-
Notifications
You must be signed in to change notification settings - Fork 13.5k
clippy: make tests work in stage 1 #144027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,31 @@ impl TestContext { | |
defaults.set_custom( | ||
"dependencies", | ||
DependencyBuilder { | ||
program: CommandBuilder::cargo(), | ||
program: { | ||
let mut p = CommandBuilder::cargo(); | ||
// If we run in bootstrap, we need to use the right compiler for building the | ||
// tests -- not the compiler that built clippy, but the compiler that got linked | ||
// into clippy. Just invoking TEST_RUSTC does not work because LD_LIBRARY_PATH | ||
// is set in a way that makes it pick the wrong sysroot. Sadly due to | ||
// <https://github.com/rust-lang/cargo/issues/4423> we cannot use RUSTFLAGS to | ||
// set `--sysroot`, so we need to use bootstrap's rustc wrapper. That wrapper | ||
// however has some staging logic that is hurting us here, so to work around | ||
// that we set both the "real" and "staging" rustc to TEST_RUSTC, including the | ||
// associated library paths. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be possible to use a different approach here... somehow, aux builds are working for clippy tests. It seems to be using clippy itself as the compiler for that, and that's somehow okay? So, we could try to do the same here, instead of all this TEST_RUSTC stuff. (That would also be closer to what Miri does.) But TBH I found something that works so I am not overly inclined to debug a different approach. ;) |
||
if let Some(rustc) = option_env!("TEST_RUSTC") { | ||
let libdir = option_env!("TEST_RUSTC_LIB").unwrap(); | ||
let sysroot = option_env!("TEST_SYSROOT").unwrap(); | ||
p.envs.push(("RUSTC_REAL".into(), Some(rustc.into()))); | ||
p.envs.push(("RUSTC_REAL_LIBDIR".into(), Some(libdir.into()))); | ||
p.envs.push(("RUSTC_SNAPSHOT".into(), Some(rustc.into()))); | ||
p.envs.push(("RUSTC_SNAPSHOT_LIBDIR".into(), Some(libdir.into()))); | ||
p.envs.push(( | ||
"RUSTC_SYSROOT".into(), | ||
Some(sysroot.into()), | ||
)); | ||
} | ||
p | ||
}, | ||
crate_manifest_path: Path::new("clippy_test_deps").join("Cargo.toml"), | ||
build_std: None, | ||
bless_lockfile: self.args.bless, | ||
|
@@ -192,6 +216,9 @@ impl TestContext { | |
let dep = format!("-Ldependency={}", Path::new(host_libs).join("deps").display()); | ||
config.program.args.push(dep.into()); | ||
} | ||
if let Some(sysroot) = option_env!("TEST_SYSROOT") { | ||
config.program.args.push(format!("--sysroot={sysroot}").into()); | ||
} | ||
|
||
config.program.program = profile_path.join(if cfg!(windows) { | ||
"clippy-driver.exe" | ||
|
Uh oh!
There was an error while loading. Please reload this page.