Skip to content

Commit 6c7f301

Browse files
Enable downloading prebuilt LLVM in test builders
See comment added for details on the test builder restriction. This is primarily intended for macOS CI, but is likely to be a slight win on other builders too.
1 parent 8ca14aa commit 6c7f301

File tree

16 files changed

+88
-4
lines changed

16 files changed

+88
-4
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -391,24 +391,28 @@ jobs:
391391
env:
392392
RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu --set llvm.allow-old-toolchain"
393393
SCRIPT: make ci-mingw-subset-1
394+
NO_DOWNLOAD_CI_LLVM: 1
394395
CUSTOM_MINGW: 1
395396
os: windows-latest-xl
396397
- name: i686-mingw-2
397398
env:
398399
RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu --set llvm.allow-old-toolchain"
399400
SCRIPT: make ci-mingw-subset-2
401+
NO_DOWNLOAD_CI_LLVM: 1
400402
CUSTOM_MINGW: 1
401403
os: windows-latest-xl
402404
- name: x86_64-mingw-1
403405
env:
404406
SCRIPT: make ci-mingw-subset-1
405407
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler --set llvm.allow-old-toolchain"
408+
NO_DOWNLOAD_CI_LLVM: 1
406409
CUSTOM_MINGW: 1
407410
os: windows-latest-xl
408411
- name: x86_64-mingw-2
409412
env:
410413
SCRIPT: make ci-mingw-subset-2
411414
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler --set llvm.allow-old-toolchain"
415+
NO_DOWNLOAD_CI_LLVM: 1
412416
CUSTOM_MINGW: 1
413417
os: windows-latest-xl
414418
- name: dist-x86_64-msvc
@@ -433,6 +437,7 @@ jobs:
433437
- name: dist-i686-mingw
434438
env:
435439
RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu --enable-full-tools --enable-profiler --set llvm.allow-old-toolchain"
440+
NO_DOWNLOAD_CI_LLVM: 1
436441
SCRIPT: python x.py dist
437442
CUSTOM_MINGW: 1
438443
DIST_REQUIRE_ALL_TOOLS: 1
@@ -441,6 +446,7 @@ jobs:
441446
env:
442447
SCRIPT: python x.py dist
443448
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler --set llvm.allow-old-toolchain"
449+
NO_DOWNLOAD_CI_LLVM: 1
444450
CUSTOM_MINGW: 1
445451
DIST_REQUIRE_ALL_TOOLS: 1
446452
os: windows-latest-xl

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ impl Config {
990990
config.llvm_from_ci = match llvm.download_ci_llvm {
991991
Some(StringOrBool::String(s)) => {
992992
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
993-
crate::native::is_ci_llvm_available(&config)
993+
crate::native::is_ci_llvm_available(&config, llvm_assertions.unwrap_or(false))
994994
}
995995
Some(StringOrBool::Bool(b)) => b,
996996
None => false,

src/bootstrap/native.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub(crate) fn detect_llvm_sha(config: &crate::config::Config) -> String {
148148
/// This checks both the build triple platform to confirm we're usable at all,
149149
/// and then verifies if the current HEAD matches the detected LLVM SHA head,
150150
/// in which case LLVM is indicated as not available.
151-
pub(crate) fn is_ci_llvm_available(config: &crate::config::Config) -> bool {
151+
pub(crate) fn is_ci_llvm_available(config: &crate::config::Config, asserts: bool) -> bool {
152152
// This is currently all tier 1 targets and tier 2 targets with host tools
153153
// (since others may not have CI artifacts)
154154
// https://doc.rust-lang.org/rustc/platform-support.html#tier-1
@@ -187,6 +187,12 @@ pub(crate) fn is_ci_llvm_available(config: &crate::config::Config) -> bool {
187187
return false;
188188
}
189189

190+
let triple = &*config.build.triple;
191+
if (triple == "aarch64-unknown-linux-gnu" || triple.contains("i686")) && asserts {
192+
// No alt builder for aarch64-unknown-linux-gnu today.
193+
return false;
194+
}
195+
190196
if crate::util::CiEnv::is_ci() {
191197
let llvm_sha = detect_llvm_sha(config);
192198
let head_sha = output(config.git().arg("rev-parse").arg("HEAD"));

src/ci/docker/host-x86_64/arm-android/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ ENV PATH=$PATH:/android/sdk/platform-tools
2929

3030
ENV TARGETS=arm-linux-androideabi
3131

32+
# We are intentionally allowing an old toolchain on this builder (and that's
33+
# incompatible with LLVM downloads today).
34+
ENV NO_DOWNLOAD_CI_LLVM 1
35+
3236
ENV RUST_CONFIGURE_ARGS --arm-linux-androideabi-ndk=/android/ndk/arm-14 \
3337
--set llvm.allow-old-toolchain
3438

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

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ RUN mkdir -p /config
2727
RUN echo "[rust]" > /config/nopt-std-config.toml
2828
RUN echo "optimize = false" >> /config/nopt-std-config.toml
2929

30+
# We are intentionally allowing an old toolchain on this builder (and that's
31+
# incompatible with LLVM downloads today).
32+
ENV NO_DOWNLOAD_CI_LLVM 1
33+
3034
ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu --disable-optimize-tests \
3135
--set llvm.allow-old-toolchain
3236
ENV SCRIPT python3 ../x.py test --stage 0 --config /config/nopt-std-config.toml library/std \

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

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ RUN sh /scripts/sccache.sh
2323
COPY scripts/cmake.sh /scripts/
2424
RUN /scripts/cmake.sh
2525

26+
# We are intentionally allowing an old toolchain on this builder (and that's
27+
# incompatible with LLVM downloads today).
28+
ENV NO_DOWNLOAD_CI_LLVM 1
2629
ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu \
2730
--set llvm.allow-old-toolchain
2831
# Exclude some tests that are unlikely to be platform specific, to speed up

src/ci/docker/host-x86_64/test-various/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ WORKDIR /
3030
COPY scripts/sccache.sh /scripts/
3131
RUN sh /scripts/sccache.sh
3232

33+
# We are disabling CI LLVM since this builder needs to build LLD, which is
34+
# currently unsupported when downloading pre-built LLVM.
35+
ENV NO_DOWNLOAD_CI_LLVM 1
36+
3337
ENV RUST_CONFIGURE_ARGS \
3438
--musl-root-x86_64=/usr/local/x86_64-linux-musl \
3539
--set build.nodejs=/node-v15.14.0-linux-x64/bin/node \

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

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ RUN sh /scripts/sccache.sh
2626
COPY scripts/cmake.sh /scripts/
2727
RUN /scripts/cmake.sh
2828

29+
# We are intentionally allowing an old toolchain on this builder (and that's
30+
# incompatible with LLVM downloads today).
31+
ENV NO_DOWNLOAD_CI_LLVM 1
32+
2933
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu \
3034
--set llvm.allow-old-toolchain
3135
ENV RUST_CHECK_TARGET check-aux

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

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ RUN sh /scripts/sccache.sh
3131
ENV RUSTBUILD_FORCE_CLANG_BASED_TESTS 1
3232
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
3333

34+
# llvm.use-linker conflicts with downloading CI LLVM
35+
ENV NO_DOWNLOAD_CI_LLVM 1
36+
3437
ENV RUST_CONFIGURE_ARGS \
3538
--build=x86_64-unknown-linux-gnu \
3639
--enable-debug \

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ RUN sh /scripts/sccache.sh
2222
COPY scripts/cmake.sh /scripts/
2323
RUN /scripts/cmake.sh
2424

25+
# We are intentionally allowing an old toolchain on this builder (and that's
26+
# incompatible with LLVM downloads today).
27+
ENV NO_DOWNLOAD_CI_LLVM 1
28+
2529
ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --set rust.ignore-git=false \
2630
--set llvm.allow-old-toolchain
2731
ENV SCRIPT python3 ../x.py --stage 2 test distcheck

src/ci/docker/host-x86_64/x86_64-gnu-llvm-13-stage1/Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2626
COPY scripts/sccache.sh /scripts/
2727
RUN sh /scripts/sccache.sh
2828

29-
# using llvm-link-shared due to libffi issues -- see #34486
29+
# We are disabling CI LLVM since this builder is intentionally using a host
30+
# LLVM, rather than the typical src/llvm-project LLVM.
31+
ENV NO_DOWNLOAD_CI_LLVM 1
32+
33+
# Using llvm-link-shared due to libffi issues -- see #34486
3034
ENV RUST_CONFIGURE_ARGS \
3135
--build=x86_64-unknown-linux-gnu \
3236
--llvm-root=/usr/lib/llvm-13 \

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ RUN apt-get update && \
3737
COPY scripts/sccache.sh /scripts/
3838
RUN sh /scripts/sccache.sh
3939

40-
# using llvm-link-shared due to libffi issues -- see #34486
40+
# We are disabling CI LLVM since this builder is intentionally using a host
41+
# LLVM, rather than the typical src/llvm-project LLVM.
42+
ENV NO_DOWNLOAD_CI_LLVM 1
43+
44+
# Using llvm-link-shared due to libffi issues -- see #34486
4145
ENV RUST_CONFIGURE_ARGS \
4246
--build=x86_64-unknown-linux-gnu \
4347
--llvm-root=/usr/lib/llvm-13 \

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

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ COPY host-x86_64/x86_64-gnu-tools/browser-ui-test.version /tmp/
8080
# the local version of the package is different than the one used by the CI.
8181
RUN npm install -g browser-ui-test@$(head -n 1 /tmp/browser-ui-test.version) --unsafe-perm=true
8282

83+
# We are intentionally allowing an old toolchain on this builder (and that's
84+
# incompatible with LLVM downloads today).
85+
ENV NO_DOWNLOAD_CI_LLVM 1
86+
8387
ENV RUST_CONFIGURE_ARGS \
8488
--set llvm.allow-old-toolchain \
8589
--build=x86_64-unknown-linux-gnu \

src/ci/github-actions/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ jobs:
600600
--build=i686-pc-windows-gnu
601601
--set llvm.allow-old-toolchain
602602
SCRIPT: make ci-mingw-subset-1
603+
# We are intentionally allowing an old toolchain on this builder (and that's
604+
# incompatible with LLVM downloads today).
605+
NO_DOWNLOAD_CI_LLVM: 1
603606
CUSTOM_MINGW: 1
604607
<<: *job-windows-xl
605608

@@ -609,6 +612,9 @@ jobs:
609612
--build=i686-pc-windows-gnu
610613
--set llvm.allow-old-toolchain
611614
SCRIPT: make ci-mingw-subset-2
615+
# We are intentionally allowing an old toolchain on this builder (and that's
616+
# incompatible with LLVM downloads today).
617+
NO_DOWNLOAD_CI_LLVM: 1
612618
CUSTOM_MINGW: 1
613619
<<: *job-windows-xl
614620

@@ -619,6 +625,9 @@ jobs:
619625
--build=x86_64-pc-windows-gnu
620626
--enable-profiler
621627
--set llvm.allow-old-toolchain
628+
# We are intentionally allowing an old toolchain on this builder (and that's
629+
# incompatible with LLVM downloads today).
630+
NO_DOWNLOAD_CI_LLVM: 1
622631
CUSTOM_MINGW: 1
623632
<<: *job-windows-xl
624633

@@ -629,6 +638,9 @@ jobs:
629638
--build=x86_64-pc-windows-gnu
630639
--enable-profiler
631640
--set llvm.allow-old-toolchain
641+
# We are intentionally allowing an old toolchain on this builder (and that's
642+
# incompatible with LLVM downloads today).
643+
NO_DOWNLOAD_CI_LLVM: 1
632644
CUSTOM_MINGW: 1
633645
<<: *job-windows-xl
634646

@@ -678,6 +690,9 @@ jobs:
678690
--enable-full-tools
679691
--enable-profiler
680692
--set llvm.allow-old-toolchain
693+
# We are intentionally allowing an old toolchain on this builder (and that's
694+
# incompatible with LLVM downloads today).
695+
NO_DOWNLOAD_CI_LLVM: 1
681696
SCRIPT: python x.py dist
682697
CUSTOM_MINGW: 1
683698
DIST_REQUIRE_ALL_TOOLS: 1
@@ -691,6 +706,9 @@ jobs:
691706
--enable-full-tools
692707
--enable-profiler
693708
--set llvm.allow-old-toolchain
709+
# We are intentionally allowing an old toolchain on this builder (and that's
710+
# incompatible with LLVM downloads today).
711+
NO_DOWNLOAD_CI_LLVM: 1
694712
CUSTOM_MINGW: 1
695713
DIST_REQUIRE_ALL_TOOLS: 1
696714
<<: *job-windows-xl

src/ci/run.sh

+12
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ else
102102
fi
103103

104104
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
105+
106+
# We enable this for non-dist builders, since those aren't trying to produce
107+
# fresh binaries. We currently don't entirely support distributing a fresh
108+
# copy of the compiler (including llvm tools, etc.) if we haven't actually
109+
# built LLVM, since not everything necessary is copied into the
110+
# local-usage-only LLVM artifacts. If that changes, this could maybe be made
111+
# true for all builds. In practice it's probably a good idea to keep building
112+
# LLVM continuously on at least some builders to ensure it works, though.
113+
# (And PGO is its own can of worms).
114+
if [ "$NO_DOWNLOAD_CI_LLVM" = "" ]; then
115+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.download-ci-llvm=if-available"
116+
fi
105117
fi
106118

107119
if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then

src/ci/scripts/install-clang.sh

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then
6161
7z x -oclang-rust/ "LLVM-${LLVM_VERSION}-win64.exe"
6262
ciCommandSetEnv RUST_CONFIGURE_ARGS \
6363
"${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe"
64+
65+
# Disable downloading CI LLVM on this builder;
66+
# setting up clang-cl just above conflicts with the default if-available option.
67+
ciCommandSetEnv NO_DOWNLOAD_CI_LLVM 1
6468
fi
6569

6670
if isWindows; then

0 commit comments

Comments
 (0)