Skip to content

Commit

Permalink
Auto merge of #122709 - onur-ozkan:use-precompiled-rustc-by-default, …
Browse files Browse the repository at this point in the history
…r=<try>

prefer precompiled rustc for x86_64-gnu

*-to be filled-*

blocker for #119899
r? ghost
  • Loading branch information
bors committed Apr 4, 2024
2 parents 0fd5712 + 731c8eb commit 3a8cf09
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ jobs:
- name: mingw-check-tidy
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-llvm-17
- name: x86_64-gnu
env:
ENABLE_GCC_CODEGEN: "1"
DOWNLOAD_RUSTC: "1"
os: ubuntu-20.04-16core-64gb
- name: x86_64-gnu-tools
os: ubuntu-20.04-16core-64gb
Expand Down Expand Up @@ -294,8 +295,9 @@ jobs:
os: ubuntu-20.04-8core-32gb
env: {}
- name: x86_64-gnu
env:
DOWNLOAD_RUSTC: "1"
os: ubuntu-20.04-4core-16gb
env: {}
- name: x86_64-gnu-stable
env:
IMAGE: x86_64-gnu
Expand Down Expand Up @@ -593,6 +595,7 @@ jobs:
name: "try - ${{ matrix.name }}"
env:
DIST_TRY_BUILD: 1
DOWNLOAD_RUSTC: 1
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,11 @@ impl Step for CodegenCranelift {
return;
}

if builder.download_rustc() {
builder.info("pre-compiled/downloaded rustc detected. skipping");
return;
}

if !target_supports_cranelift_backend(run.target) {
builder.info("target not supported by rustc_codegen_cranelift. skipping");
return;
Expand Down Expand Up @@ -3344,6 +3349,11 @@ impl Step for CodegenGCC {
return;
}

if builder.download_rustc() {
builder.info("pre-compiled/downloaded rustc detected. skipping");
return;
}

let triple = run.target.triple;
let target_supported =
if triple.contains("linux") { triple.contains("x86_64") } else { false };
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::core::config::flags::{Color, Flags, Warnings};
use crate::utils::cache::{Interned, INTERNER};
use crate::utils::channel::{self, GitInfo};
use crate::utils::helpers::{exe, output, t};
use build_helper::ci::CiEnv;
use build_helper::exit;
use build_helper::util::fail;
use semver::Version;
Expand Down Expand Up @@ -2418,13 +2419,16 @@ impl Config {
let compiler = format!("{top_level}/compiler/");
let library = format!("{top_level}/library/");

// If we are running in CI, the current commit will never have artifacts already built.
let tip_commit = if CiEnv::is_ci() { "HEAD^" } else { "HEAD" };

// Look for a version to compare to based on the current commit.
// Only commits merged by bors will have CI artifacts.
let merge_base = output(
self.git()
.arg("rev-list")
.arg(format!("--author={}", self.stage0_metadata.config.git_merge_commit_email))
.args(["-n1", "--first-parent", "HEAD"]),
.args(["-n1", "--first-parent", tip_commit]),
);
let commit = merge_base.trim_end();
if commit.is_empty() {
Expand Down
15 changes: 15 additions & 0 deletions src/ci/docker/host-x86_64/x86_64-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
xz-utils \
mingw-w64 \
# libgccjit dependencies
flex \
libmpfr-dev \
libgmp-dev \
libmpc3 \
libmpc-dev \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

# Fix rustc_codegen_gcc lto issues.
ENV GCC_EXEC_PREFIX="/usr/lib/gcc/"

ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--enable-sanitizers \
--enable-profiler \
--enable-compiler-docs

COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/

RUN /scripts/build-gccjit.sh /scripts

ENV SCRIPT python3 ../x.py --stage 2 test
5 changes: 5 additions & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
echo "Setting extra environment values for docker: $extra_env"
fi

if [ "$DOWNLOAD_RUSTC" = "1" ]; then
extra_env="$extra_env --env DOWNLOAD_RUSTC=1"
echo "Setting extra environment values for docker: $extra_env"
fi

docker \
run \
--workdir /checkout/obj \
Expand Down
6 changes: 5 additions & 1 deletion src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ jobs:
- name: mingw-check-tidy
<<: *job-linux-4c

- name: x86_64-gnu-llvm-17
- name: x86_64-gnu
env:
ENABLE_GCC_CODEGEN: "1"
DOWNLOAD_RUSTC: "1"
<<: *job-linux-16c

- name: x86_64-gnu-tools
Expand Down Expand Up @@ -476,6 +477,8 @@ jobs:
<<: *job-linux-8c

- name: x86_64-gnu
env:
DOWNLOAD_RUSTC: "1"
<<: *job-linux-4c

# This job ensures commits landing on nightly still pass the full
Expand Down Expand Up @@ -754,6 +757,7 @@ jobs:
name: try - ${{ matrix.name }}
env:
DIST_TRY_BUILD: 1
DOWNLOAD_RUSTC: 1
<<: [*shared-ci-variables, *prod-variables]
if: github.event_name == 'push' && (((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust') || ((github.ref == 'refs/heads/automation/bors/try') && github.repository == 'rust-lang/rust'))
strategy:
Expand Down
9 changes: 9 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export RUST_RELEASE_CHANNEL=$(releaseChannel)
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"

if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
if [ "$DOWNLOAD_RUSTC" = 1 ]; then
echo "ERROR: "DOWNLOAD_RUSTC" should not be set in dist builders!" >&2
exit 1
fi

RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
Expand Down Expand Up @@ -139,6 +144,10 @@ else
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
fi

if [ "$DOWNLOAD_RUSTC" = 1 ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.download-rustc=if-unchanged"
fi

RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"

# When running gcc backend tests, we need to install `libgccjit` and to not run llvm codegen
Expand Down
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
3 changes: 2 additions & 1 deletion src/tools/opt-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ enum EnvironmentCmd {
}

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

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

0 comments on commit 3a8cf09

Please sign in to comment.