Skip to content

Commit f91cdb7

Browse files
committed
fix(ci): create musl-g++ wrapper so z3 compiles against musl headers
Using system g++ directly produces object files with glibc symbols like __printf_chk that don't exist in musl. Instead, create a musl-g++ wrapper that mirrors musl-gcc: it invokes g++ with the musl-gcc.specs file, which redirects include and library paths to musl. This ensures z3 compiles against musl headers and avoids glibc symbol references.
1 parent 914adda commit f91cdb7

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

.github/workflows/release-dev.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ jobs:
202202
apt-get install -y --no-install-recommends musl-tools
203203
rm -rf /var/lib/apt/lists/*
204204
205+
- name: Create musl-g++ wrapper
206+
run: |
207+
set -euo pipefail
208+
# musl-tools ships musl-gcc (C wrapper) but not a C++ equivalent.
209+
# z3's bundled cmake build needs a C++ compiler that targets musl.
210+
# Extract the specs path from musl-gcc and create a parallel g++ wrapper.
211+
SPECS=$(sed -n 's/.*-specs "\([^"]*\)".*/\1/p' "$(which musl-gcc)")
212+
printf '#!/bin/sh\nexec g++ "$@" -specs "%s"\n' "$SPECS" > /usr/local/bin/musl-g++
213+
chmod +x /usr/local/bin/musl-g++
214+
205215
- name: Add Rust musl target
206216
run: mise x -- rustup target add ${{ matrix.target }}
207217

@@ -221,11 +231,8 @@ jobs:
221231
222232
- name: Build ${{ matrix.target }}
223233
env:
224-
# musl-tools only provides musl-gcc (C); z3 bundled build needs a
225-
# C++ compiler. The system g++ works because z3's public API uses
226-
# C linkage and libstdc++ is statically linked in the final binary.
227-
CXX_aarch64_unknown_linux_musl: g++
228-
CXX_x86_64_unknown_linux_musl: g++
234+
CXX_aarch64_unknown_linux_musl: musl-g++
235+
CXX_x86_64_unknown_linux_musl: musl-g++
229236
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli --features bundled-z3
230237

231238
- name: sccache stats

.github/workflows/release-tag.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ jobs:
224224
apt-get install -y --no-install-recommends musl-tools
225225
rm -rf /var/lib/apt/lists/*
226226
227+
- name: Create musl-g++ wrapper
228+
run: |
229+
set -euo pipefail
230+
SPECS=$(sed -n 's/.*-specs "\([^"]*\)".*/\1/p' "$(which musl-gcc)")
231+
printf '#!/bin/sh\nexec g++ "$@" -specs "%s"\n' "$SPECS" > /usr/local/bin/musl-g++
232+
chmod +x /usr/local/bin/musl-g++
233+
227234
- name: Add Rust musl target
228235
run: mise x -- rustup target add ${{ matrix.target }}
229236

@@ -243,8 +250,8 @@ jobs:
243250
244251
- name: Build ${{ matrix.target }}
245252
env:
246-
CXX_aarch64_unknown_linux_musl: g++
247-
CXX_x86_64_unknown_linux_musl: g++
253+
CXX_aarch64_unknown_linux_musl: musl-g++
254+
CXX_x86_64_unknown_linux_musl: musl-g++
248255
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli --features bundled-z3
249256

250257
- name: sccache stats

0 commit comments

Comments
 (0)