diff options
| author | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-09-05 14:30:36 -0700 |
|---|---|---|
| committer | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-09-05 14:30:36 -0700 |
| commit | 6d2d47b2fc73b7beacced1f2a62037193ea1ed30 (patch) | |
| tree | c88f402339467ddad0625255f499de617d21d069 /src | |
| parent | 4d9a4786163a9a9831bf4e283b4e408be03a169b (diff) | |
| download | rust-6d2d47b2fc73b7beacced1f2a62037193ea1ed30.tar.gz rust-6d2d47b2fc73b7beacced1f2a62037193ea1ed30.zip | |
don't use `ld -r` with `-C codegen-units=1`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/back/write.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustc/back/write.rs b/src/librustc/back/write.rs index 506d3585016..627d455f06e 100644 --- a/src/librustc/back/write.rs +++ b/src/librustc/back/write.rs @@ -476,6 +476,9 @@ pub fn run_passes(sess: &Session, sess.fatal("can't perform LTO when using multiple codegen units"); } + // Sanity check + assert!(trans.modules.len() == sess.opts.cg.codegen_units); + unsafe { configure_llvm(sess); } @@ -607,6 +610,15 @@ pub fn run_passes(sess: &Session, }; let link_obj = |output_path: &Path| { + // Running `ld -r` on a single input is kind of pointless. + if sess.opts.cg.codegen_units == 1 { + fs::copy(&crate_output.with_extension("0.o"), + output_path).unwrap(); + // Leave the .0.o file around, to mimic the behavior of the normal + // code path. + return; + } + // Some builds of MinGW GCC will pass --force-exe-suffix to ld, which // will automatically add a .exe extension if the extension is not // already .exe or .dll. To ensure consistent behavior on Windows, we |
