linker: Remove special case for rust-lld in detect_self_contained_mingw#149590
linker: Remove special case for rust-lld in detect_self_contained_mingw#149590bors merged 1 commit intorust-lang:mainfrom
rust-lld in detect_self_contained_mingw#149590Conversation
…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.
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.
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
There was a problem hiding this comment.
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
sess.opts.sysroot.all_paths() to check both.
There was a problem hiding this comment.
Good point, but is --sysroot ever passed to rustc when building natively (host == target)?
There was a problem hiding this comment.
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.
--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.
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