Skip to content

Fix handling of SCRIPT_ARG in docker images #143964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/ci/docker/host-aarch64/aarch64-gnu-llvm-19/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ ENV RUST_CONFIGURE_ARGS \

COPY scripts/shared.sh /scripts/

ARG SCRIPT_ARG
COPY scripts/stage_2_test_set1.sh /scripts/
COPY scripts/stage_2_test_set2.sh /scripts/

COPY scripts/stage_2_test_set1.sh /tmp/
COPY scripts/stage_2_test_set2.sh /tmp/

ENV SCRIPT "/tmp/${SCRIPT_ARG}"
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
4 changes: 1 addition & 3 deletions src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,10 @@ ENV RUST_CONFIGURE_ARGS \
--set rust.lto=thin \
--set rust.codegen-units=1

ARG SCRIPT_ARG

COPY host-x86_64/dist-x86_64-linux/dist.sh /scripts/
COPY host-x86_64/dist-x86_64-linux/dist-alt.sh /scripts/

ENV SCRIPT /scripts/${SCRIPT_ARG}
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang

Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/i686-gnu-nopt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu --disable-optimize-tests
ARG SCRIPT_ARG
COPY scripts/stage_2_test_set1.sh /scripts/
COPY scripts/stage_2_test_set2.sh /scripts/
ENV SCRIPT ${SCRIPT_ARG}
COPY scripts/i686-gnu-nopt-2.sh /scripts/
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
3 changes: 1 addition & 2 deletions src/ci/docker/host-x86_64/i686-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu
ARG SCRIPT_ARG
COPY scripts/stage_2_test_set1.sh /scripts/
COPY scripts/stage_2_test_set2.sh /scripts/
ENV SCRIPT /scripts/${SCRIPT_ARG}
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
14 changes: 6 additions & 8 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-19/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ ENV RUST_CONFIGURE_ARGS \

COPY scripts/shared.sh /scripts/

ARG SCRIPT_ARG
COPY scripts/x86_64-gnu-llvm.sh /scripts/
COPY scripts/x86_64-gnu-llvm2.sh /scripts/
COPY scripts/x86_64-gnu-llvm3.sh /scripts/
COPY scripts/stage_2_test_set1.sh /scripts/
COPY scripts/stage_2_test_set2.sh /scripts/

COPY scripts/x86_64-gnu-llvm.sh /tmp/
COPY scripts/x86_64-gnu-llvm2.sh /tmp/
COPY scripts/x86_64-gnu-llvm3.sh /tmp/
COPY scripts/stage_2_test_set1.sh /tmp/
COPY scripts/stage_2_test_set2.sh /tmp/

ENV SCRIPT "/tmp/${SCRIPT_ARG}"
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
14 changes: 6 additions & 8 deletions src/ci/docker/host-x86_64/x86_64-gnu-llvm-20/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ ENV RUST_CONFIGURE_ARGS \

COPY scripts/shared.sh /scripts/

ARG SCRIPT_ARG
COPY scripts/x86_64-gnu-llvm.sh /scripts/
COPY scripts/x86_64-gnu-llvm2.sh /scripts/
COPY scripts/x86_64-gnu-llvm3.sh /scripts/
COPY scripts/stage_2_test_set1.sh /scripts/
COPY scripts/stage_2_test_set2.sh /scripts/

COPY scripts/x86_64-gnu-llvm.sh /tmp/
COPY scripts/x86_64-gnu-llvm2.sh /tmp/
COPY scripts/x86_64-gnu-llvm3.sh /tmp/
COPY scripts/stage_2_test_set1.sh /tmp/
COPY scripts/stage_2_test_set2.sh /tmp/

ENV SCRIPT "/tmp/${SCRIPT_ARG}"
ENV SCRIPT "Must specify DOCKER_SCRIPT for this image"
12 changes: 4 additions & 8 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
"$context"
)

# If the environment variable DOCKER_SCRIPT is defined,
# set the build argument SCRIPT_ARG to DOCKER_SCRIPT.
# In this way, we run the script defined in CI,
# instead of the one defined in the Dockerfile.
if [ -n "${DOCKER_SCRIPT+x}" ]; then
build_args+=("--build-arg" "SCRIPT_ARG=${DOCKER_SCRIPT}")
fi

GHCR_BUILDKIT_IMAGE="ghcr.io/rust-lang/buildkit:buildx-stable-1"
# On non-CI jobs, we try to download a pre-built image from the rust-lang-ci
# ghcr.io registry. If it is not possible, we fall back to building the image
Expand Down Expand Up @@ -341,6 +333,10 @@ if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
echo "Setting extra environment values for docker: $extra_env"
fi

if [ -n "${DOCKER_SCRIPT}" ]; then
extra_env="$extra_env --env SCRIPT=\"/scripts/${DOCKER_SCRIPT}\""
fi

docker \
run \
--workdir /checkout/obj \
Expand Down
6 changes: 6 additions & 0 deletions src/ci/docker/scripts/i686-gnu-nopt-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -ex

python3 ../x.py test --stage 1 --set rust.optimize=false library/std &&
/scripts/stage_2_test_set2.sh
2 changes: 1 addition & 1 deletion src/ci/docker/scripts/x86_64-gnu-llvm2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex

##### Test stage 2 #####

/tmp/stage_2_test_set1.sh
/scripts/stage_2_test_set1.sh

# Run the `mir-opt` tests again but this time for a 32-bit target.
# This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have
Expand Down
6 changes: 2 additions & 4 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,14 @@ auto:
- name: i686-gnu-nopt-1
env:
IMAGE: i686-gnu-nopt
DOCKER_SCRIPT: /scripts/stage_2_test_set1.sh
DOCKER_SCRIPT: stage_2_test_set1.sh
<<: *job-linux-4c

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

- name: pr-check-1
Expand Down
Loading