]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #58057 - michaelwoerister:stabilize-xlto, r=alexcrichton
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 13 Feb 2019 03:36:59 +0000 (04:36 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Feb 2019 03:36:59 +0000 (04:36 +0100)
Stabilize linker-plugin based LTO (aka cross-language LTO)

This PR stabilizes [linker plugin based LTO](https://github.com/rust-lang/rust/issues/49879), also known as "cross-language LTO" because it allows for doing inlining and other optimizations across language boundaries in mixed Rust/C/C++ projects.

As described in the tracking issue, it works by making `rustc` emit LLVM bitcode instead of machine code, the same as `clang` does. A linker with the proper plugin (like LLD) can then run (Thin)LTO across all modules.

The feature has been implemented over a number of pull requests and there are various [codegen](https://github.com/rust-lang/rust/blob/master/src/test/codegen/no-dllimport-w-cross-lang-lto.rs) and [run](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto-clang)-[make](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs) [tests](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/cross-lang-lto) that make sure that it keeps working.

It also works for building big projects like [Firefox](https://treeherder.mozilla.org/#/jobs?repo=try&revision=2ce2d5ddcea6fbff790503eac406954e469b2f5d).

The PR makes the feature available under the `-C linker-plugin-lto` flag. As discussed in the tracking issue it is not cross-language specific and also not LLD specific. `-C linker-plugin-lto` is descriptive of what it does. If someone has a better name, let me know `:)`

1  2 
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_llvm/back/lto.rs
src/librustc_codegen_ssa/back/linker.rs
src/librustc_codegen_ssa/back/write.rs

Simple merge
Simple merge
Simple merge