diff options
| author | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-08-26 15:53:56 -0700 |
|---|---|---|
| committer | Stuart Pernsteiner <spernsteiner@mozilla.com> | 2014-09-05 09:18:57 -0700 |
| commit | b5a0b700c64639043bce0a2ba0a8b40dd853d469 (patch) | |
| tree | 3747685e68efa0ce67e2f4931a6e9235fcfdc57b | |
| parent | 4b70269854a701668ba47641201c4403228db06b (diff) | |
| download | rust-b5a0b700c64639043bce0a2ba0a8b40dd853d469.tar.gz rust-b5a0b700c64639043bce0a2ba0a8b40dd853d469.zip | |
use target-specific linker args when combining compilation units
| -rw-r--r-- | src/librustc/back/write.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/librustc/back/write.rs b/src/librustc/back/write.rs index 076338ccef8..2760ae80110 100644 --- a/src/librustc/back/write.rs +++ b/src/librustc/back/write.rs @@ -604,17 +604,34 @@ pub fn run_passes(sess: &Session, }; let link_obj = |output_path: &Path| { - let mut cmd = Command::new("ld"); + let pname = get_cc_prog(sess); + let mut cmd = Command::new(pname.as_slice()); + + cmd.args(sess.targ_cfg.target_strs.cc_args.as_slice()); + cmd.arg("-nostdlib"); for index in range(0, trans.modules.len()) { cmd.arg(crate_output.with_extension(format!("{}.o", index).as_slice())); } cmd.arg("-r").arg("-o").arg(output_path); + + if (sess.opts.debugging_opts & config::PRINT_LINK_ARGS) != 0 { + println!("{}", &cmd); + } + cmd.stdin(::std::io::process::Ignored) .stdout(::std::io::process::InheritFd(1)) .stderr(::std::io::process::InheritFd(2)); - cmd.status().unwrap(); + match cmd.status() { + Ok(_) => {}, + Err(e) => { + sess.err(format!("could not exec the linker `{}`: {}", + pname, + e).as_slice()); + sess.abort_if_errors(); + }, + } }; // Flag to indicate whether the user explicitly requested bitcode. |
