Skip to content

Commit 9ec5616

Browse files
committed
Auto merge of #122709 - onur-ozkan:use-precompiled-rustc-by-default, r=<try>
prefer precompiled rustc for x86_64-gnu *-to be filled-* blocker for #119899 r? ghost
2 parents ca7d34e + 7099a13 commit 9ec5616

File tree

8 files changed

+54
-5
lines changed

8 files changed

+54
-5
lines changed

.github/workflows/ci.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ jobs:
5858
- name: mingw-check-tidy
5959
os: ubuntu-20.04-4core-16gb
6060
env: {}
61-
- name: x86_64-gnu-llvm-17
61+
- name: x86_64-gnu
6262
env:
6363
ENABLE_GCC_CODEGEN: "1"
64+
DOWNLOAD_RUSTC: "1"
6465
os: ubuntu-20.04-16core-64gb
6566
- name: x86_64-gnu-tools
6667
os: ubuntu-20.04-16core-64gb
@@ -294,8 +295,9 @@ jobs:
294295
os: ubuntu-20.04-8core-32gb
295296
env: {}
296297
- name: x86_64-gnu
298+
env:
299+
DOWNLOAD_RUSTC: "1"
297300
os: ubuntu-20.04-4core-16gb
298-
env: {}
299301
- name: x86_64-gnu-stable
300302
env:
301303
IMAGE: x86_64-gnu

src/bootstrap/src/core/build_steps/test.rs

+10
Original file line numberDiff line numberDiff line change
@@ -3223,6 +3223,11 @@ impl Step for CodegenCranelift {
32233223
return;
32243224
}
32253225

3226+
if builder.download_rustc() {
3227+
builder.info("pre-compiled/downloaded rustc detected. skipping");
3228+
return;
3229+
}
3230+
32263231
if !target_supports_cranelift_backend(run.target) {
32273232
builder.info("target not supported by rustc_codegen_cranelift. skipping");
32283233
return;
@@ -3344,6 +3349,11 @@ impl Step for CodegenGCC {
33443349
return;
33453350
}
33463351

3352+
if builder.download_rustc() {
3353+
builder.info("pre-compiled/downloaded rustc detected. skipping");
3354+
return;
3355+
}
3356+
33473357
let triple = run.target.triple;
33483358
let target_supported =
33493359
if triple.contains("linux") { triple.contains("x86_64") } else { false };

src/bootstrap/src/core/config/config.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::core::config::flags::{Color, Flags, Warnings};
2121
use crate::utils::cache::{Interned, INTERNER};
2222
use crate::utils::channel::{self, GitInfo};
2323
use crate::utils::helpers::{exe, output, t};
24+
use build_helper::ci::CiEnv;
2425
use build_helper::exit;
2526
use build_helper::util::fail;
2627
use semver::Version;
@@ -2418,13 +2419,16 @@ impl Config {
24182419
let compiler = format!("{top_level}/compiler/");
24192420
let library = format!("{top_level}/library/");
24202421

2422+
// If we are running in CI, the current commit will never have artifacts already built.
2423+
let tip_commit = if CiEnv::is_ci() { "HEAD^" } else { "HEAD" };
2424+
24212425
// Look for a version to compare to based on the current commit.
24222426
// Only commits merged by bors will have CI artifacts.
24232427
let merge_base = output(
24242428
self.git()
24252429
.arg("rev-list")
24262430
.arg(format!("--author={}", self.stage0_metadata.config.git_merge_commit_email))
2427-
.args(["-n1", "--first-parent", "HEAD"]),
2431+
.args(["-n1", "--first-parent", tip_commit]),
24282432
);
24292433
let commit = merge_base.trim_end();
24302434
if commit.is_empty() {

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

+15
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
pkg-config \
1818
xz-utils \
1919
mingw-w64 \
20+
# libgccjit dependencies
21+
flex \
22+
libmpfr-dev \
23+
libgmp-dev \
24+
libmpc3 \
25+
libmpc-dev \
2026
&& rm -rf /var/lib/apt/lists/*
2127

2228
COPY scripts/sccache.sh /scripts/
2329
RUN sh /scripts/sccache.sh
2430

31+
# Fix rustc_codegen_gcc lto issues.
32+
ENV GCC_EXEC_PREFIX="/usr/lib/gcc/"
33+
2534
ENV RUST_CONFIGURE_ARGS \
2635
--build=x86_64-unknown-linux-gnu \
2736
--enable-sanitizers \
2837
--enable-profiler \
2938
--enable-compiler-docs
39+
40+
COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
41+
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/
42+
43+
RUN /scripts/build-gccjit.sh /scripts
44+
3045
ENV SCRIPT python3 ../x.py --stage 2 test

src/ci/docker/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
310310
echo "Setting extra environment values for docker: $extra_env"
311311
fi
312312

313+
if [ "$DOWNLOAD_RUSTC" = "1" ]; then
314+
extra_env="$extra_env --env DOWNLOAD_RUSTC=1"
315+
echo "Setting extra environment values for docker: $extra_env"
316+
fi
317+
313318
docker \
314319
run \
315320
--workdir /checkout/obj \

src/ci/github-actions/ci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ jobs:
357357
- name: mingw-check-tidy
358358
<<: *job-linux-4c
359359

360-
- name: x86_64-gnu-llvm-17
360+
- name: x86_64-gnu
361361
env:
362362
ENABLE_GCC_CODEGEN: "1"
363+
DOWNLOAD_RUSTC: "1"
363364
<<: *job-linux-16c
364365

365366
- name: x86_64-gnu-tools
@@ -476,6 +477,8 @@ jobs:
476477
<<: *job-linux-8c
477478

478479
- name: x86_64-gnu
480+
env:
481+
DOWNLOAD_RUSTC: "1"
479482
<<: *job-linux-4c
480483

481484
# This job ensures commits landing on nightly still pass the full

src/ci/run.sh

+9
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export RUST_RELEASE_CHANNEL=$(releaseChannel)
105105
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
106106

107107
if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
108+
if [ "$DOWNLOAD_RUSTC" = 1 ]; then
109+
echo "ERROR: "DOWNLOAD_RUSTC" should not be set in dist builders!" >&2
110+
exit 1
111+
fi
112+
108113
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
109114
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
110115
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
@@ -139,6 +144,10 @@ else
139144
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
140145
fi
141146

147+
if [ "$DOWNLOAD_RUSTC" = 1 ]; then
148+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.download-rustc=if-unchanged"
149+
fi
150+
142151
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
143152

144153
# When running gcc backend tests, we need to install `libgccjit` and to not run llvm codegen

src/tools/opt-dist/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ enum EnvironmentCmd {
9898
}
9999

100100
fn is_try_build() -> bool {
101-
std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0"
101+
// std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0";
102+
false
102103
}
103104

104105
fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)> {

0 commit comments

Comments
 (0)