File tree Expand file tree Collapse file tree 2 files changed +34
-8
lines changed
Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -209,15 +209,28 @@ jobs:
209209 run : |
210210 set -euo pipefail
211211 ZIG="$(mise which zig)"
212+ ZIG_TARGET="${{ matrix.zig_target }}"
212213 mkdir -p /tmp/zig-musl
213- printf '#!/bin/sh\nexec "%s" cc --target=${{ matrix.zig_target }} "$@"\n' "$ZIG" > /tmp/zig-musl/cc
214- printf '#!/bin/sh\nexec "%s" c++ --target=${{ matrix.zig_target }} "$@"\n' "$ZIG" > /tmp/zig-musl/cxx
215- chmod +x /tmp/zig-musl/cc /tmp/zig-musl/cxx
214+
215+ # cc-rs injects --target=<rust-triple> (e.g. aarch64-unknown-linux-musl)
216+ # which zig cannot parse. The wrappers strip any --target flags and use
217+ # the correct zig target instead.
218+ for tool in cc c++; do
219+ cat > "/tmp/zig-musl/${tool}" <<WRAPPER
220+ #!/bin/bash
221+ args=()
222+ for arg in "\$@"; do
223+ case "\$arg" in --target=*) ;; *) args+=("\$arg") ;; esac
224+ done
225+ exec "$ZIG" $tool --target=$ZIG_TARGET "\${args[@]}"
226+ WRAPPER
227+ chmod +x "/tmp/zig-musl/${tool}"
228+ done
216229
217230 # Tell cargo / cc-rs / cmake to use zig for the musl target
218231 TARGET_ENV=$(echo "${{ matrix.target }}" | tr '-' '_')
219232 echo "CC_${TARGET_ENV}=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
220- echo "CXX_${TARGET_ENV}=/tmp/zig-musl/cxx " >> "$GITHUB_ENV"
233+ echo "CXX_${TARGET_ENV}=/tmp/zig-musl/c++ " >> "$GITHUB_ENV"
221234 echo "CARGO_TARGET_${TARGET_ENV^^}_LINKER=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
222235
223236 - name : Scope workspace to CLI crates
Original file line number Diff line number Diff line change @@ -231,15 +231,28 @@ jobs:
231231 run : |
232232 set -euo pipefail
233233 ZIG="$(mise which zig)"
234+ ZIG_TARGET="${{ matrix.zig_target }}"
234235 mkdir -p /tmp/zig-musl
235- printf '#!/bin/sh\nexec "%s" cc --target=${{ matrix.zig_target }} "$@"\n' "$ZIG" > /tmp/zig-musl/cc
236- printf '#!/bin/sh\nexec "%s" c++ --target=${{ matrix.zig_target }} "$@"\n' "$ZIG" > /tmp/zig-musl/cxx
237- chmod +x /tmp/zig-musl/cc /tmp/zig-musl/cxx
236+
237+ # cc-rs injects --target=<rust-triple> (e.g. aarch64-unknown-linux-musl)
238+ # which zig cannot parse. The wrappers strip any --target flags and use
239+ # the correct zig target instead.
240+ for tool in cc c++; do
241+ cat > "/tmp/zig-musl/${tool}" <<WRAPPER
242+ #!/bin/bash
243+ args=()
244+ for arg in "\$@"; do
245+ case "\$arg" in --target=*) ;; *) args+=("\$arg") ;; esac
246+ done
247+ exec "$ZIG" $tool --target=$ZIG_TARGET "\${args[@]}"
248+ WRAPPER
249+ chmod +x "/tmp/zig-musl/${tool}"
250+ done
238251
239252 # Tell cargo / cc-rs / cmake to use zig for the musl target
240253 TARGET_ENV=$(echo "${{ matrix.target }}" | tr '-' '_')
241254 echo "CC_${TARGET_ENV}=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
242- echo "CXX_${TARGET_ENV}=/tmp/zig-musl/cxx " >> "$GITHUB_ENV"
255+ echo "CXX_${TARGET_ENV}=/tmp/zig-musl/c++ " >> "$GITHUB_ENV"
243256 echo "CARGO_TARGET_${TARGET_ENV^^}_LINKER=/tmp/zig-musl/cc" >> "$GITHUB_ENV"
244257
245258 - name : Scope workspace to CLI crates
You can’t perform that action at this time.
0 commit comments