-
Notifications
You must be signed in to change notification settings - Fork 14.1k
linker: Remove special case for rust-lld in detect_self_contained_mingw
#149590
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
Conversation
…mingw` `rust-lld` is supposed to live in sysroot, so it doesn't change the behavior of the function, only removes a potential micro-optimization.
|
Shouldn't hurt. @bors r+ |
|
@bors rollup |
| // Assume `-C linker=rust-lld` as self-contained mode | ||
| if linker == Path::new("rust-lld") { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below only the sysroot from which we get the standard library is checked, not the fallback sysroot that rustc itself is contained in. rust-lld is likely to be contained only in the latter if the former is overriden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly sure from my tests the sysroot would point at ~/.rustup/toolchains/<toolchain>.
If I read
rust/compiler/rustc_session/src/filesearch.rs
Line 190 in 8202d11
| fn default_from_rustc_driver_dll() -> Result<PathBuf, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code below only strips sess.opts.sysroot.path(), which only returns the value explicitly passed to --sysroot if passed, only returning the fallback sysroot when it isn't passed.
rust/compiler/rustc_session/src/config.rs
Lines 1345 to 1348 in 8202d11
| /// Return explicit sysroot if it was passed with `--sysroot`, or default sysroot otherwise. | |
| pub fn path(&self) -> &Path { | |
| self.explicit.as_deref().unwrap_or(&self.default) | |
| } |
sess.opts.sysroot.all_paths() to check both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but is --sysroot ever passed to rustc when building natively (host == target)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are legitimate reasons to pass it when building natively. For example miri does for it's copy of the standard library that contains MIR for all functions (though it doesn't need a linker). cargo build -Zbuild-std doesn't use --sysroot currently, but I think it should pass --sysroot /dev/null or something like that to prevent accidentally picking up libraries from the sysroot. The only thing that leads to is lang item conflicts. --sysroot /dev/null would give nicer error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--sysroot /dev/null would break all cases of implicit self-contained detection, not just rust-lld. I mean, there is no obvious issue caused by this PR, not that there is no general issue with implicit self-contained detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. The self-contained components are themself only looked up in --sysroot. Didn't think of that.
Rollup of 5 pull requests Successful merges: - #148918 (Remove an outdated test) - #149244 (Fix std::mem::drop rustdoc misleading statement) - #149532 (Rename supertrait item shadowing lints) - #149541 (Various never type test improvements) - #149590 (linker: Remove special case for `rust-lld` in `detect_self_contained_mingw`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #149590 - petrochenkov:norlld, r=mati865 linker: Remove special case for `rust-lld` in `detect_self_contained_mingw` `rust-lld` is supposed to live inside sysroot, so it doesn't change the behavior of the function, only removes a potential micro-optimization. #149178 (comment) r? `@mati865`
rust-lldis supposed to live inside sysroot, so it doesn't change the behavior of the function, only removes a potential micro-optimization.#149178 (comment)
r? @mati865