]> git.lizzy.rs Git - rust.git/commit
run optimization and codegen on worker threads
authorStuart Pernsteiner <spernsteiner@mozilla.com>
Thu, 17 Jul 2014 17:52:52 +0000 (10:52 -0700)
committerStuart Pernsteiner <spernsteiner@mozilla.com>
Fri, 5 Sep 2014 16:18:55 +0000 (09:18 -0700)
commitcf672850df05a05e8bb5785228c408a24e102d32
tree77fcfd17136b3d8a12d29a7e1ce880f10120a5b2
parente29aa1430bb45d18a5d3fcc5f3b7d20e99a57758
run optimization and codegen on worker threads

Refactor the code in `llvm::back` that invokes LLVM optimization and codegen
passes so that it can be called from worker threads.  (Previously, it used
`&Session` extensively, and `Session` is not `Share`.)  The new code can handle
multiple compilation units, by compiling each unit to `crate.0.o`, `crate.1.o`,
etc., and linking together all the `crate.N.o` files into a single `crate.o`
using `ld -r`.  The later linking steps can then be run unchanged.

The new code preserves the behavior of `--emit`/`-o` when building a single
compilation unit.  With multiple compilation units, the `--emit=asm/ir/bc`
options produce multiple files, so combinations like `--emit=ir -o foo.ll` will
not actually produce `foo.ll` (they instead produce several `foo.N.ll` files).

The new code supports `-Z lto` only when using a single compilation unit.
Compiling with multiple compilation units and `-Z lto` will produce an error.
(I can't think of any good reason to do such a thing.)  Linking with `-Z lto`
against a library that was built as multiple compilation units will also fail,
because the rlib does not contain a `crate.bytecode.deflate` file.  This could
be supported in the future by linking together the `crate.N.bc` files produced
when compiling the library into a single `crate.bc`, or by making the LTO code
support multiple `crate.N.bytecode.deflate` files.
src/compiletest/runtest.rs
src/librustc/back/link.rs
src/librustc/back/lto.rs
src/librustc/back/write.rs
src/librustc/driver/config.rs
src/librustc/driver/driver.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/context.rs
src/librustc_llvm/lib.rs