about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-07-05 23:43:32 +0200
committerGitHub <noreply@github.com>2022-07-05 23:43:32 +0200
commit3fe0191df87f34607b356d6e88b86922c6ee7fd7 (patch)
tree5f5359c5b0daaae2b1c033484fc803d711e136fb
parent4986379d7910d4f87beb2a4a0d17127cc074df0e (diff)
parent22b4ea4813a7aa5fc2ee454fca50853fdc47ba3e (diff)
downloadrust-3fe0191df87f34607b356d6e88b86922c6ee7fd7.tar.gz
rust-3fe0191df87f34607b356d6e88b86922c6ee7fd7.zip
Rollup merge of #98880 - topjohnwu:macos-dylib-cross, r=jyn514
Proper macOS libLLVM symlink when cross compiling

Follow up of #98418

When cross compiling on macOS with `llvm.link-shared` enabled, the symlink creation will fail after compiling LLVM for the target architecture, because it will attempt to create the symlink in the host LLVM directory, which was already created when being built.

This commit changes the symlink path to the actual LLVM output.

r? `@jyn514`
-rw-r--r--src/bootstrap/native.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 8395be40f9b..503a2fc469e 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -487,16 +487,14 @@ impl Step for Llvm {
             let version = output(cmd.arg("--version"));
             let major = version.split('.').next().unwrap();
             let lib_name = match llvm_version_suffix {
-                Some(s) => format!("lib/libLLVM-{}{}.dylib", major, s),
-                None => format!("lib/libLLVM-{}.dylib", major),
+                Some(s) => format!("libLLVM-{}{}.dylib", major, s),
+                None => format!("libLLVM-{}.dylib", major),
             };
 
-            // The reason why we build the library path from llvm-config is because
-            // the output of llvm-config depends on its location in the file system.
-            // Make sure we create the symlink exactly where it's needed.
-            let llvm_base = build_llvm_config.parent().unwrap().parent().unwrap();
-            let lib_llvm = llvm_base.join(lib_name);
-            t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
+            let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
+            if !lib_llvm.exists() {
+                t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
+            }
         }
 
         t!(stamp.write());