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

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