Skip to content

Commit

Permalink
bootstrap: Make LLD available to run-make tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Jan 30, 2019
1 parent 4460e7c commit 9c29517
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions src/bootstrap/tool.rs
@@ -1,6 +1,5 @@
use std::fs;
use std::env;
use std::iter;
use std::path::PathBuf;
use std::process::{Command, exit};
use std::collections::HashSet;
Expand Down Expand Up @@ -666,27 +665,41 @@ impl<'a> Builder<'a> {

// Add the llvm/bin directory to PATH since it contains lots of
// useful, platform-independent tools
if tool.uses_llvm_tools() {
if tool.uses_llvm_tools() && !self.config.dry_run {
let mut additional_paths = vec![];

if let Some(llvm_bin_path) = self.llvm_bin_path() {
if host.contains("windows") {
// On Windows, PATH and the dynamic library path are the same,
// so we just add the LLVM bin path to lib_path
lib_paths.push(llvm_bin_path);
} else {
let old_path = env::var_os("PATH").unwrap_or_default();
let new_path = env::join_paths(iter::once(llvm_bin_path)
.chain(env::split_paths(&old_path)))
.expect("Could not add LLVM bin path to PATH");
cmd.env("PATH", new_path);
}
additional_paths.push(llvm_bin_path);
}

// If LLD is available, add that too.
if self.config.lld_enabled {
let lld_install_root = self.ensure(native::Lld {
target: self.config.build,
});

let lld_bin_path = lld_install_root.join("bin");
additional_paths.push(lld_bin_path);
}

if host.contains("windows") {
// On Windows, PATH and the dynamic library path are the same,
// so we just add the LLVM bin path to lib_path
lib_paths.extend(additional_paths);
} else {
let old_path = env::var_os("PATH").unwrap_or_default();
let new_path = env::join_paths(additional_paths.into_iter()
.chain(env::split_paths(&old_path)))
.expect("Could not add LLVM bin path to PATH");
cmd.env("PATH", new_path);
}
}

add_lib_path(lib_paths, cmd);
}

fn llvm_bin_path(&self) -> Option<PathBuf> {
if self.config.llvm_enabled && !self.config.dry_run {
if self.config.llvm_enabled {
let llvm_config = self.ensure(native::Llvm {
target: self.config.build,
emscripten: false,
Expand Down

0 comments on commit 9c29517

Please sign in to comment.