diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2023-10-26 17:42:02 -0400 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2023-10-26 17:42:02 -0400 |
| commit | c797cccda61e1116fa4a2e8feb0fb43432add599 (patch) | |
| tree | 0c135dadf0e67d118d77ddb06e449d0014f6f22a /compiler/rustc_codegen_gcc/build_system/src/config.rs | |
| parent | 8396efecf7d30ca9f7edcf76aba2ea388300f6ab (diff) | |
| parent | e4fe941b11a55c5005630696e9b6d81c65f7bd04 (diff) | |
| download | rust-c797cccda61e1116fa4a2e8feb0fb43432add599.tar.gz rust-c797cccda61e1116fa4a2e8feb0fb43432add599.zip | |
Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into subtree-update_cg_gcc_2023-10-25
Diffstat (limited to 'compiler/rustc_codegen_gcc/build_system/src/config.rs')
| -rw-r--r-- | compiler/rustc_codegen_gcc/build_system/src/config.rs | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/compiler/rustc_codegen_gcc/build_system/src/config.rs b/compiler/rustc_codegen_gcc/build_system/src/config.rs index 4f2e33f0f99..64d9bd73e01 100644 --- a/compiler/rustc_codegen_gcc/build_system/src/config.rs +++ b/compiler/rustc_codegen_gcc/build_system/src/config.rs @@ -3,9 +3,9 @@ use std::collections::HashMap; use std::env as std_env; pub struct ConfigInfo { + pub target: String, pub target_triple: String, pub rustc_command: Vec<String>, - pub run_wrapper: Option<&'static str>, } // Returns the beginning for the command line of rustc. @@ -30,23 +30,47 @@ pub fn set_config( }; let host_triple = get_rustc_host_triple()?; let mut linker = None; - let mut target_triple = host_triple.as_str(); - let mut run_wrapper = None; - // FIXME: handle this with a command line flag? - // let mut target_triple = "m68k-unknown-linux-gnu"; + let mut target_triple = host_triple.clone(); + let mut target = target_triple.clone(); - if host_triple != target_triple { - if target_triple == "m68k-unknown-linux-gnu" { - target_triple = "mips-unknown-linux-gnu"; - linker = Some("-Clinker=m68k-linux-gcc"); - } else if target_triple == "aarch64-unknown-linux-gnu" { - // We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. - linker = Some("-Clinker=aarch64-linux-gnu-gcc"); - run_wrapper = Some("qemu-aarch64 -L /usr/aarch64-linux-gnu"); - } else { - return Err(format!("unknown non-native platform `{}`", target_triple)); + // We skip binary name and the command. + let mut args = std::env::args().skip(2); + + let mut set_target_triple = false; + let mut set_target = false; + while let Some(arg) = args.next() { + match arg.as_str() { + "--target-triple" => { + if let Some(arg) = args.next() { + target_triple = arg; + set_target_triple = true; + } else { + return Err( + "Expected a value after `--target-triple`, found nothing".to_string() + ); + } + }, + "--target" => { + if let Some(arg) = args.next() { + target = arg; + set_target = true; + } else { + return Err( + "Expected a value after `--target`, found nothing".to_string() + ); + } + }, + _ => (), } } + + if set_target_triple && !set_target { + target = target_triple.clone(); + } + + if host_triple != target_triple { + linker = Some(format!("-Clinker={}-gcc", target_triple)); + } let current_dir = std_env::current_dir().map_err(|error| format!("`current_dir` failed: {:?}", error))?; let channel = if let Some(channel) = env.get("CHANNEL") { @@ -118,8 +142,8 @@ pub fn set_config( "target/out".to_string(), ]); Ok(ConfigInfo { - target_triple: target_triple.to_string(), + target, + target_triple, rustc_command, - run_wrapper, }) } |
