Skip to content

Commit 405670a

Browse files
ewelsclaude
andcommitted
fix: pass --target to cargo so rustflags skip build scripts
Without an explicit --target flag, Cargo does not distinguish host from target compilation, so target.<triple>.rustflags still applies to build scripts. Pass --target explicitly to force the separation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 320fd01 commit 405670a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ jobs:
5252
- name: Build
5353
run: >
5454
cargo build --release
55-
${TARGET_CPU:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
55+
${TARGET_CPU:+--target "$HOST_TRIPLE" --config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
5656
env:
5757
TARGET_CPU: ${{ matrix.target_cpu || '' }}
5858

5959
- name: Test
6060
run: >
6161
cargo test --release
62-
${TARGET_CPU:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
62+
${TARGET_CPU:+--target "$HOST_TRIPLE" --config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$TARGET_CPU']"}
6363
env:
6464
TARGET_CPU: ${{ matrix.target_cpu || '' }}
6565

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ COPY src/ src/
2323

2424
RUN HOST_TRIPLE=$(rustc -vV | awk '/^host:/ {print $2}') && \
2525
GIT_SHORT_HASH="${GIT_SHORT_HASH}" \
26-
cargo build --release \
26+
cargo build --release --target "$HOST_TRIPLE" \
2727
${CPU_TARGET:+--config "target.'$HOST_TRIPLE'.rustflags=['-C', 'target-cpu=$CPU_TARGET']"} \
28-
&& strip target/release/rustqc
28+
&& strip "target/$HOST_TRIPLE/release/rustqc" \
29+
&& cp "target/$HOST_TRIPLE/release/rustqc" /rustqc
2930

3031
# ---- Runtime stage ----
3132
FROM debian:bookworm-slim
@@ -36,6 +37,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3637
procps \
3738
&& rm -rf /var/lib/apt/lists/*
3839

39-
COPY --from=builder /build/target/release/rustqc /usr/local/bin/rustqc
40+
COPY --from=builder /rustqc /usr/local/bin/rustqc
4041

4142
CMD ["rustqc"]

0 commit comments

Comments
 (0)