summary refs log tree commit diff
path: root/src/bootstrap/native.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2020-04-24 11:18:59 -0700
committerAlex Crichton <alex@alexcrichton.com>2020-04-24 11:18:59 -0700
commit0546d115288ce0d6c3a819909de12fba5ce673fd (patch)
tree9e32fc64b1f724ce18ef4f916f99c31b96413e9a /src/bootstrap/native.rs
parentc7a7658c6dd89fd5e0a696460fe9abceb2bde8aa (diff)
downloadrust-0546d115288ce0d6c3a819909de12fba5ce673fd.tar.gz
rust-0546d115288ce0d6c3a819909de12fba5ce673fd.zip
Fix cross-compiling LLD to different platforms
Looks like the native build system isn't great a coping with this, so
try to work around that with a few workarounds.
Diffstat (limited to 'src/bootstrap/native.rs')
-rw-r--r--src/bootstrap/native.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 0c87695ff7c..0f39e33c5f4 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -479,10 +479,29 @@ impl Step for Lld {
         let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");
         cfg.out_dir(&out_dir)
             .profile("Release")
-            .env("LLVM_CONFIG_REAL", llvm_config)
+            .env("LLVM_CONFIG_REAL", &llvm_config)
             .define("LLVM_CONFIG_PATH", llvm_config_shim)
             .define("LLVM_INCLUDE_TESTS", "OFF");
 
+        // While we're using this horrible workaround to shim the execution of
+        // llvm-config, let's just pile on more. I can't seem to figure out how
+        // to build LLD as a standalone project and also cross-compile it at the
+        // same time. It wants a natively executable `llvm-config` to learn
+        // about LLVM, but then it learns about all the host configuration of
+        // LLVM and tries to link to host LLVM libraries.
+        //
+        // To work around that we tell our shim to replace anything with the
+        // build target with the actual target instead. This'll break parts of
+        // LLD though which try to execute host tools, such as llvm-tblgen, so
+        // we specifically tell it where to find those. This is likely super
+        // brittle and will break over time. If anyone knows better how to
+        // cross-compile LLD it would be much appreciated to fix this!
+        if target != builder.config.build {
+            cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
+                .env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
+                .define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen"));
+        }
+
         cfg.build();
 
         t!(File::create(&done_stamp));