9191 rust : [stable, nightly]
9292 clang : ["15", "17"]
9393 phpts : [ts, nts]
94+ target : [gnu, musl]
9495 exclude :
9596 # ext-php-rs requires nightly Rust when on Windows.
9697 - os : windows-latest
@@ -101,11 +102,23 @@ jobs:
101102 clang : " 15"
102103 - os : windows-latest
103104 clang : " 15"
105+ # musl only supported on Linux with stable Rust
106+ - os : windows-latest
107+ target : musl
108+ - os : macos-latest
109+ target : musl
110+ - target : musl
111+ rust : nightly
104112 env :
105113 CARGO_TERM_COLOR : always
106114 steps :
107115 - name : Checkout code
108116 uses : actions/checkout@v5
117+ - name : Install musl toolchain
118+ if : matrix.target == 'musl'
119+ run : |
120+ sudo apt-get update
121+ sudo apt-get install -y musl-tools musl-dev
109122 - name : Setup PHP
110123 uses : shivammathur/setup-php@v2
111124 with :
@@ -118,6 +131,9 @@ jobs:
118131 with :
119132 toolchain : ${{ matrix.rust }}
120133 components : rustfmt, clippy
134+ - name : Add musl target
135+ if : matrix.target == 'musl'
136+ run : rustup target add x86_64-unknown-linux-musl
121137 - run : rustup show
122138 - name : Cache cargo dependencies
123139 uses : Swatinem/rust-cache@v2
@@ -162,13 +178,15 @@ jobs:
162178 - name : Build
163179 env :
164180 EXT_PHP_RS_TEST : " "
165- run : cargo build --release --features closure,anyhow,runtime --workspace
181+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
182+ run : cargo build --release --features closure,anyhow,runtime --workspace ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
166183 # Test
167184 - name : Test inline examples
168185 # Macos fails on unstable rust. We skip the inline examples test for now.
169186 if : " !(contains(matrix.os, 'macos') && matrix.rust == 'nightly')"
170- run : cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast
171-
187+ env :
188+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
189+ run : cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
172190 test-embed :
173191 name : Test with embed
174192 runs-on : ubuntu-latest
0 commit comments