File tree Expand file tree Collapse file tree 5 files changed +78
-3
lines changed
Expand file tree Collapse file tree 5 files changed +78
-3
lines changed 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+ 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,11 @@ 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 = " musl-gcc"
79[target .aarch64-unknown-linux-gnu ]
810linker = " aarch64-linux-gnu-gcc"
11+ [target .aarch64-unknown-linux-musl ]
12+ linker = " aarch64-linux-musl-gcc"
913[target .arm-unknown-linux-gnueabihf ]
1014linker = " 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+ # Prefer building via cross (Docker) to avoid requiring a full aarch64 musl toolchain.
10+ if command -v cross > /dev/null 2>&1 ; then
11+ cross build --release --target " $TARGET "
12+ else
13+ # If you need to disable crt-static for your environment, set: NO_CRT_STATIC=1
14+ if [ " ${NO_CRT_STATIC:- } " != " " ]; then
15+ export RUSTFLAGS=" ${RUSTFLAGS:- } -C target-feature=-crt-static"
16+ fi
17+ # Some toolchains don't ship libgcc_s.so.1; force static libgcc when using a local gcc-based linker.
18+ export RUSTFLAGS=" ${RUSTFLAGS:- } -C link-arg=-static-libgcc"
19+ cargo build --release --target " $TARGET "
20+ fi
21+
22+ mkdir -p " build/$BUILD /native"
23+ cp " target/$TARGET /release/libblake3_dotnet.so" " build/$BUILD /native"
24+
25+ # Prefer a target-specific strip if available, otherwise fall back.
26+ if command -v aarch64-linux-musl-strip > /dev/null 2>&1 ; then
27+ aarch64-linux-musl-strip " build/$BUILD /native" /* .so
28+ elif command -v llvm-strip > /dev/null 2>&1 ; then
29+ llvm-strip " build/$BUILD /native" /* .so || true
30+ elif command -v strip > /dev/null 2>&1 ; then
31+ strip " build/$BUILD /native" /* .so || true
32+ 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+ # By default, musl targets are built with a static C runtime.
10+ # If you need to disable it for your environment, set: NO_CRT_STATIC=1
11+ if [ " ${NO_CRT_STATIC:- } " != " " ]; then
12+ export RUSTFLAGS=" ${RUSTFLAGS:- } -C target-feature=-crt-static"
13+ fi
14+
15+ cargo build --release --target " $TARGET "
16+
17+ mkdir -p " build/$BUILD /native"
18+ cp " target/$TARGET /release/libblake3_dotnet.so" " build/$BUILD /native"
19+
20+ if command -v strip > /dev/null 2>&1 ; then
21+ strip " build/$BUILD /native" /* .so || true
22+ 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