diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-01-21 17:47:57 -0700 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-01-26 08:02:08 -0700 |
| commit | 2d21df8a3fd7a68ba9f52389ead7f06f13190c12 (patch) | |
| tree | c8226fed3da77b0c51cd998e6dac74201109a6ac /src/bootstrap | |
| parent | b7f030e114186890612872c89498cbc914c0220f (diff) | |
| download | rust-2d21df8a3fd7a68ba9f52389ead7f06f13190c12.tar.gz rust-2d21df8a3fd7a68ba9f52389ead7f06f13190c12.zip | |
Workaround presence of LLVM library in stage0/lib
This commit works around the newly-introduced LLVM shared library. This is needed such that llvm-config run from librustc_llvm's build script can correctly locate it's own LLVM, not the one in stage0/lib. The LLVM build system uses the DT_RUNPATH/RUNPATH header within the llvm-config binary, which we want to use, but because Cargo always adds the host compiler's "libdir" (stage0/lib in our case) to the dynamic linker's search path, we weren't properly finding the freshly-built LLVM in llvm/lib. By restoring the environment variable setting the search path to what bootstrap sees, the problem is resolved and librustc_llvm correctly links and finds the appropriate LLVM. Several run-make-fulldeps tests are also updated with similar handling.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 9 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 1 | ||||
| -rw-r--r-- | src/bootstrap/util.rs | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a69ba207495..f742bce180c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -21,7 +21,7 @@ use crate::install; use crate::native; use crate::test; use crate::tool; -use crate::util::{add_lib_path, exe, libdir}; +use crate::util::{self, add_lib_path, exe, libdir}; use crate::{Build, DocTests, Mode, GitRepo}; pub use crate::Compiler; @@ -791,6 +791,13 @@ impl<'a> Builder<'a> { .env("CARGO_TARGET_DIR", out_dir) .arg(cmd); + // See comment in librustc_llvm/build.rs for why this is necessary, largely llvm-config + // needs to not accidentally link to libLLVM in stage0/lib. + cargo.env("REAL_LIBRARY_PATH_VAR", &util::dylib_path_var()); + if let Some(e) = env::var_os(util::dylib_path_var()) { + cargo.env("REAL_LIBRARY_PATH", e); + } + if cmd != "install" { cargo.arg("--target") .arg(target); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index b581271663e..ec04dee6c32 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -712,6 +712,7 @@ pub fn build_codegen_backend(builder: &Builder, if builder.is_rust_llvm(target) && backend != "emscripten" { cargo.env("LLVM_RUSTLLVM", "1"); } + cargo.env("LLVM_CONFIG", &llvm_config); if backend != "emscripten" { let target_config = builder.config.target_config.get(&target); diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 2880f1a084b..37c6c040da8 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -70,7 +70,11 @@ pub fn dylib_path_var() -> &'static str { /// Parses the `dylib_path_var()` environment variable, returning a list of /// paths that are members of this lookup path. pub fn dylib_path() -> Vec<PathBuf> { - env::split_paths(&env::var_os(dylib_path_var()).unwrap_or_default()).collect() + let var = match env::var_os(dylib_path_var()) { + Some(v) => v, + None => return vec![], + }; + env::split_paths(&var).collect() } /// `push` all components to `buf`. On windows, append `.exe` to the last component. |
