Questions regarding linker-plugin-based LTO
⚓ Rust 📅 2025-09-20 👤 surdeus 👁️ 10Hi!
After reading the documentation about Linker-based LTO and researching over the forum and Rustc's GitHub issue tracker, I have several questions about linker-based LTO functionality in Rustc:
- Toolchain compatibility docs are outdated - the latest reported Rustc version is 1.78 (currently we have 1.90 as a stable). Could you please clarify this information for the missing Rustc versions too? Or maybe anything is changed regarding the "Note that the compatibility policy for this feature might change in the future."? This information is important for users since sometimes (according to the documentation) uses "unstable" LLVM versions so users can get awkward errors here.
- According to the documentation, linker-based LTO supports both LTO modes: Thin and Full. However, according to the issue, right now this functionality doesn't work for FullLTO cases. Seems like it should be already fixed with Rustc 1.90 but according to my local tests (just reproduced the results from the issue with the same commands) - it still doesn't work, even if I have the same LLVM version between Clang and Rustc (LLVM version 20.1.8). If linker-based LTO still doesn't work with FullLTO, I think we need to update the documentation about it before the actual fix. Tried to reproduce with Rustc Nightly 1.92, but it has a different LLVM version under the hood, so I get linking errors (as expected).
- Here is described a way to pass a custom linker plugin. I tried to find something about LLVM linker plugin but found only this page in LLVM docs. As far as I understand, it's the same thing - am I right? If so, I suppose it would be nice to add a reference to this LLVM docs page from Rustc docs about linker-based LTO.
- Did anyone test linker-based LTO in Rustc with other LLVM-based compilers except Clang? E.g. tests with Flang for Fortran, LDC for D, etc ? I would be happy to read reports for other combinations. In theory - it should work. However, I am interested in practical tests since they usually uncover hidden traps.
- Here was mentioned that "LLVM refuses to read bitcode produced by a newer LLVM version". What about reading bitcode from an older LLVM version instead of a newer one? Is it guaranteed to be processed properly, or we cannot really rely on it as users?
- Did anyone hear about any project that tries to mix different compilers (like most common nowadays GCC and Clang) for linker-based LTO purposes? I mean some kind of a transpiler from GCC bitcode to LLVM bitcode, so a linker with LLVM plugin will be able to perform cross-compiler LTO optimizations? Something like Wyrm but ready-to-use or at least not abandoned
I know that I ask for pretty crazy stuff, yeah. As far as I understand, for Rustc the most promising option for such mixing is experimenting with GCC backend for Rustc.
Gently pinging @bjorn3 and @alice as they replied in other LTO-related topics on this forum.
Thank you!
1 post - 1 participant
🏷️ Rust_feed