Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,27 @@ jobs:
- name: Build Linux
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
chmod 755 *.sh
echo "building linux-x64"
./build-linux-x64.sh
echo "building linux-arm64"
sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install -y gcc-aarch64-linux-gnu
./build-linux-arm64.sh
echo "building linux-arm"
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install -y gcc-arm-linux-gnueabihf
./build-linux-arm.sh
- name: Build macOS
- name: Build macOS and musl Linux
if: matrix.os == 'macos-latest'
run: |
chmod 755 *.sh
./build-osx-x64.sh
./build-osx-arm64.sh
brew tap messense/macos-cross-toolchains
brew install aarch64-unknown-linux-musl
brew install x86_64-unknown-linux-musl
./build-linux-musl-x64.sh
./build-linux-musl-arm64.sh
- name: Build Windows
if: matrix.os == 'windows-latest'
run: |
Expand Down
6 changes: 6 additions & 0 deletions lib/blake3_dotnet/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ rustflags = ["-Ctarget-feature=+crt-static"]
rustflags = ["-Ctarget-feature=+crt-static"]
[target.x86_64-unknown-linux-gnu]
rustflags = ["-Ctarget-feature=-crt-static"]
[target.x86_64-unknown-linux-musl]
linker = "musl-gcc"
rustflags = ["-Ctarget-feature=-crt-static", "-Clinker=x86_64-linux-musl-gcc"]
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-Ctarget-feature=-crt-static", "-Clinker=aarch64-linux-musl-gcc"]
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
20 changes: 20 additions & 0 deletions lib/blake3_dotnet/build-linux-musl-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu

TARGET="aarch64-unknown-linux-musl"
BUILD="linux-musl-arm64"

rustup target add "$TARGET"
cargo build --release --target "$TARGET"

mkdir -p "build/$BUILD/native"
cp "target/$TARGET/release/libblake3_dotnet.so" "build/$BUILD/native"

# Prefer a target-specific strip if available, otherwise fall back.
if command -v aarch64-linux-musl-strip >/dev/null 2>&1; then
aarch64-linux-musl-strip "build/$BUILD/native"/*.so
elif command -v llvm-strip >/dev/null 2>&1; then
llvm-strip "build/$BUILD/native"/*.so || true
elif command -v strip >/dev/null 2>&1; then
strip "build/$BUILD/native"/*.so || true
fi
15 changes: 15 additions & 0 deletions lib/blake3_dotnet/build-linux-musl-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -eu

TARGET="x86_64-unknown-linux-musl"
BUILD="linux-musl-x64"

rustup target add "$TARGET"
cargo build --release --target "$TARGET"

mkdir -p "build/$BUILD/native"
cp "target/$TARGET/release/libblake3_dotnet.so" "build/$BUILD/native"

if command -v strip >/dev/null 2>&1; then
strip "build/$BUILD/native"/*.so || true
fi
6 changes: 5 additions & 1 deletion lib/blake3_dotnet/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ BLAKE3 Rust libraries compiled to native and exposed as plain shared libraries.

You need to have [`rustup`](https://rustup.rs/) installed

Run one of the `build*` scripts (e.g `build-win-x64.ps1` or `build-linux-x64.sh`).
Run one of the `build*` scripts (e.g `build-win-x64.ps1` or `build-linux-x64.sh`).

Musl targets are supported via:
- `build-linux-musl-x64.sh` (`x86_64-unknown-linux-musl`)
- `build-linux-musl-arm64.sh` (`aarch64-unknown-linux-musl`)
Loading