Skip to content

Commit 4ab5963

Browse files
authored
Merge pull request #32 from xoofx/try-musl
Add musl build
2 parents 3df186b + 824bf03 commit 4ab5963

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

.github/workflows/native.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,27 @@ 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
44-
- name: Build macOS
45+
- name: Build macOS and musl Linux
4546
if: matrix.os == 'macos-latest'
4647
run: |
4748
chmod 755 *.sh
4849
./build-osx-x64.sh
4950
./build-osx-arm64.sh
51+
brew tap messense/macos-cross-toolchains
52+
brew install aarch64-unknown-linux-musl
53+
brew install x86_64-unknown-linux-musl
54+
./build-linux-musl-x64.sh
55+
./build-linux-musl-arm64.sh
5056
- name: Build Windows
5157
if: matrix.os == 'windows-latest'
5258
run: |

lib/blake3_dotnet/.cargo/config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ rustflags = ["-Ctarget-feature=+crt-static"]
44
rustflags = ["-Ctarget-feature=+crt-static"]
55
[target.x86_64-unknown-linux-gnu]
66
rustflags = ["-Ctarget-feature=-crt-static"]
7+
[target.x86_64-unknown-linux-musl]
8+
linker = "musl-gcc"
9+
rustflags = ["-Ctarget-feature=-crt-static", "-Clinker=x86_64-linux-musl-gcc"]
710
[target.aarch64-unknown-linux-gnu]
811
linker = "aarch64-linux-gnu-gcc"
12+
[target.aarch64-unknown-linux-musl]
13+
linker = "aarch64-linux-musl-gcc"
14+
rustflags = ["-Ctarget-feature=-crt-static", "-Clinker=aarch64-linux-musl-gcc"]
915
[target.arm-unknown-linux-gnueabihf]
1016
linker = "arm-linux-gnueabihf-gcc"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
cargo build --release --target "$TARGET"
9+
10+
mkdir -p "build/$BUILD/native"
11+
cp "target/$TARGET/release/libblake3_dotnet.so" "build/$BUILD/native"
12+
13+
# Prefer a target-specific strip if available, otherwise fall back.
14+
if command -v aarch64-linux-musl-strip >/dev/null 2>&1; then
15+
aarch64-linux-musl-strip "build/$BUILD/native"/*.so
16+
elif command -v llvm-strip >/dev/null 2>&1; then
17+
llvm-strip "build/$BUILD/native"/*.so || true
18+
elif command -v strip >/dev/null 2>&1; then
19+
strip "build/$BUILD/native"/*.so || true
20+
fi
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
cargo build --release --target "$TARGET"
9+
10+
mkdir -p "build/$BUILD/native"
11+
cp "target/$TARGET/release/libblake3_dotnet.so" "build/$BUILD/native"
12+
13+
if command -v strip >/dev/null 2>&1; then
14+
strip "build/$BUILD/native"/*.so || true
15+
fi

lib/blake3_dotnet/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ BLAKE3 Rust libraries compiled to native and exposed as plain shared libraries.
66

77
You 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`)

0 commit comments

Comments
 (0)