Skip to content
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

Don't pass --sysroot twice if SYSROOT is set #10149

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Jan 3, 2023

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

@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2023

r? @dswij

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 3, 2023
@jyn514
Copy link
Member Author

jyn514 commented Jan 3, 2023

r? @flip1995

@@ -256,11 +256,14 @@ pub fn main() {
LazyLock::force(&ICE_HOOK);
exit(rustc_driver::catch_with_exit_code(move || {
let mut orig_args: Vec<String> = env::args().collect();
let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if we do want to support passing --sysroot to clippy-driver (with -- to cargo-clippy, not rustflags), this will need to be changed to look at clippy_args as well, not just orig_args.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could I send a PR to support passing --sysroot to clippy-driver?

tests/integration.rs Outdated Show resolved Hide resolved
tests/integration.rs Outdated Show resolved Hide resolved
tests/integration.rs Outdated Show resolved Hide resolved
@rust-cloud-vms rust-cloud-vms bot force-pushed the duplicate-sysroot branch 3 times, most recently from c4926f7 to 2e40e36 Compare January 3, 2023 18:37
@flip1995 flip1995 mentioned this pull request Jan 9, 2023
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration test is not the right place for this. The integration test is really just for running Clippy on a repo and check that it doesn't produce an ICE.

IIUC what you want to test is that when running SYSROOT=/path/to/smth RUSTFLAGS=--sysroot=/path/tp/lib cargo clippy will only use the sysroot given by RUSTFLAGS?

I'll try to move this to .github/driver.sh tomorrow before merging.

@jyn514
Copy link
Member Author

jyn514 commented Jan 12, 2023

IIUC what you want to test is that when running SYSROOT=/path/to/smth RUSTFLAGS=--sysroot=/path/tp/lib cargo clippy will only use the sysroot given by RUSTFLAGS?

Yes, exactly.

I'll try to move this to .github/driver.sh tomorrow before merging.

❤️

jyn514 and others added 2 commits January 12, 2023 18:32
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
rust-lang@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.
Whne SYSROOT is defined, clippy-driver will insert a --sysroot argument
when calling rustc. However, when a sysroot argument is already defined,
e.g. through RUSTFLAGS=--sysroot=... the `cargo clippy` call would
error. This tests that the sysroot argument is only passed once and that
SYSROOT is ignored in this case.
@flip1995
Copy link
Member

@bors r+

Thanks for addressing this and sorry for taking so long to review. I'll sync this to rustc right after this PR is merged.

@bors
Copy link
Collaborator

bors commented Jan 12, 2023

📌 Commit fe00717 has been approved by flip1995

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 12, 2023

⌛ Testing commit fe00717 with merge f9ca9d4...

@bors
Copy link
Collaborator

bors commented Jan 12, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing f9ca9d4 to master...

@bors bors merged commit f9ca9d4 into rust-lang:master Jan 12, 2023
@jyn514 jyn514 deleted the duplicate-sysroot branch January 12, 2023 19:11
@jyn514
Copy link
Member Author

jyn514 commented Jan 12, 2023

Thank you! No worries at all, I just wanted to make sure it landed before the beta bump :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants