Skip to content

Commit 6dfec1a

Browse files
authored
Rollup merge of #143964 - nikic:docker-script-arg, r=marcoieni
Fix handling of SCRIPT_ARG in docker images Instead of making this a build parameter, pass the SCRIPT as an environment variable. To this purpose, normalize on always referring to a script in `/scripts`. For i686-gnu-nopt-2 I had to create a separate script, because Docker seems to be really terrible at command line argument parsing, so it's not possible to pass an environment variable that contains whitespace. Fixes #143962. try-job: `dist-x86_64-linux` try-job: `i686-gnu-nopt-*` try-job: `i686-gnu-*` try-job: `x86_64-gnu-llvm-19-*` try-job: `x86_64-gnu-llvm-20-*`
2 parents 7a85c59 + 4b421d4 commit 6dfec1a

File tree

10 files changed

+32
-41
lines changed

10 files changed

+32
-41
lines changed

src/ci/docker/host-aarch64/aarch64-gnu-llvm-19/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ ENV RUST_CONFIGURE_ARGS \
5050

5151
COPY scripts/shared.sh /scripts/
5252

53-
ARG SCRIPT_ARG
53+
COPY scripts/stage_2_test_set1.sh /scripts/
54+
COPY scripts/stage_2_test_set2.sh /scripts/
5455

55-
COPY scripts/stage_2_test_set1.sh /tmp/
56-
COPY scripts/stage_2_test_set2.sh /tmp/
57-
58-
ENV SCRIPT "/tmp/${SCRIPT_ARG}"
56+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ ENV RUST_CONFIGURE_ARGS \
9696
--set rust.lto=thin \
9797
--set rust.codegen-units=1
9898

99-
ARG SCRIPT_ARG
100-
10199
COPY host-x86_64/dist-x86_64-linux/dist.sh /scripts/
102100
COPY host-x86_64/dist-x86_64-linux/dist-alt.sh /scripts/
103101

104-
ENV SCRIPT /scripts/${SCRIPT_ARG}
102+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
105103

106104
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
107105

src/ci/docker/host-x86_64/i686-gnu-nopt/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COPY scripts/sccache.sh /scripts/
2323
RUN sh /scripts/sccache.sh
2424

2525
ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu --disable-optimize-tests
26-
ARG SCRIPT_ARG
2726
COPY scripts/stage_2_test_set1.sh /scripts/
2827
COPY scripts/stage_2_test_set2.sh /scripts/
29-
ENV SCRIPT ${SCRIPT_ARG}
28+
COPY scripts/i686-gnu-nopt-2.sh /scripts/
29+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

src/ci/docker/host-x86_64/i686-gnu/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ COPY scripts/sccache.sh /scripts/
2424
RUN sh /scripts/sccache.sh
2525

2626
ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu
27-
ARG SCRIPT_ARG
2827
COPY scripts/stage_2_test_set1.sh /scripts/
2928
COPY scripts/stage_2_test_set2.sh /scripts/
30-
ENV SCRIPT /scripts/${SCRIPT_ARG}
29+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

src/ci/docker/host-x86_64/x86_64-gnu-llvm-19/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ ENV RUST_CONFIGURE_ARGS \
5757

5858
COPY scripts/shared.sh /scripts/
5959

60-
ARG SCRIPT_ARG
60+
COPY scripts/x86_64-gnu-llvm.sh /scripts/
61+
COPY scripts/x86_64-gnu-llvm2.sh /scripts/
62+
COPY scripts/x86_64-gnu-llvm3.sh /scripts/
63+
COPY scripts/stage_2_test_set1.sh /scripts/
64+
COPY scripts/stage_2_test_set2.sh /scripts/
6165

62-
COPY scripts/x86_64-gnu-llvm.sh /tmp/
63-
COPY scripts/x86_64-gnu-llvm2.sh /tmp/
64-
COPY scripts/x86_64-gnu-llvm3.sh /tmp/
65-
COPY scripts/stage_2_test_set1.sh /tmp/
66-
COPY scripts/stage_2_test_set2.sh /tmp/
67-
68-
ENV SCRIPT "/tmp/${SCRIPT_ARG}"
66+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

src/ci/docker/host-x86_64/x86_64-gnu-llvm-20/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ ENV RUST_CONFIGURE_ARGS \
5757

5858
COPY scripts/shared.sh /scripts/
5959

60-
ARG SCRIPT_ARG
60+
COPY scripts/x86_64-gnu-llvm.sh /scripts/
61+
COPY scripts/x86_64-gnu-llvm2.sh /scripts/
62+
COPY scripts/x86_64-gnu-llvm3.sh /scripts/
63+
COPY scripts/stage_2_test_set1.sh /scripts/
64+
COPY scripts/stage_2_test_set2.sh /scripts/
6165

62-
COPY scripts/x86_64-gnu-llvm.sh /tmp/
63-
COPY scripts/x86_64-gnu-llvm2.sh /tmp/
64-
COPY scripts/x86_64-gnu-llvm3.sh /tmp/
65-
COPY scripts/stage_2_test_set1.sh /tmp/
66-
COPY scripts/stage_2_test_set2.sh /tmp/
67-
68-
ENV SCRIPT "/tmp/${SCRIPT_ARG}"
66+
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

src/ci/docker/run.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
114114
"$context"
115115
)
116116

117-
# If the environment variable DOCKER_SCRIPT is defined,
118-
# set the build argument SCRIPT_ARG to DOCKER_SCRIPT.
119-
# In this way, we run the script defined in CI,
120-
# instead of the one defined in the Dockerfile.
121-
if [ -n "${DOCKER_SCRIPT+x}" ]; then
122-
build_args+=("--build-arg" "SCRIPT_ARG=${DOCKER_SCRIPT}")
123-
fi
124-
125117
GHCR_BUILDKIT_IMAGE="ghcr.io/rust-lang/buildkit:buildx-stable-1"
126118
# On non-CI jobs, we try to download a pre-built image from the rust-lang-ci
127119
# ghcr.io registry. If it is not possible, we fall back to building the image
@@ -341,6 +333,10 @@ if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
341333
echo "Setting extra environment values for docker: $extra_env"
342334
fi
343335

336+
if [ -n "${DOCKER_SCRIPT}" ]; then
337+
extra_env="$extra_env --env SCRIPT=\"/scripts/${DOCKER_SCRIPT}\""
338+
fi
339+
344340
docker \
345341
run \
346342
--workdir /checkout/obj \
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
python3 ../x.py test --stage 1 --set rust.optimize=false library/std &&
6+
/scripts/stage_2_test_set2.sh

src/ci/docker/scripts/x86_64-gnu-llvm2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ex
44

55
##### Test stage 2 #####
66

7-
/tmp/stage_2_test_set1.sh
7+
/scripts/stage_2_test_set1.sh
88

99
# Run the `mir-opt` tests again but this time for a 32-bit target.
1010
# This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have

src/ci/github-actions/jobs.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,14 @@ auto:
315315
- name: i686-gnu-nopt-1
316316
env:
317317
IMAGE: i686-gnu-nopt
318-
DOCKER_SCRIPT: /scripts/stage_2_test_set1.sh
318+
DOCKER_SCRIPT: stage_2_test_set1.sh
319319
<<: *job-linux-4c
320320

321321
# Skip tests that run in i686-gnu-nopt-1
322322
- name: i686-gnu-nopt-2
323323
env:
324324
IMAGE: i686-gnu-nopt
325-
DOCKER_SCRIPT: >-
326-
python3 ../x.py test --stage 1 --set rust.optimize=false library/std &&
327-
/scripts/stage_2_test_set2.sh
325+
DOCKER_SCRIPT: i686-gnu-nopt-2.sh
328326
<<: *job-linux-4c
329327

330328
- name: pr-check-1

0 commit comments

Comments
 (0)