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

Make [rust] use-lld=true work on windows #100464

Merged
merged 1 commit into from
Aug 14, 2022

Conversation

khyperia
Copy link
Contributor

Before, it would fail with "error: ignoring unknown argument '-Wl,--icf=all'"

This option was introduced in #99062 (well, technically #99680)

See zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/rust-lld.3A.20error.3A.20ignoring.20unknown.20argument.20'-Wl.2C--icf.3Dall'

@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 12, 2022
@rust-highfive
Copy link
Collaborator

r? @jyn514

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 12, 2022
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It needs some small changes but I appreciate all the research you did :) the link to rustc_driver was especially useful since it confirmed this is an MSVC-specific problem.

// 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))]
Copy link
Member

@jyn514 jyn514 Aug 12, 2022

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

@khyperia khyperia Aug 12, 2022

Choose a reason for hiding this comment

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

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!

Copy link
Member

Choose a reason for hiding this comment

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

so, you're right that the distinction matters, but unfortunately bootstrap is really bad at naming things 😅 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:

let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");

Copy link
Member

Choose a reason for hiding this comment

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

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

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2022
Before, it would fail with "error: ignoring unknown argument '-Wl,--icf=all'"
@jyn514
Copy link
Member

jyn514 commented Aug 12, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 12, 2022

📌 Commit dcead65 has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 12, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2022
…mpiler-errors

Rollup of 11 pull requests

Successful merges:

 - rust-lang#100355 (rustdoc: Rename ``@has` FILE PATTERN` to ``@hasraw` FILE PATTERN`)
 - rust-lang#100407 (avoid some int2ptr casts in thread_local_key tests)
 - rust-lang#100434 (Fix HIR pretty printing of let else)
 - rust-lang#100438 (Erase regions better in `promote_candidate`)
 - rust-lang#100445 (adapt test for msan message change)
 - rust-lang#100447 (Remove more Clean trait implementations)
 - rust-lang#100464 (Make `[rust] use-lld=true` work on windows)
 - rust-lang#100475 (Give a helpful diagnostic when the next struct field has an attribute)
 - rust-lang#100490 (wf: correctly `shallow_resolve` consts)
 - rust-lang#100501 (nicer Miri backtraces for from_exposed_addr)
 - rust-lang#100509 (merge two test directories that mean the same thing)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7a34d39 into rust-lang:master Aug 14, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 14, 2022
@khyperia khyperia deleted the lld-icf-on-windows branch October 23, 2022 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants