Rollup merge of #140357 - onur-ozkan:133840, r=clubby789

bypass linker configuration and cross target check on `x check`

I was going to handle this using the untracked env approach, but I realized it somehow doesn't regress https://github.com/rust-lang/rust/issues/130108 anymore...

Anyway, if it works, it works. 😄 No need to dig deeper but my guess is we moved some cache-invalidating env from these functions to others.

Fixes https://github.com/rust-lang/rust/issues/133840

try-job: aarch64-apple
This commit is contained in:
Guillaume Gomez 2025-05-05 21:32:31 +02:00 committed by GitHub
commit 246acdbb95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View file

@ -112,9 +112,8 @@ impl Cargo {
let mut cargo = builder.cargo(compiler, mode, source_type, target, cmd_kind);
match cmd_kind {
// No need to configure the target linker for these command types,
// as they don't invoke rustc at all.
Kind::Clean | Kind::Suggest | Kind::Format | Kind::Setup => {}
// No need to configure the target linker for these command types.
Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {}
_ => {
cargo.configure_linker(builder);
}
@ -205,6 +204,8 @@ impl Cargo {
self
}
// FIXME(onur-ozkan): Add coverage to make sure modifications to this function
// doesn't cause cache invalidations (e.g., #130108).
fn configure_linker(&mut self, builder: &Builder<'_>) -> &mut Cargo {
let target = self.target;
let compiler = self.compiler;

View file

@ -96,6 +96,7 @@ pub fn find(build: &Build) {
let targets: HashSet<_> = match build.config.cmd {
// We don't need to check cross targets for these commands.
crate::Subcommand::Clean { .. }
| crate::Subcommand::Check { .. }
| crate::Subcommand::Suggest { .. }
| crate::Subcommand::Format { .. }
| crate::Subcommand::Setup { .. } => {

View file

@ -181,7 +181,7 @@ fn test_language_clang() {
#[test]
fn test_new_cc_build() {
let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target = TargetSelection::from_user("x86_64-unknown-linux-gnu");
let cfg = new_cc_build(&build, target.clone());
let compiler = cfg.get_compiler();
@ -190,7 +190,7 @@ fn test_new_cc_build() {
#[test]
fn test_default_compiler_wasi() {
let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target = TargetSelection::from_user("wasm32-wasi");
let wasi_sdk = PathBuf::from("/wasi-sdk");
// SAFETY: bootstrap tests run on a single thread
@ -215,7 +215,7 @@ fn test_default_compiler_wasi() {
#[test]
fn test_default_compiler_fallback() {
let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target = TargetSelection::from_user("x86_64-unknown-linux-gnu");
let mut cfg = cc::Build::new();
let result = default_compiler(&mut cfg, Language::C, target, &build);
@ -224,7 +224,7 @@ fn test_default_compiler_fallback() {
#[test]
fn test_find_target_with_config() {
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target = TargetSelection::from_user("x86_64-unknown-linux-gnu");
let mut target_config = Target::default();
target_config.cc = Some(PathBuf::from("dummy-cc"));
@ -249,7 +249,7 @@ fn test_find_target_with_config() {
#[test]
fn test_find_target_without_config() {
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target = TargetSelection::from_user("x86_64-unknown-linux-gnu");
build.config.target_config.clear();
find_target(&build, target.clone());
@ -262,7 +262,7 @@ fn test_find_target_without_config() {
#[test]
fn test_find() {
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) });
let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) });
let target1 = TargetSelection::from_user("x86_64-unknown-linux-gnu");
let target2 = TargetSelection::from_user("x86_64-unknown-openbsd");
build.targets.push(target1.clone());