From ea63d9a14b2774a28c2518f4279755ba955e8d92 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Wed, 22 Apr 2020 20:40:45 -0700 Subject: [PATCH] disable LLD build for cross compiled hosts At present, the LLD build requested by the --enable-lld configure option appears to make direct use of the "llvm-config" binary built as part of the LLVM build. For cross built LLVM, the "llvm-config" binary produced is intended to run on the target system, so it seems like this cannot work as intended today. Disable the LLD build for cross compiled hosts, while continuing to allow --enable-lld to build a native LLD for use by targets like Fuchsia that expect to use it for linking. --- src/bootstrap/compile.rs | 2 +- src/bootstrap/dist.rs | 2 +- src/bootstrap/lib.rs | 6 ++++++ src/bootstrap/native.rs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 06ab0a9c310af..90e8f23c46e00 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -733,7 +733,7 @@ impl Step for Assemble { // when not performing a full bootstrap). builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host }); - let lld_install = if builder.config.lld_enabled { + let lld_install = if builder.lld_enabled(target_compiler.host) { Some(builder.ensure(native::Lld { target: target_compiler.host })) } else { None diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 8215211ea1c9d..534007265b34f 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -519,7 +519,7 @@ impl Step for Rustc { maybe_install_llvm_dylib(builder, host, image); // Copy over lld if it's there - if builder.config.lld_enabled { + if builder.lld_enabled(compiler.host) { let exe = exe("rust-lld", &compiler.host); let src = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin").join(&exe); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 31bbd92cd6205..27cb9ce5a588a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -561,6 +561,12 @@ impl Build { self.out.join(&*target).join("lld") } + fn lld_enabled(&self, target: Interned) -> bool { + // LLD does not currently cross compile correctly, so build it only for + // the native toolchain: + self.config.lld_enabled && self.config.build == target + } + /// Output directory for all documentation for a target fn doc_out(&self, target: Interned) -> PathBuf { self.out.join(&*target).join("doc") diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 0c87695ff7cae..c5f02815cf414 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -440,7 +440,7 @@ impl Step for Lld { run.builder.ensure(Lld { target: run.target }); } - /// Compile LLVM for `target`. + /// Compile LLD for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { if builder.config.dry_run { return PathBuf::from("lld-out-dir-test-gen");