From 379f88b05f019a38b1d2a73ae9b1d677028d48de Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Sun, 11 Jun 2023 23:24:28 +0200 Subject: [PATCH] docs: cross-compiling sws from source [skip ci] https://static-web-server.net/building-from-source/#cross-compiling --- docs/content/building-from-source.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/content/building-from-source.md b/docs/content/building-from-source.md index 2556819..4d58cd1 100644 --- a/docs/content/building-from-source.md +++ b/docs/content/building-from-source.md @@ -50,6 +50,25 @@ cargo run --no-default-features -- -h cargo build --release --no-default-features ``` +## Cross-compiling + +If you want to cross-compile SWS then consider using [Zig](https://github.com/ziglang/zig) as [linker](https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html) for [easier cross compiling](https://actually.fyi/posts/zig-makes-rust-cross-compilation-just-work/). + +Let's say, you want to cross-compile SWS from macOS to Linux. Then follow these steps. + +1. Add the necessary toolchain, for example: `rustup target add x86_64-unknown-linux-gnu` or using `rustup target add x86_64-unknown-linux-musl` if a statically-linked binary is wanted. +2. Install the latest [Zig](https://github.com/ziglang/zig) version via `brew install zig` +3. Install [cargo-zigbuild](https://github.com/rust-cross/cargo-zigbuild) via `cargo install cargo-zigbuild` +4. Finally, just build SWS as follows: + ```sh + # dynamically-linked binary + cargo zigbuild --verbose --release --target=x86_64-unknown-linux-gnu + # or statically-linked binary + cargo zigbuild --verbose --release --target=x86_64-unknown-linux-musl + ``` + +Built binaries can be found under the corresponding toolchain directory inside `target/`. + ## Building documentation from source All HTML documentation is located in the `docs/` project's directory and is built using [Material for MkDocs](https://github.com/squidfunk/mkdocs-material). -- libgit2 1.7.2