]> git.lizzy.rs Git - rust.git/commitdiff
Use lld directly for Fuchsia target
authorPetr Hosek <phosek@google.com>
Tue, 16 Oct 2018 00:27:07 +0000 (17:27 -0700)
committerPetr Hosek <phosek@google.com>
Mon, 5 Nov 2018 23:46:00 +0000 (15:46 -0800)
Fuchsia already uses lld as the default linker, so there's no reason
to always invoke it through Clang, instead we can simply invoke lld
directly and pass the set of flags that matches Clang.

src/bootstrap/bin/rustc.rs
src/bootstrap/configure.py
src/bootstrap/lib.rs
src/ci/docker/dist-various-2/Dockerfile
src/librustc_target/spec/aarch64_fuchsia.rs
src/librustc_target/spec/fuchsia_base.rs
src/librustc_target/spec/x86_64_fuchsia.rs

index b6764c1aaeab6a22c3ef8af857c626b01529a601..a97c88336e427d9f185da49607736c45685c23f5 100644 (file)
@@ -232,7 +232,9 @@ fn main() {
                 // flesh out rpath support more fully in the future.
                 cmd.arg("-Z").arg("osx-rpath-install-name");
                 Some("-Wl,-rpath,@loader_path/../lib")
-            } else if !target.contains("windows") && !target.contains("wasm32") {
+            } else if !target.contains("windows") &&
+                      !target.contains("wasm32") &&
+                      !target.contains("fuchsia") {
                 Some("-Wl,-rpath,$ORIGIN/../lib")
             } else {
                 None
index ddb894eb1f6597be1c166cdb6d8176e8804121c1..58525d0fc1a92ad06c24def1d19c8baea30745b3 100755 (executable)
@@ -68,6 +68,7 @@ o("cargo-native-static", "build.cargo-native-static", "static native libraries i
 o("profiler", "build.profiler", "build the profiler runtime")
 o("emscripten", None, "compile the emscripten backend as well as LLVM")
 o("full-tools", None, "enable all tools")
+o("lld", "rust.lld", "build lld")
 o("lldb", "rust.lldb", "build lldb")
 o("missing-tools", "dist.missing-tools", "allow failures when building tools")
 
index ba601249ea895fb7f43afd08322d06270f111288..ea9d5bf3fa05c7ae8b0d863ec9c7bb4ed116ff9b 100644 (file)
@@ -843,7 +843,8 @@ fn linker(&self, target: Interned<String>) -> Option<&Path> {
         } else if target != self.config.build &&
                   !target.contains("msvc") &&
                   !target.contains("emscripten") &&
-                  !target.contains("wasm32") {
+                  !target.contains("wasm32") &&
+                  !target.contains("fuchsia") {
             Some(self.cc(target))
         } else {
             None
index 7adb32efa1d414ef8daa1f1030fd7d92bcd51f24..944c2a51b8d1fb4c1939328438cd96df4e498091 100644 (file)
@@ -47,6 +47,17 @@ ENV \
     CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
     CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++
 
+ENV CARGO_TARGET_X86_64_FUCHSIA_AR /usr/local/bin/llvm-ar
+ENV CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS \
+-C link-arg=--sysroot=/usr/local/x86_64-fuchsia \
+-C link-arg=-L/usr/local/x86_64-fuchsia/lib \
+-C link-arg=-L/usr/local/lib/x86_64-fuchsia/lib
+ENV CARGO_TARGET_AARCH64_FUCHSIA_AR /usr/local/bin/llvm-ar
+ENV CARGO_TARGET_AARCH64_FUCHSIA_RUSTFLAGS \
+-C link-arg=--sysroot=/usr/local/aarch64-fuchsia \
+-C link-arg=-L/usr/local/aarch64-fuchsia/lib \
+-C link-arg=-L/usr/local/lib/aarch64-fuchsia/lib
+
 ENV TARGETS=x86_64-fuchsia
 ENV TARGETS=$TARGETS,aarch64-fuchsia
 ENV TARGETS=$TARGETS,sparcv9-sun-solaris
@@ -55,5 +66,5 @@ ENV TARGETS=$TARGETS,x86_64-sun-solaris
 ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
 ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi
 
-ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
+ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs
 ENV SCRIPT python2.7 ../x.py dist --target $TARGETS
index 8f7ee11d575eee8412d08292704091a715149ad2..9ef4fe3b3af4b4d380f20f9d6ea3fe8d5c2b701a 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use spec::{LldFlavor, LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::fuchsia_base::opts();
@@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
         target_os: "fuchsia".to_string(),
         target_env: String::new(),
         target_vendor: String::new(),
-        linker_flavor: LinkerFlavor::Gcc,
+        linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
         options: TargetOptions {
             abi_blacklist: super::arm_base::abi_blacklist(),
             .. base
index b593b83532614b4801a0f9ecc8755aafb36d0588..8c20755492e31569f67b086d12e69839e2949fbb 100644 (file)
@@ -8,27 +8,19 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use spec::{LldFlavor, LinkArgs, LinkerFlavor, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
     let mut args = LinkArgs::new();
-    args.insert(LinkerFlavor::Gcc, vec![
-        // We want to be able to strip as much executable code as possible
-        // from the linker command line, and this flag indicates to the
-        // linker that it can avoid linking in dynamic libraries that don't
-        // actually satisfy any symbols up to that point (as with many other
-        // resolutions the linker does). This option only applies to all
-        // following libraries so we're sure to pass it as one of the first
-        // arguments.
-        // FIXME: figure out whether these linker args are desirable
-        //"-Wl,--as-needed".to_string(),
-
-        // Always enable NX protection when it is available
-        //"-Wl,-z,noexecstack".to_string(),
+    args.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec![
+        "--build-id".to_string(), "--hash-style=gnu".to_string(),
+        "-z".to_string(), "rodynamic".to_string(),
     ]);
 
     TargetOptions {
+        linker: Some("rust-lld".to_owned()),
+        lld_flavor: LldFlavor::Ld,
         dynamic_linking: true,
         executables: true,
         target_family: Some("unix".to_string()),
index 62148a740dff56833b1495b1f823d7652c429d96..08df78d0db05d906e231941176b10e3ed6248da6 100644 (file)
@@ -8,13 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use spec::{LinkerFlavor, Target, TargetResult};
+use spec::{LldFlavor, LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::fuchsia_base::opts();
     base.cpu = "x86-64".to_string();
     base.max_atomic_width = Some(64);
-    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
     base.stack_probes = true;
 
     Ok(Target {
@@ -27,7 +26,7 @@ pub fn target() -> TargetResult {
         target_os: "fuchsia".to_string(),
         target_env: String::new(),
         target_vendor: String::new(),
-        linker_flavor: LinkerFlavor::Gcc,
+        linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
         options: base,
     })
 }