5

Make `[rust] use-lld=true` work on windows by khyperia · Pull Request #100464 ·...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/100464
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

// is already on by default in Windows optimized builds, which is interpreted as --icf=all:

// https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746

// https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827

#[cfg(not(windows))]

Member

@jyn514 jyn514 7 days ago

edited

This is the platform of the host we are building on. But it's possible to cross compile from Unix to Windows, in which case I think we still use the MSVC toolchain.

Also, I think this needs to only special case MSVC - I think pc-windows-gnu should support these flags (@workingjubilee @Kobzol can you confirm?).

As a general rule, the only platform-specific cfg code in bootstrap should be related to filesystem stuff, everything else should be based off compiler.target.

All reactions

Contributor

Author

@khyperia khyperia 7 days ago

edited

Ah right, that makes sense!

I am very unsure of myself, but I think that I should be checking compiler.host.contains("msvc") rather than target.contains("msvc") - the comment at the top of this function says "This will build the compiler for a particular stage of the build using the compiler targeting the target architecture", so I think we should be using the flag format for compiler rather than target. Let me know if I'm wrong!

All reactions

so, you're right that the distinction matters, but unfortunately bootstrap is really bad at naming things sweat_smile and compiler is "the compiler building Rustc", not "the compiler generated by the Rustc step". so target is correct.

If it helps, I double-checked this for myself by looking at what platform we pass to cargo, and it is target, not compiler.host:

All reactions

ok it turns out you are correct after all, we use the linker of the host and not the target. sorry for the confusion.

All reactions

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK