diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-10-10 23:06:22 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-10-15 22:10:07 +0300 |
| commit | 9e0fc5ccd050201e77483b1efb2e6c76f47496f6 (patch) | |
| tree | b11fa90e3a2205b9add4ba0ffc8a3e38725c96e6 /src/bootstrap/lib.rs | |
| parent | 2689fd2402590961dae32f35369a8685c89022fb (diff) | |
| download | rust-9e0fc5ccd050201e77483b1efb2e6c76f47496f6.tar.gz rust-9e0fc5ccd050201e77483b1efb2e6c76f47496f6.zip | |
rustbuild: Support specifying archiver and linker explicitly
Diffstat (limited to 'src/bootstrap/lib.rs')
| -rw-r--r-- | src/bootstrap/lib.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 2d721f45578..7c599f91838 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -240,10 +240,11 @@ pub struct Build { lldb_python_dir: Option<String>, // Runtime state filled in later on - // target -> (cc, ar) - cc: HashMap<Interned<String>, (cc::Tool, Option<PathBuf>)>, - // host -> (cc, ar) + // C/C++ compilers and archiver for all targets + cc: HashMap<Interned<String>, cc::Tool>, cxx: HashMap<Interned<String>, cc::Tool>, + ar: HashMap<Interned<String>, PathBuf>, + // Misc crates: HashMap<Interned<String>, Crate>, is_sudo: bool, ci_env: CiEnv, @@ -324,6 +325,7 @@ impl Build { rls_info, cc: HashMap::new(), cxx: HashMap::new(), + ar: HashMap::new(), crates: HashMap::new(), lldb_version: None, lldb_python_dir: None, @@ -612,7 +614,7 @@ impl Build { /// Returns the path to the C compiler for the target specified. fn cc(&self, target: Interned<String>) -> &Path { - self.cc[&target].0.path() + self.cc[&target].path() } /// Returns a list of flags to pass to the C compiler for the target @@ -620,7 +622,7 @@ impl Build { fn cflags(&self, target: Interned<String>) -> Vec<String> { // Filter out -O and /O (the optimization flags) that we picked up from // cc-rs because the build scripts will determine that for themselves. - let mut base = self.cc[&target].0.args().iter() + let mut base = self.cc[&target].args().iter() .map(|s| s.to_string_lossy().into_owned()) .filter(|s| !s.starts_with("-O") && !s.starts_with("/O")) .collect::<Vec<_>>(); @@ -644,7 +646,11 @@ impl Build { /// Returns the path to the `ar` archive utility for the target specified. fn ar(&self, target: Interned<String>) -> Option<&Path> { - self.cc[&target].1.as_ref().map(|p| &**p) + self.ar.get(&target).map(|p| &**p) + } + + fn linker(&self, target: Interned<String>) -> Option<&Path> { + self.config.target_config.get(&target).and_then(|c| c.linker.as_ref().map(|p| &**p)) } /// Returns the path to the C++ compiler for the target specified. @@ -667,7 +673,10 @@ impl Build { // than an entry here. let mut base = Vec::new(); - if target != self.config.build && !target.contains("msvc") && + if let Some(linker) = self.linker(target) { + // If linker was explictly provided, force it on all the compiled Rust code. + base.push(format!("-Clinker={}", linker.display())); + } else if target != self.config.build && !target.contains("msvc") && !target.contains("emscripten") { base.push(format!("-Clinker={}", self.cc(target).display())); } |
