diff --git a/.github/actions/checkout-rust/action.yml b/.github/actions/checkout-rust/action.yml new file mode 100644 index 00000000000..67140523f20 --- /dev/null +++ b/.github/actions/checkout-rust/action.yml @@ -0,0 +1,31 @@ +name: Check out rust-lang/rust +description: > + Checks out the rust-lang/rust commit of the toolchain into `/build/rust`, where y.sh runs + the rustc tests. Unlike the anonymous full clone y.sh would do, this checkout is authenticated + and shallow, so GitHub does not rate-limit it. + +inputs: + path: + description: The cg_gcc directory. + default: . + +runs: + using: composite + steps: + - id: toolchain + shell: bash + working-directory: ${{ inputs.path }} + run: | + commit="$(rustc -vV | sed -n 's/^commit-hash: //p')" + if [ -z "$commit" ]; then + echo "::error::could not find the commit of the toolchain" + exit 1 + fi + echo "commit=$commit" >> "$GITHUB_OUTPUT" + + - uses: actions/checkout@v7 + with: + repository: rust-lang/rust + ref: ${{ steps.toolchain.outputs.commit }} + path: ${{ inputs.path }}/build/rust + persist-credentials: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66362e27ce4..fc45d1a60f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,6 +173,10 @@ jobs: if: ${{ matrix.libgccjit_version.gcc == 'gcc-15-without-int128' }} run: cat tests/failing-ui-tests-without-128bit-integers.txt >> tests/failing-ui-tests.txt + - name: Check out rust-lang/rust + if: ${{ contains(matrix.commands, '-rustc') }} + uses: ./.github/actions/checkout-rust + - name: Run tests run: | ./y.sh test --release --clean --build-sysroot --no-builtins-tests ${{ matrix.commands }} diff --git a/.github/workflows/failures.yml b/.github/workflows/failures.yml index cd218ee0b2e..23411645931 100644 --- a/.github/workflows/failures.yml +++ b/.github/workflows/failures.yml @@ -100,6 +100,10 @@ jobs: if: matrix.libgccjit_version.gcc != 'libgccjit12.so' run: ./y.sh prepare + - name: Check out rust-lang/rust + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + uses: ./.github/actions/checkout-rust + - name: Run tests # FIXME: re-enable those tests for libgccjit 12. if: matrix.libgccjit_version.gcc != 'libgccjit12.so' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43885125278..cc91ea2b666 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,6 +83,9 @@ jobs: - name: Add more failing tests (some panic and debuginfo tests fail) run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt + - name: Check out rust-lang/rust + uses: ./.github/actions/checkout-rust + - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. diff --git a/.github/workflows/rustup.yml b/.github/workflows/rustup.yml index 0309ccbad54..13fb592fc2b 100644 --- a/.github/workflows/rustup.yml +++ b/.github/workflows/rustup.yml @@ -111,6 +111,12 @@ jobs: git config --global user.name "User" ./y.sh prepare + - name: Check out rust-lang/rust + if: ${{ contains(matrix.commands, '-rustc') }} + uses: ./.github/actions/checkout-rust + with: + path: rust/compiler/rustc_codegen_gcc + - name: Run tests run: | ./y.sh test --release --clean --build-sysroot --no-builtins-tests ${{ matrix.commands }} @@ -252,6 +258,11 @@ jobs: git config --global user.name "User" ./y.sh prepare + - name: Check out rust-lang/rust + uses: ./.github/actions/checkout-rust + with: + path: rust/compiler/rustc_codegen_gcc + - name: Run tests run: | # Without this, `tee` masks the exit status of `y.sh test`. diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 79eae8afa14..2880108825b 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -559,18 +559,33 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result { let _ = git_clone("https://github.com/rust-lang/rust.git", Some(&rust_dir_path), false); let rust_dir: Option<&Path> = Some(&rust_dir_path); run_command(&[&"git", &"checkout", &"--", &"tests/"], rust_dir)?; - run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?; let rustc_commit = match rustc_version_info(env.get("RUSTC").map(|s| s.as_str()))?.commit_hash { Some(commit_hash) => commit_hash, None => return Err("Couldn't retrieve rustc commit hash".to_string()), }; if rustc_commit != "unknown" { + // GitHub rate-limits a fetch right after a full clone, so only fetch a missing commit. + let commit_object = format!("{rustc_commit}^{{commit}}"); + let has_commit = run_command_with_output_and_env_no_err( + &[&"git", &"rev-parse", &"--quiet", &"--verify", &commit_object], + rust_dir, + Some(env), + ) + .is_ok(); + if !has_commit { + run_command_with_output_and_env( + &[&"git", &"fetch", &"origin", &rustc_commit], + rust_dir, + Some(env), + )?; + } run_command_with_output_and_env( &[&"git", &"checkout", &rustc_commit], rust_dir, Some(env), )?; } else { + run_command_with_output_and_env(&[&"git", &"fetch"], rust_dir, Some(env))?; run_command_with_output_and_env(&[&"git", &"checkout"], rust_dir, Some(env))?; } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5750754596b..16d6ab86704 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2026-10-24" +channel = "nightly-2026-10-26" components = ["rust-src", "rustc-dev", "llvm-tools-preview"]