Skip to content

Commit 320fd01

Browse files
ewelsclaude
andauthored
fix: scope rustflags to target triple to avoid SIGILL in build scripts (#91)
The previous fix (#90) switched from RUSTFLAGS to build.rustflags, but build.rustflags still applies to build scripts. Use target-scoped rustflags (target.'<triple>'.rustflags) so CPU flags only affect crate compilation, leaving host build scripts unaffected. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 176137f commit 320fd01

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,21 @@ jobs:
4545

4646
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # ratchet:Swatinem/rust-cache@v2.9.1
4747

48+
- name: Detect host triple
49+
if: matrix.target_cpu
50+
run: echo "HOST_TRIPLE=$(rustc -vV | awk '/^host:/ {print $2}')" >> "$GITHUB_ENV"
51+
4852
- name: Build
4953
run: >
5054
cargo build --release
51-
${TARGET_CPU:+--config "build.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
55+
${TARGET_CPU:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
5256
env:
5357
TARGET_CPU: ${{ matrix.target_cpu || '' }}
5458

5559
- name: Test
5660
run: >
5761
cargo test --release
58-
${TARGET_CPU:+--config "build.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
62+
${TARGET_CPU:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
5963
env:
6064
TARGET_CPU: ${{ matrix.target_cpu || '' }}
6165

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
- name: Build
125125
run: >
126126
cargo build --release --target ${{ matrix.target }}
127-
${TARGET_CPU:+--config "build.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
127+
${TARGET_CPU:+--config "target.'${{ matrix.target }}'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
128128
env:
129129
TARGET_CPU: ${{ matrix.target_cpu || '' }}
130130

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ COPY Cargo.toml Cargo.lock build.rs ./
2121
COPY cpp/ cpp/
2222
COPY src/ src/
2323

24-
RUN GIT_SHORT_HASH="${GIT_SHORT_HASH}" \
24+
RUN HOST_TRIPLE=$(rustc -vV | awk '/^host:/ {print $2}') && \
25+
GIT_SHORT_HASH="${GIT_SHORT_HASH}" \
2526
cargo build --release \
26-
${CPU_TARGET:+--config "build.rustflags=['-C', 'target-cpu=$CPU_TARGET']"} \
27+
${CPU_TARGET:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$CPU_TARGET']"} \
2728
&& strip target/release/rustqc
2829

2930
# ---- Runtime stage ----

0 commit comments

Comments
 (0)