diff options
| author | bors <bors@rust-lang.org> | 2019-01-31 11:07:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-31 11:07:41 +0000 |
| commit | d30b99f9c23f8e1d6ef993cc94da96510ad709b3 (patch) | |
| tree | 06c4c2ae28a7962efff74b5deda5f6df5443d7f0 /src/bootstrap | |
| parent | f40aaa68278ef0879af5fe7ce077c64c6515ea05 (diff) | |
| parent | b17c10de46b021cb25855d440b6a0c270d4d1f4e (diff) | |
| download | rust-d30b99f9c23f8e1d6ef993cc94da96510ad709b3.tar.gz rust-d30b99f9c23f8e1d6ef993cc94da96510ad709b3.zip | |
Auto merge of #57514 - michaelwoerister:xlto-tests, r=alexcrichton
compiletest: Support opt-in Clang-based run-make tests and use them for testing xLTO. Some cross-language run-make tests need a Clang compiler that matches the LLVM version of `rustc`. Since such a compiler usually isn't available these tests (marked with the `needs-matching-clang` directive) are ignored by default. For some CI jobs we do need these tests to run unconditionally though. In order to support this a `--force-clang-based-tests` flag is added to compiletest. If this flag is specified, `compiletest` will fail if it can't detect an appropriate version of Clang. @rust-lang/infra The PR doesn't yet enable the tests yet. Do you have any recommendation for which jobs to enable them? cc #57438 r? @alexcrichton
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/config.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/native.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 24 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 41 |
4 files changed, 55 insertions, 17 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index ba339c50fc3..7d3e584f1a6 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -77,6 +77,7 @@ pub struct Config { pub llvm_experimental_targets: String, pub llvm_link_jobs: Option<u32>, pub llvm_version_suffix: Option<String>, + pub llvm_use_linker: Option<String>, pub lld_enabled: bool, pub lldb_enabled: bool, @@ -261,6 +262,7 @@ struct Llvm { cxxflags: Option<String>, ldflags: Option<String>, use_libcxx: Option<bool>, + use_linker: Option<String>, } #[derive(Deserialize, Default, Clone)] @@ -527,6 +529,7 @@ impl Config { config.llvm_cxxflags = llvm.cxxflags.clone(); config.llvm_ldflags = llvm.ldflags.clone(); set(&mut config.llvm_use_libcxx, llvm.use_libcxx); + config.llvm_use_linker = llvm.use_linker.clone(); } if let Some(ref rust) = toml.rust { diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index b1bc2e6cad5..f48f9ee752e 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -234,6 +234,10 @@ impl Step for Llvm { cfg.define("LLVM_VERSION_SUFFIX", suffix); } + if let Some(ref linker) = builder.config.llvm_use_linker { + cfg.define("LLVM_USE_LINKER", linker); + } + if let Some(ref python) = builder.config.python { cfg.define("PYTHON_EXECUTABLE", python); } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 216649808e2..1a46ebfcabb 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1088,9 +1088,7 @@ impl Step for Compiletest { }; let lldb_exe = if builder.config.lldb_enabled && !target.contains("emscripten") { // Test against the lldb that was just built. - builder.llvm_out(target) - .join("bin") - .join("lldb") + builder.llvm_out(target).join("bin").join("lldb") } else { PathBuf::from("lldb") }; @@ -1107,6 +1105,26 @@ impl Step for Compiletest { } } + if let Some(var) = env::var_os("RUSTBUILD_FORCE_CLANG_BASED_TESTS") { + match &var.to_string_lossy().to_lowercase()[..] { + "1" | "yes" | "on" => { + assert!(builder.config.lldb_enabled, + "RUSTBUILD_FORCE_CLANG_BASED_TESTS needs Clang/LLDB to \ + be built."); + let clang_exe = builder.llvm_out(target).join("bin").join("clang"); + cmd.arg("--run-clang-based-tests-with").arg(clang_exe); + } + "0" | "no" | "off" => { + // Nothing to do. + } + other => { + // Let's make sure typos don't get unnoticed + panic!("Unrecognized option '{}' set in \ + RUSTBUILD_FORCE_CLANG_BASED_TESTS", other); + } + } + } + // Get paths from cmd args let paths = match &builder.config.cmd { Subcommand::Test { ref paths, .. } => &paths[..], diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 9f6db73e6f7..cd3afc59e56 100644 --- a/src/bootstrap/tool.rs +++ b/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; @@ -666,19 +665,33 @@ 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); } } @@ -686,7 +699,7 @@ impl<'a> Builder<'a> { } 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, |
