Skip to content

Commit

Permalink
Build musl
Browse files Browse the repository at this point in the history
The performance of musl is worse than glibc, but static link is suitable for more environments.
  • Loading branch information
james58899 committed Jun 3, 2024
1 parent 07bd74b commit 24cac4e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
required: false
type: boolean
default: false
skip-linux-musl:
required: false
type: boolean
default: false
skip-windows:
required: false
type: boolean
Expand Down Expand Up @@ -58,6 +62,50 @@ jobs:
with:
name: hath-rust-${{ matrix.target }}
path: target/${{ matrix.target }}/release/hath-rust
build-linux-musl:
runs-on: ubuntu-latest
if: inputs.skip-linux-musl != true
strategy:
fail-fast: false
matrix:
target: ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", "armv7-unknown-linux-musleabihf"]
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo apt-get install -y crossbuild-essential-arm64 crossbuild-essential-armhf
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
run: |
rustup update
rustup toolchain install nightly
rustup target add --toolchain nightly ${{ matrix.target }}
- name: Build
env:
CC: clang-18
CXX: clang-18
CFLAGS: "-fuse-ld=lld-18"
CXXFLAGS: "-fuse-ld=lld-18"
CARGO_HOST_RUSTFLAGS: "-Clinker=clang-18 -Clink-arg=-fuse-ld=lld-18"
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clinker=clang-18 -Clink-arg=-fuse-ld=lld-18 -Clink-arg=--target=x86_64-unknown-linux-musl"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clinker=clang-18 -Clink-arg=-fuse-ld=lld-18 -Clink-arg=--target=aarch64-unknown-linux-musl"
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS: "-Clinker=clang-18 -Clink-arg=-fuse-ld=lld-18 -Clink-arg=--target=armv7-unknown-linux-musleabihf"
run: cargo +nightly -Ztarget-applies-to-host -Zhost-config build --verbose --release --target=${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: hath-rust-${{ matrix.target }}
path: target/${{ matrix.target }}/release/hath-rust
build-windows:
runs-on: windows-latest
if: inputs.skip-windows != true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
with:
skip-windows: true
skip-macos: true
skip-linux-musl: true
Docker:
needs: Build
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ jobs:
- name: Rename artifact
run: |
mv artifacts/hath-rust-x86_64-unknown-linux-gnu/hath-rust hath-rust-x86_64-unknown-linux-gnu
mv artifacts/hath-rust-x86_64-unknown-linux-musl/hath-rust hath-rust-x86_64-unknown-linux-musl
mv artifacts/hath-rust-aarch64-unknown-linux-gnu/hath-rust hath-rust-aarch64-unknown-linux-gnu
mv artifacts/hath-rust-aarch64-unknown-linux-musl/hath-rust hath-rust-aarch64-unknown-linux-musl
mv artifacts/hath-rust-armv7-unknown-linux-gnueabihf/hath-rust hath-rust-armv7-unknown-linux-gnueabihf
mv artifacts/hath-rust-armv7-unknown-linux-musleabihf/hath-rust hath-rust-armv7-unknown-linux-musleabihf
mv artifacts/hath-rust-x86_64-pc-windows-msvc/hath-rust.exe hath-rust-x86_64-pc-windows-msvc.exe
mv artifacts/hath-rust-i686-pc-windows-msvc/hath-rust.exe hath-rust-i686-pc-windows-msvc.exe
mv artifacts/hath-rust-universal-apple-darwin/hath-rust hath-rust-universal-apple-darwin
Expand All @@ -32,8 +35,11 @@ jobs:
generate_release_notes: true
files: |
hath-rust-x86_64-unknown-linux-gnu
hath-rust-x86_64-unknown-linux-musl
hath-rust-aarch64-unknown-linux-gnu
hath-rust-aarch64-unknown-linux-musl
hath-rust-armv7-unknown-linux-gnueabihf
hath-rust-armv7-unknown-linux-musleabihf
hath-rust-x86_64-pc-windows-msvc.exe
hath-rust-i686-pc-windows-msvc.exe
hath-rust-universal-apple-darwin

0 comments on commit 24cac4e

Please sign in to comment.