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,26 @@ 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
112+ # Skip PHP 8.0 for musl (EOL)
113+ - target : musl
114+ php : " 8.0"
104115 env :
105116 CARGO_TERM_COLOR : always
106117 steps :
107118 - name : Checkout code
108119 uses : actions/checkout@v5
120+ - name : Install musl toolchain
121+ if : matrix.target == 'musl'
122+ run : |
123+ sudo apt-get update
124+ sudo apt-get install -y musl-tools musl-dev
109125 - name : Setup PHP
110126 uses : shivammathur/setup-php@v2
111127 with :
@@ -118,6 +134,9 @@ jobs:
118134 with :
119135 toolchain : ${{ matrix.rust }}
120136 components : rustfmt, clippy
137+ - name : Add musl target
138+ if : matrix.target == 'musl'
139+ run : rustup target add x86_64-unknown-linux-musl
121140 - run : rustup show
122141 - name : Cache cargo dependencies
123142 uses : Swatinem/rust-cache@v2
@@ -162,12 +181,15 @@ jobs:
162181 - name : Build
163182 env :
164183 EXT_PHP_RS_TEST : " "
165- run : cargo build --release --features closure,anyhow --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
184+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
185+ run : cargo build --release --features closure,anyhow --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }} ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
166186 # Test
167187 - name : Test inline examples
168188 # Macos fails on unstable rust. We skip the inline examples test for now.
169189 if : " !(contains(matrix.os, 'macos') && matrix.rust == 'nightly')"
170- run : cargo test --release --workspace --features closure,anyhow --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
190+ env :
191+ RUSTFLAGS : ${{ matrix.target == 'musl' && '-C target-feature=-crt-static' || '' }}
192+ run : cargo test --release --workspace --features closure,anyhow --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }} ${{ matrix.target == 'musl' && '--target x86_64-unknown-linux-musl' || '' }}
171193 build-zts :
172194 name : Build with ZTS
173195 runs-on : ubuntu-latest
0 commit comments