about summary refs log tree commit diff
path: root/src/librustc_back
diff options
context:
space:
mode:
authorMarco A L Barbosa <malbarbo@gmail.com>2018-01-12 21:22:06 -0200
committerMarco A L Barbosa <malbarbo@gmail.com>2018-01-22 16:14:51 -0200
commit68db72d8cd613f88ea69d37bcd159c4ff659aab1 (patch)
tree051cbd9f58fa05e54443ba553f1de9f720fdf6ba /src/librustc_back
parentfdc18b3067b5bad257ccbe7400e3c4fb617e9e18 (diff)
downloadrust-68db72d8cd613f88ea69d37bcd159c4ff659aab1.tar.gz
rust-68db72d8cd613f88ea69d37bcd159c4ff659aab1.zip
Do not assume dynamic linking for musl/mips[el] targets
All musl targets except mips[el] assume static linking by default. This
can be confusing
https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084

When the musl/mips[el] targets was
[added](https://github.com/rust-lang/rust/pull/31298), dynamic linking
was chosen because of binary size concerns, and probably also because
libunwind
[didn't](https://users.rust-lang.org/t/static-cross-compiled-binaries-arent-really-static/6084/8)
supported mips.

Now that we have `crt-static` target-feature (the user can choose
dynamic link for musl targets), and libunwind
[6.0](https://github.com/llvm-mirror/libunwind/commits/release_60) add
support to mips, we do not need to assume dynamic linking.
Diffstat (limited to 'src/librustc_back')
-rw-r--r--src/librustc_back/target/mips_unknown_linux_musl.rs19
-rw-r--r--src/librustc_back/target/mipsel_unknown_linux_musl.rs19
2 files changed, 16 insertions, 22 deletions
diff --git a/src/librustc_back/target/mips_unknown_linux_musl.rs b/src/librustc_back/target/mips_unknown_linux_musl.rs
index 3f6b984272e..e1a3de34d01 100644
--- a/src/librustc_back/target/mips_unknown_linux_musl.rs
+++ b/src/librustc_back/target/mips_unknown_linux_musl.rs
@@ -9,9 +9,15 @@
 // except according to those terms.
 
 use LinkerFlavor;
-use target::{Target, TargetOptions, TargetResult};
+use target::{Target, TargetResult};
 
 pub fn target() -> TargetResult {
+    let mut base = super::linux_musl_base::opts();
+    base.cpu = "mips32r2".to_string();
+    base.features = "+mips32r2,+soft-float".to_string();
+    base.max_atomic_width = Some(32);
+    // see #36994
+    base.exe_allocation_crate = None;
     Ok(Target {
         llvm_target: "mips-unknown-linux-musl".to_string(),
         target_endian: "big".to_string(),
@@ -23,15 +29,6 @@ pub fn target() -> TargetResult {
         target_env: "musl".to_string(),
         target_vendor: "unknown".to_string(),
         linker_flavor: LinkerFlavor::Gcc,
-        options: TargetOptions {
-            cpu: "mips32r2".to_string(),
-            features: "+mips32r2,+soft-float".to_string(),
-            max_atomic_width: Some(32),
-
-            // see #36994
-            exe_allocation_crate: None,
-
-            ..super::linux_base::opts()
-        }
+        options: base,
     })
 }
diff --git a/src/librustc_back/target/mipsel_unknown_linux_musl.rs b/src/librustc_back/target/mipsel_unknown_linux_musl.rs
index 464f0bfe480..08c16af70d3 100644
--- a/src/librustc_back/target/mipsel_unknown_linux_musl.rs
+++ b/src/librustc_back/target/mipsel_unknown_linux_musl.rs
@@ -9,9 +9,15 @@
 // except according to those terms.
 
 use LinkerFlavor;
-use target::{Target, TargetOptions, TargetResult};
+use target::{Target, TargetResult};
 
 pub fn target() -> TargetResult {
+    let mut base = super::linux_musl_base::opts();
+    base.cpu = "mips32".to_string();
+    base.features = "+mips32,+soft-float".to_string();
+    base.max_atomic_width = Some(32);
+    // see #36994
+    base.exe_allocation_crate = None;
     Ok(Target {
         llvm_target: "mipsel-unknown-linux-musl".to_string(),
         target_endian: "little".to_string(),
@@ -23,15 +29,6 @@ pub fn target() -> TargetResult {
         target_env: "musl".to_string(),
         target_vendor: "unknown".to_string(),
         linker_flavor: LinkerFlavor::Gcc,
-        options: TargetOptions {
-            cpu: "mips32".to_string(),
-            features: "+mips32,+soft-float".to_string(),
-            max_atomic_width: Some(32),
-
-            // see #36994
-            exe_allocation_crate: None,
-
-            ..super::linux_base::opts()
-        }
+        options: base,
     })
 }