47 bytes, text/x-phabricator-request
|Details | Review|
Given the right combination of Clang and rustc, LLD can do cross-language ThinLTO. In order for this to work, Rust code must be built with the (currently still unstable) `-Z cross-lang-lto` flag. While testing and debugging the feature, I added this flag to `rustflags_override` in `config/rules.mk` (see https://hg.mozilla.org/try/rev/b2592d085693e617e12d8ae936b70ad0ad01c85f). It would be great if cross-lang LTO could be easily enabled via `.mozconfig`. Some notes: - There might be additional places where the flag needs to be added. All Rust code that ends up in the Firefox distribution and is linked via LLD should have the flag. Tools or build scripts should *not* be compiled with the flag. - This build option will only work if the right combination of Clang, rustc, and LLD are used. In the future, when the flag is available in stable Rust, the build system might want to have a sanity check for this. - When the flag gets stabilized, it will look different (probably something like `-C xlto` or `-C lld-lto`). I'm not sure how to best handle this change.
I'm not particularly convinced it's limited to lld. BFD ld or gold, with the LLVM plugin, should just as well be able to do the linking.
Yes, you are right, in theory gold and newer versions of ld support this too. In practice, I had some trouble though. ld never worked for me and gold seemed a bit unstable, while lld always worked fine. That being said, I haven't tried the other linkers in almost half a year now, so the situation might have improved.
We're doing thin lto with BFD ld on automation (also, Apple's ld64 for mac, where there's essentially no other choice), and haven't had problems with that. I don't expect linking more thin lto objects to make a difference.
That's good to know. I also expect cross-lang-lto not to make a difference as long as the LLVM version of rustc, clang, and the linker plugin match closely enough.
Severity: normal → enhancement
Attachment #9055291 - Attachment description: Enable cross-language LTO on Win64 → Enable cross-language LTO on Win64 shippable builds
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/autoland/rev/5851c65af0e0 Enable cross-language LTO on Win64 shippable builds r=glandium
Summary: Support cross-language LTO in the build system → Enable cross-language LTO on Win64
You need to log in before you can comment on or make changes to this bug.