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

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