Skip to content

Remove -Zemit-thin-lto flag#152527

Open
bjorn3 wants to merge 2 commits intorust-lang:mainfrom
bjorn3:remove_z_emit_thin_lto
Open

Remove -Zemit-thin-lto flag#152527
bjorn3 wants to merge 2 commits intorust-lang:mainfrom
bjorn3:remove_z_emit_thin_lto

Conversation

@bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Feb 12, 2026

As far as I can tell it was introduced in #98162 to allow fat LTO with -Clinker-plugin-lto. In #136840 a change was made to automatically disable ThinLTO summary generation when -Clinker-plugin-lto -Clto=fat is used, so we can safely remove it.

Fixes #152490

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2026

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @cuviper


ModulePassManager MPM;
bool NeedThinLTOBufferPasses = EmitThinLTO;
bool NeedThinLTOBufferPasses = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

This used to be true when fat LTO is not used, so I ensured all fat LTO phases do NeedThinLTOBufferPasses = false below.

MPM.addPass(BitcodeWriterPass(ThinLTODataOS));
}
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
Copy link
Member Author

Choose a reason for hiding this comment

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

PreLinkNoLTO is never used when fat LTO is enabled.

if (EmitThinLTO) {
// thin lto summaries prevent fat lto, so do not emit them if fat
// lto is requested. See PR #136840 for background information.
if (OptStage != LLVMRustOptStage::PreLinkFatLTO) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't need to check LLVMRustOptStage::FatLTO as ThinLTOBufferRef is NULL in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Then, how is this block "For ... LTO" at all?
(per the existing comment, assuming unqualified means full)

Copy link
Member Author

Choose a reason for hiding this comment

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

LTO runs this function twice. Once on each individual module (PreLinkFatLTO or PreLinkThinLTO). In this case ThinBufferRef is a valid pointer to write the bitcode to after optimizing. And a second time after doing module linking (FatLTO) or cross-module function importing (ThinLTO). In this case ThinBufferRef is NULL as we will emit object file(s) rather thaj bitcode.

Copy link
Member

Choose a reason for hiding this comment

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

I see, then perhaps the "For" comment can mention that this is only expected in the prelink phase.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@bjorn3 bjorn3 force-pushed the remove_z_emit_thin_lto branch from df6f555 to 3a1c7d4 Compare February 13, 2026 12:40
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the remove_z_emit_thin_lto branch from 7bb4fe1 to 6dab8fa Compare February 19, 2026 10:42
@rustbot

This comment has been minimized.

@cuviper
Copy link
Member

cuviper commented Feb 20, 2026

LGTM

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 20, 2026

📌 Commit 6dab8fa has been approved by cuviper

It is now in the queue for this repository.

@rust-bors rust-bors bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 20, 2026
…uviper

Remove -Zemit-thin-lto flag

As far as I can tell it was introduced in rust-lang#98162 to allow fat LTO with `-Clinker-plugin-lto`. In rust-lang#136840 a change was made to automatically disable ThinLTO summary generation when `-Clinker-plugin-lto -Clto=fat` is used, so we can safely remove it.

Fixes rust-lang#152490
rust-bors bot pushed a commit that referenced this pull request Feb 20, 2026
Rollup of 8 pull requests

Successful merges:

 - #152057 (bootstrap: respect POSIX jobserver)
 - #152527 (Remove -Zemit-thin-lto flag)
 - #152818 (DOC: do not link to "nightly" in Iterator::by_ref() docstring)
 - #152840 (Add bootstrap snapshot tests for {`install`, `install src`})
 - #152846 (Clarify some variable names in the query proc-macro)
 - #152858 (Fix typo in doc for core::mem::type_info::Struct)
 - #152861 (resolve: do not suggest `_` for unresolved imports)
 - #152873 (std::ops::ControlFlow - use "a" before `Result`)
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 20, 2026

@bors r-

Failed in #152886 (comment)

@rust-bors rust-bors bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 20, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 20, 2026

Commit 6dab8fa has been unapproved.

This PR was contained in a rollup (#152886), which was also unapproved.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Feb 20, 2026
@bjorn3
Copy link
Member Author

bjorn3 commented Feb 20, 2026

@bors try jobs=aarch64-gnu-debug

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 20, 2026
Remove -Zemit-thin-lto flag


try-job: aarch64-gnu-debug
As far as I can tell it was introduced to allow fat LTO with
-Clinker-plugin-lto. Later a change was made to automatically disable
ThinLTO summary generation when -Clinker-plugin-lto -Clto=fat is used,
so we can safely remove it.
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 20, 2026

☀️ Try build successful (CI)
Build commit: 92e1558 (92e15585e3e15dbe0a30d3f961d9033e05445be9, parent: 59fd4ef94daa991e6797b5aa6127e824f3067def)

@bjorn3 bjorn3 force-pushed the remove_z_emit_thin_lto branch from 953103a to c51cd0e Compare February 20, 2026 12:24
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bjorn3
Copy link
Member Author

bjorn3 commented Feb 20, 2026

@bors r=cuviper

Only change since review is an adjusted test.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 20, 2026

📌 Commit c51cd0e has been approved by cuviper

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove -Zemit-thin-lto flag

3 participants

Comments