Skip to content

Commit

Permalink
don't use ld -r with -C codegen-units=1
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed Sep 5, 2014
1 parent 4d9a478 commit 6d2d47b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/librustc/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down

5 comments on commit 6d2d47b

@bors
Copy link
Contributor

@bors bors commented on 6d2d47b Sep 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 6d2d47b Sep 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging epdtry/rust/parallel-codegen = 6d2d47b into auto

@bors
Copy link
Contributor

@bors bors commented on 6d2d47b Sep 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epdtry/rust/parallel-codegen = 6d2d47b merged ok, testing candidate = 4bea7b3

@bors
Copy link
Contributor

@bors bors commented on 6d2d47b Sep 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4bea7b3

Please sign in to comment.