Skip to content

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

Merged
bors merged 2 commits into
rust-lang:masterfrom
jyn514:duplicate-sysroot
Jan 12, 2023
Merged

Don't pass --sysroot twice if SYSROOT is set#10149
bors merged 2 commits into
rust-lang:masterfrom
jyn514:duplicate-sysroot

Conversation

@jyn514

@jyn514 jyn514 commented Jan 3, 2023

Copy link
Copy Markdown
Member

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

rustbot commented Jan 3, 2023

Copy link
Copy Markdown
Collaborator

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

jyn514 commented Jan 3, 2023

Copy link
Copy Markdown
Member Author

r? @flip1995

@rustbot rustbot assigned flip1995 and unassigned dswij Jan 3, 2023
Comment thread src/driver.rs
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
Copy Markdown
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
Copy Markdown
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?

Comment thread tests/integration.rs Outdated
Comment thread tests/integration.rs Outdated
Comment thread tests/integration.rs Outdated
@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

@flip1995 flip1995 left a comment

Copy link
Copy Markdown
Member

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

jyn514 commented Jan 12, 2023

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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

bors commented Jan 12, 2023

Copy link
Copy Markdown
Contributor

📌 Commit fe00717 has been approved by flip1995

It is now in the queue for this repository.

@bors

bors commented Jan 12, 2023

Copy link
Copy Markdown
Contributor

⌛ Testing commit fe00717 with merge f9ca9d4...

@bors

bors commented Jan 12, 2023

Copy link
Copy Markdown
Contributor

☀️ 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

jyn514 commented Jan 12, 2023

Copy link
Copy Markdown
Member Author

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