Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update comments on thin LTO for linker plugin
Clarify comments regarding thin LTO requirements for linker plugin.
  • Loading branch information
NobodyXu committed Oct 24, 2025
commit 27698d1f9dc974f208548b5c07972e6eb3e9433e
5 changes: 3 additions & 2 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ impl<'this> RustcCodegenFlags<'this> {
// https://doc.rust-lang.org/rustc/linker-plugin-lto.html
if self.linker_plugin_lto.unwrap_or(false) {
// 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.
// And for thin LTO to work, the archive also has to be compiled using thin LTO,
// In order to use linker-plugin-lto to achieve cross-lang lto, cc has to use thin LTO
// to compile the c/c++ libraries because llvm linker plugin/lld uses thin LTO by default.
// And for thin LTO in linker plugin 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

push_if_supported("-flto=thin".into());
Expand Down
Loading