Blame SOURCES/rust-pr70591-ensure-llvm-is-in-the-link-path.patch

a094b5
commit 6067315d58ff3d49b305ae3c99810656856c8e21
a094b5
Author: Josh Stone <jistone@redhat.com>
a094b5
Date:   Mon Mar 30 14:03:39 2020 -0700
a094b5
a094b5
    Ensure LLVM is in the link path for "fulldeps" tests
a094b5
    
a094b5
    This is a follow-up to #70123, which added `llvm-config --libdir` to the
a094b5
    `LIBRARY_PATH` for rustc tools. We need the same for "run-make-fulldeps"
a094b5
    and "ui-fulldeps" tests which depend on compiler libraries, implicitly
a094b5
    needing to link to `-lLLVM` as well.
a094b5
a094b5
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
a094b5
index 5b946b05735d..2499856235f1 100644
a094b5
--- a/src/bootstrap/test.rs
a094b5
+++ b/src/bootstrap/test.rs
a094b5
@@ -21,7 +21,7 @@ use crate::flags::Subcommand;
a094b5
 use crate::native;
a094b5
 use crate::tool::{self, SourceType, Tool};
a094b5
 use crate::toolstate::ToolState;
a094b5
-use crate::util::{self, dylib_path, dylib_path_var};
a094b5
+use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var};
a094b5
 use crate::Crate as CargoCrate;
a094b5
 use crate::{envify, DocTests, GitRepo, Mode};
a094b5
 
a094b5
@@ -1178,6 +1178,15 @@ impl Step for Compiletest {
a094b5
                 cmd.arg("--system-llvm");
a094b5
             }
a094b5
 
a094b5
+            // Tests that use compiler libraries may inherit the `-lLLVM` link
a094b5
+            // requirement, but the `-L` library path is not propagated across
a094b5
+            // separate compilations. We can add LLVM's library path to the
a094b5
+            // platform-specific environment variable as a workaround.
a094b5
+            if !builder.config.dry_run && suite.ends_with("fulldeps") {
a094b5
+                let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
a094b5
+                add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
a094b5
+            }
a094b5
+
a094b5
             // Only pass correct values for these flags for the `run-make` suite as it
a094b5
             // requires that a C++ compiler was configured which isn't always the case.
a094b5
             if !builder.config.dry_run && suite == "run-make-fulldeps" {