Skip to content

Conversation

@NobodyXu
Copy link
Contributor

The linker-plugin/lld uses thin LTO by default, and it requires the archive to be compiled with thin LTO as well, since thin LTO generates function summary which is needed by thin LTO.

// It has to be thin LTO because llvm linker plugin/lld uses thin LTO by default.
// And for thin LTO to work, the archive also has to be compiled using thin LTO,
// since thin LTO generates extra information that fat LTO does not generate that
// is required for thin LTO process.
Copy link
Contributor

Choose a reason for hiding this comment

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

Six "thin LTO" in two sentences. Well, not that I care that much, but it does sting the eye. It also feels that it would look worse in isolation, i.e. not in the diff context. I mean

- push_if_supported(format!("-flto={cc_val}").into());
+ // It has to be thin LTO because llvm linker plugin/lld uses thin LTO by default.

looks like meaningful "rebuttal," while

// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
// It has to be thin LTO because llvm linker plugin/lld uses thin LTO by default.

feels like "wow, where does it come from?"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks updated

Copy link
Contributor

Choose a reason for hiding this comment

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

Five "thin LTO"-s, only one down... But what does second sentence add now? It's basically the first sentence... Again, not that I care that much :-) Just do you :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm if it can be understood by another maintainer with no context before hand, then I think it's good

Choose a reason for hiding this comment

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

FWIW, I think this might become problematic with rustc_codegen_gcc, as GCC has -flto but not -flto=thin (the way GCC does LTO is different). I believe rustc_codegen_gcc already has some support for cross-language LTO so it's not just theoretical. cc @antoyo

Copy link
Contributor Author

@NobodyXu NobodyXu Oct 21, 2025

Choose a reason for hiding this comment

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

-flto is only enabled for clang, it's currently always disabled for gcc

The linker-plugin/lld uses thin LTO by default, and it requires the archive to be compiled
with thin LTO as well, since thin LTO generates function summary
which is needed by thin LTO.
Added a comment explaining the purpose of the unused 'lto' variable.
Clarify comments regarding thin LTO requirements for linker plugin.
@NobodyXu NobodyXu merged commit b6281e8 into main Oct 24, 2025
158 checks passed
@NobodyXu NobodyXu deleted the NobodyXu-patch-1 branch October 24, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants