File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,15 +32,28 @@ jobs:
3232 - name : Build Linux
3333 if : matrix.os == 'ubuntu-22.04'
3434 run : |
35+ sudo apt-get update
3536 chmod 755 *.sh
3637 echo "building linux-x64"
3738 ./build-linux-x64.sh
3839 echo "building linux-arm64"
39- sudo apt-get install gcc-aarch64-linux-gnu
40+ sudo apt-get install -y gcc-aarch64-linux-gnu
4041 ./build-linux-arm64.sh
4142 echo "building linux-arm"
42- sudo apt-get install gcc-arm-linux-gnueabihf
43+ sudo apt-get install -y gcc-arm-linux-gnueabihf
4344 ./build-linux-arm.sh
45+
46+ # musl
47+ echo "building linux-musl-x64"
48+ sudo apt-get install -y musl-tools
49+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc ./build-linux-musl-x64.sh
50+
51+ echo "building linux-musl-arm64"
52+ # Use cross (Docker-based) to avoid installing a full aarch64 musl toolchain on the runner.
53+ cargo install cross --locked
54+ RUSTFLAGS="-C target-feature=-crt-static" cross build --release --target aarch64-unknown-linux-musl
55+ mkdir -p build/linux-musl-arm64/native
56+ cp target/aarch64-unknown-linux-musl/release/libblake3_dotnet.so build/linux-musl-arm64/native
4457 - name : Build macOS
4558 if : matrix.os == 'macos-latest'
4659 run : |
Original file line number Diff line number Diff line change @@ -4,7 +4,13 @@ rustflags = ["-Ctarget-feature=+crt-static"]
44rustflags = [" -Ctarget-feature=+crt-static" ]
55[target .x86_64-unknown-linux-gnu ]
66rustflags = [" -Ctarget-feature=-crt-static" ]
7+ [target .x86_64-unknown-linux-musl ]
8+ linker = " x86_64-linux-musl-gcc"
9+ rustflags = [" -Ctarget-feature=-crt-static" ]
710[target .aarch64-unknown-linux-gnu ]
811linker = " aarch64-linux-gnu-gcc"
12+ [target .aarch64-unknown-linux-musl ]
13+ linker = " aarch64-linux-musl-gcc"
14+ rustflags = [" -Ctarget-feature=-crt-static" ]
915[target .arm-unknown-linux-gnueabihf ]
1016linker = " arm-linux-gnueabihf-gcc"
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -eu
3+
4+ TARGET=" aarch64-unknown-linux-musl"
5+ BUILD=" linux-musl-arm64"
6+
7+ rustup target add " $TARGET "
8+
9+ # Some toolchains/environments require disabling crt static linking for musl.
10+ # If you already set RUSTFLAGS, this appends the flag.
11+ EXTRA_RUSTFLAGS=" -C target-feature=-crt-static"
12+ if [ " ${RUSTFLAGS:- } " = " " ]; then
13+ export RUSTFLAGS=" $EXTRA_RUSTFLAGS "
14+ else
15+ export RUSTFLAGS=" $RUSTFLAGS $EXTRA_RUSTFLAGS "
16+ fi
17+
18+ cargo build --release --target " $TARGET "
19+
20+ mkdir -p " build/$BUILD /native"
21+ cp " target/$TARGET /release/libblake3_dotnet.so" " build/$BUILD /native"
22+
23+ # Prefer a target-specific strip if available, otherwise fall back.
24+ if command -v aarch64-linux-musl-strip > /dev/null 2>&1 ; then
25+ aarch64-linux-musl-strip " build/$BUILD /native" /* .so
26+ elif command -v llvm-strip > /dev/null 2>&1 ; then
27+ llvm-strip " build/$BUILD /native" /* .so || true
28+ elif command -v strip > /dev/null 2>&1 ; then
29+ strip " build/$BUILD /native" /* .so || true
30+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -eu
3+
4+ TARGET=" x86_64-unknown-linux-musl"
5+ BUILD=" linux-musl-x64"
6+
7+ rustup target add " $TARGET "
8+
9+ # Some toolchains/environments require disabling crt static linking for musl.
10+ # If you already set RUSTFLAGS, this appends the flag.
11+ EXTRA_RUSTFLAGS=" -C target-feature=-crt-static"
12+ if [ " ${RUSTFLAGS:- } " = " " ]; then
13+ export RUSTFLAGS=" $EXTRA_RUSTFLAGS "
14+ else
15+ export RUSTFLAGS=" $RUSTFLAGS $EXTRA_RUSTFLAGS "
16+ fi
17+
18+ cargo build --release --target " $TARGET "
19+
20+ mkdir -p " build/$BUILD /native"
21+ cp " target/$TARGET /release/libblake3_dotnet.so" " build/$BUILD /native"
22+
23+ if command -v strip > /dev/null 2>&1 ; then
24+ strip " build/$BUILD /native" /* .so || true
25+ fi
Original file line number Diff line number Diff line change @@ -6,4 +6,8 @@ BLAKE3 Rust libraries compiled to native and exposed as plain shared libraries.
66
77You need to have [ ` rustup ` ] ( https://rustup.rs/ ) installed
88
9- Run one of the ` build* ` scripts (e.g ` build-win-x64.ps1 ` or ` build-linux-x64.sh ` ).
9+ Run one of the ` build* ` scripts (e.g ` build-win-x64.ps1 ` or ` build-linux-x64.sh ` ).
10+
11+ Musl targets are supported via:
12+ - ` build-linux-musl-x64.sh ` (` x86_64-unknown-linux-musl ` )
13+ - ` build-linux-musl-arm64.sh ` (` aarch64-unknown-linux-musl ` )
You can’t perform that action at this time.
0 commit comments