Skip to content

Commit f9ca9d4

Browse files
committed
Auto merge of #10149 - jyn514:duplicate-sysroot, r=flip1995
Don't pass `--sysroot` twice if SYSROOT is set This is useful for rust-lang/rust to allow setting a sysroot that's *only* for build scripts, different from the regular sysroot passed in RUSTFLAGS (since cargo doesn't apply RUSTFLAGS to build scripts or proc-macros). That said, the exact motivation is not particularly important: this fixes a regression from 5907e91#r1060215684. Note that only RUSTFLAGS is tested in the new integration test; passing --sysroot through `clippy-driver` never worked as far as I can tell, and no one is using it, so I didn't fix it here. Helps with rust-lang/rust#106394. --- changelog: other: `SYSROOT` and `--sysroot` can now be set at the same time [#10149](#10149) <!-- changelog_checked -->
2 parents decaba9 + fe00717 commit f9ca9d4

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.github/driver.sh

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ test "$sysroot" = $desired_sysroot
1717
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
1818
test "$sysroot" = $desired_sysroot
1919

20+
# Check that the --sysroot argument is only passed once (SYSROOT is ignored)
21+
(
22+
cd rustc_tools_util
23+
touch src/lib.rs
24+
SYSROOT=/tmp RUSTFLAGS="--sysroot=$(rustc --print sysroot)" ../target/debug/cargo-clippy clippy --verbose
25+
)
26+
2027
# Make sure this isn't set - clippy-driver should cope without it
2128
unset CARGO_MANIFEST_DIR
2229

src/driver.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,14 @@ pub fn main() {
256256
LazyLock::force(&ICE_HOOK);
257257
exit(rustc_driver::catch_with_exit_code(move || {
258258
let mut orig_args: Vec<String> = env::args().collect();
259+
let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some();
259260

260261
let sys_root_env = std::env::var("SYSROOT").ok();
261262
let pass_sysroot_env_if_given = |args: &mut Vec<String>, sys_root_env| {
262263
if let Some(sys_root) = sys_root_env {
263-
args.extend(vec!["--sysroot".into(), sys_root]);
264+
if !has_sysroot_arg {
265+
args.extend(vec!["--sysroot".into(), sys_root]);
266+
}
264267
};
265268
};
266269

tests/integration.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//! This test is meant to only be run in CI. To run it locally use:
2+
//!
3+
//! `env INTEGRATION=rust-lang/log cargo test --test integration --features=integration`
4+
//!
5+
//! You can use a different `INTEGRATION` value to test different repositories.
6+
//!
7+
//! This test will clone the specified repository and run Clippy on it. The test succeeds, if
8+
//! Clippy doesn't produce an ICE. Lint warnings are ignored by this test.
9+
110
#![cfg(feature = "integration")]
211
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
312
#![warn(rust_2018_idioms, unused_lifetimes)]

0 commit comments

Comments
 (0)