diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-12-20 11:16:41 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-12-20 12:59:07 -0800 |
| commit | cade120da3bea3e26019b0a8c94d26ec7e136261 (patch) | |
| tree | d8e0b0aec0229bc9e92555be88c78727a6b00b6e | |
| parent | 60842c1c1fdb69bccc58613e26f1c9661ca8bd39 (diff) | |
| parent | bd85a6dbe71807774764e52600aa5429ac878b1d (diff) | |
| download | rust-cade120da3bea3e26019b0a8c94d26ec7e136261.tar.gz rust-cade120da3bea3e26019b0a8c94d26ec7e136261.zip | |
Rollup merge of #38463 - japaric:asm-args, r=alexcrichton
target spec: add an asm-args field to pass arguments to the external .. assembler The main use case is the (still out of tree) msp430 target. For that target we use an external assembler, `mps430-elf-gcc`, to produce object files from the assembly rustc/llvm outputs. The problem is that by default `msp430-elf-gcc` produces object files for the MSP430**X** ABI but we want to use produce objects using the MSP430 (note: no X) ABI. To do that we have to pass `-mcpu=msp430` to the assembler and that's what this flag is for. r? @alexcrichton cc @pftbest
| -rw-r--r-- | src/librustc_back/target/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 351d469ea28..13333be66f5 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -267,6 +267,9 @@ pub struct TargetOptions { /// user-defined libraries. pub post_link_args: Vec<String>, + /// Extra arguments to pass to the external assembler (when used) + pub asm_args: Vec<String>, + /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults /// to "generic". pub cpu: String, @@ -394,6 +397,7 @@ impl Default for TargetOptions { ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(), pre_link_args: Vec::new(), post_link_args: Vec::new(), + asm_args: Vec::new(), cpu: "generic".to_string(), features: "".to_string(), dynamic_linking: false, @@ -561,6 +565,7 @@ impl Target { key!(late_link_args, list); key!(post_link_objects, list); key!(post_link_args, list); + key!(asm_args, list); key!(cpu); key!(features); key!(dynamic_linking, bool); @@ -723,6 +728,7 @@ impl ToJson for Target { target_option_val!(late_link_args); target_option_val!(post_link_objects); target_option_val!(post_link_args); + target_option_val!(asm_args); target_option_val!(cpu); target_option_val!(features); target_option_val!(dynamic_linking); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index ffab0bde7ab..de8814f143e 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -1085,6 +1085,10 @@ fn run_work_multithreaded(sess: &Session, pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) { let (pname, mut cmd, _) = get_linker(sess); + for arg in &sess.target.target.options.asm_args { + cmd.arg(arg); + } + cmd.arg("-c").arg("-o").arg(&outputs.path(OutputType::Object)) .arg(&outputs.temp_path(OutputType::Assembly, None)); debug!("{:?}", cmd); |
