summaryrefslogtreecommitdiff
path: root/user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch')
-rw-r--r--user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch204
1 files changed, 74 insertions, 130 deletions
diff --git a/user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch b/user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
index 4c0a8dee0..6053de26b 100644
--- a/user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
+++ b/user/rust/0005-Remove-nostdlib-and-musl_root-from-musl-targets.patch
@@ -1,28 +1,28 @@
-From c822b31f554ed2f930be8625973a401fd438c123 Mon Sep 17 00:00:00 2001
+From 5d98731bae319172c5fbfd8235f62bb00acb3a7d Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Fri, 8 Sep 2017 22:11:14 -0500
-Subject: [PATCH 05/23] Remove -nostdlib and musl_root from musl targets
+Subject: [PATCH 05/14] Remove -nostdlib and musl_root from musl targets
---
- config.toml.example | 6 ---
- src/bootstrap/bin/rustc.rs | 10 -----
- src/bootstrap/cc_detect.rs | 27 ++----------
- src/bootstrap/compile.rs | 31 --------------
- src/bootstrap/config.rs | 7 ----
- src/bootstrap/configure.py | 22 ----------
- src/bootstrap/lib.rs | 8 ----
- src/bootstrap/sanity.rs | 30 +-------------
- .../dist-i586-gnu-i586-i686-musl/Dockerfile | 2 -
- src/ci/docker/dist-various-1/Dockerfile | 7 ----
+ config.toml.example | 6 ----
+ src/bootstrap/bin/rustc.rs | 12 --------
+ src/bootstrap/cc_detect.rs | 27 ++----------------
+ src/bootstrap/compile.rs | 21 --------------
+ src/bootstrap/config.rs | 7 -----
+ src/bootstrap/configure.py | 22 ---------------
+ src/bootstrap/lib.rs | 8 ------
+ src/bootstrap/sanity.rs | 28 -------------------
+ .../dist-i586-gnu-i586-i686-musl/Dockerfile | 2 --
+ src/ci/docker/dist-various-1/Dockerfile | 7 -----
src/ci/docker/dist-x86_64-musl/Dockerfile | 1 -
- src/librustc_target/spec/linux_musl_base.rs | 41 -------------------
- 12 files changed, 4 insertions(+), 188 deletions(-)
+ src/librustc_target/spec/linux_musl_base.rs | 16 -----------
+ 12 files changed, 3 insertions(+), 154 deletions(-)
diff --git a/config.toml.example b/config.toml.example
-index e8cb0cba6b..1971fea758 100644
+index 23943d34b7..5eace54c6b 100644
--- a/config.toml.example
+++ b/config.toml.example
-@@ -452,12 +452,6 @@
+@@ -461,12 +461,6 @@
# only use static libraries. If unset, the target's default linkage is used.
#crt-static = false
@@ -36,10 +36,10 @@ index e8cb0cba6b..1971fea758 100644
# probably don't want to use this.
#qemu-rootfs = "..."
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
-index b6764c1aae..6fa60bd9a5 100644
+index a0c75cd9e9..f8daab9bd1 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
-@@ -30,7 +30,6 @@
+@@ -20,7 +20,6 @@
extern crate bootstrap;
use std::env;
@@ -47,27 +47,29 @@ index b6764c1aae..6fa60bd9a5 100644
use std::io;
use std::path::PathBuf;
use std::process::Command;
-@@ -126,15 +125,6 @@ fn main() {
+@@ -116,17 +115,6 @@ fn main() {
cmd.arg("-Cprefer-dynamic");
}
- // Help the libc crate compile by assisting it in finding the MUSL
- // native libraries.
- if let Some(s) = env::var_os("MUSL_ROOT") {
-- let mut root = OsString::from("native=");
-- root.push(&s);
-- root.push("/lib");
-- cmd.arg("-L").arg(&root);
+- if target.contains("musl") {
+- let mut root = OsString::from("native=");
+- root.push(&s);
+- root.push("/lib");
+- cmd.arg("-L").arg(&root);
+- }
- }
-
// Override linker if necessary.
if let Ok(target_linker) = env::var("RUSTC_TARGET_LINKER") {
cmd.arg(format!("-Clinker={}", target_linker));
diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs
-index d5da0cabec..47cc31bded 100644
+index 37844759c7..fa553c0b06 100644
--- a/src/bootstrap/cc_detect.rs
+++ b/src/bootstrap/cc_detect.rs
-@@ -95,7 +95,7 @@ pub fn find(build: &mut Build) {
+@@ -85,7 +85,7 @@ pub fn find(build: &mut Build) {
if let Some(cc) = config.and_then(|c| c.cc.as_ref()) {
cfg.compiler(cc);
} else {
@@ -76,7 +78,7 @@ index d5da0cabec..47cc31bded 100644
}
let compiler = cfg.get_compiler();
-@@ -124,7 +124,7 @@ pub fn find(build: &mut Build) {
+@@ -114,7 +114,7 @@ pub fn find(build: &mut Build) {
if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
cfg.compiler(cxx);
} else {
@@ -85,7 +87,7 @@ index d5da0cabec..47cc31bded 100644
}
let compiler = cfg.get_compiler();
build.verbose(&format!("CXX_{} = {:?}", host, compiler.path()));
-@@ -135,8 +135,7 @@ pub fn find(build: &mut Build) {
+@@ -125,8 +125,7 @@ pub fn find(build: &mut Build) {
fn set_compiler(cfg: &mut cc::Build,
compiler: Language,
target: Interned<String>,
@@ -95,7 +97,7 @@ index d5da0cabec..47cc31bded 100644
match &*target {
// When compiling for android we may have the NDK configured in the
// config.toml in which case we look there. Otherwise the default
-@@ -173,26 +172,6 @@ fn set_compiler(cfg: &mut cc::Build,
+@@ -166,26 +165,6 @@ fn set_compiler(cfg: &mut cc::Build,
}
}
@@ -123,60 +125,36 @@ index d5da0cabec..47cc31bded 100644
}
}
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
-index 69d45acded..7bb38ac7ec 100644
+index b581271663..21421b2e38 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
-@@ -86,13 +86,6 @@ impl Step for Std {
- });
- builder.info(&format!("Uplifting stage1 std ({} -> {})", from.host, target));
-
-- // Even if we're not building std this stage, the new sysroot must
-- // still contain the musl startup objects.
-- if target.contains("musl") {
-- let libdir = builder.sysroot_libdir(compiler, target);
-- copy_musl_third_party_objects(builder, target, &libdir);
-- }
--
- builder.ensure(StdLink {
- compiler: from,
- target_compiler: compiler,
-@@ -101,11 +94,6 @@ impl Step for Std {
- return;
- }
+@@ -114,21 +114,6 @@ impl Step for Std {
+ fn copy_third_party_objects(builder: &Builder, compiler: &Compiler, target: Interned<String>) {
+ let libdir = builder.sysroot_libdir(*compiler, target);
-- if target.contains("musl") {
-- let libdir = builder.sysroot_libdir(compiler, target);
-- copy_musl_third_party_objects(builder, target, &libdir);
+- // Copies the crt(1,i,n).o startup objects
+- //
+- // Since musl supports fully static linking, we can cross link for it even
+- // with a glibc-targeting toolchain, given we have the appropriate startup
+- // files. As those shipped with glibc won't work, copy the ones provided by
+- // musl so we have them on linux-gnu hosts.
+- if target.contains("musl") {
+- for &obj in &["crt1.o", "crti.o", "crtn.o"] {
+- builder.copy(
+- &builder.musl_root(target).unwrap().join("lib").join(obj),
+- &libdir.join(obj),
+- );
- }
--
- let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
- std_cargo(builder, &compiler, target, &mut cargo);
-
-@@ -126,20 +114,6 @@ impl Step for Std {
- }
- }
-
--/// Copies the crt(1,i,n).o startup objects
--///
--/// Since musl supports fully static linking, we can cross link for it even
--/// with a glibc-targeting toolchain, given we have the appropriate startup
--/// files. As those shipped with glibc won't work, copy the ones provided by
--/// musl so we have them on linux-gnu hosts.
--fn copy_musl_third_party_objects(builder: &Builder,
-- target: Interned<String>,
-- into: &Path) {
-- for &obj in &["crt1.o", "crti.o", "crtn.o"] {
-- builder.copy(&builder.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj));
- }
--}
-
- /// Configure cargo to compile the standard library, adding appropriate env vars
- /// and such.
- pub fn std_cargo(builder: &Builder,
-@@ -193,11 +167,6 @@ pub fn std_cargo(builder: &Builder,
- cargo.env("JEMALLOC_OVERRIDE", jemalloc);
- }
- }
+ // Copies libunwind.a compiled to be linked wit x86_64-fortanix-unknown-sgx.
+ //
+ // This target needs to be linked to Fortanix's port of llvm's libunwind.
+@@ -182,12 +167,6 @@ pub fn std_cargo(builder: &Builder,
+ cargo.arg("--features").arg(features)
+ .arg("--manifest-path")
+ .arg(builder.src.join("src/libstd/Cargo.toml"));
+-
- if target.contains("musl") {
- if let Some(p) = builder.musl_root(target) {
- cargo.env("MUSL_ROOT", p);
@@ -186,10 +164,10 @@ index 69d45acded..7bb38ac7ec 100644
}
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
-index a9d330e06a..745785a8ae 100644
+index 9421817ae6..cd70c1a1e4 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
-@@ -136,8 +136,6 @@ pub struct Config {
+@@ -128,8 +128,6 @@ pub struct Config {
pub print_step_timings: bool,
pub missing_tools: bool,
@@ -198,7 +176,7 @@ index a9d330e06a..745785a8ae 100644
pub prefix: Option<PathBuf>,
pub sysconfdir: Option<PathBuf>,
pub datadir: Option<PathBuf>,
-@@ -173,7 +171,6 @@ pub struct Target {
+@@ -164,7 +162,6 @@ pub struct Target {
pub linker: Option<PathBuf>,
pub ndk: Option<PathBuf>,
pub crt_static: Option<bool>,
@@ -206,7 +184,7 @@ index a9d330e06a..745785a8ae 100644
pub qemu_rootfs: Option<PathBuf>,
pub no_std: bool,
}
-@@ -305,7 +302,6 @@ struct Rust {
+@@ -296,7 +293,6 @@ struct Rust {
backtrace: Option<bool>,
default_linker: Option<String>,
channel: Option<String>,
@@ -214,7 +192,7 @@ index a9d330e06a..745785a8ae 100644
rpath: Option<bool>,
optimize_tests: Option<bool>,
debuginfo_tests: Option<bool>,
-@@ -343,7 +339,6 @@ struct TomlTarget {
+@@ -335,7 +331,6 @@ struct TomlTarget {
linker: Option<String>,
android_ndk: Option<String>,
crt_static: Option<bool>,
@@ -222,7 +200,7 @@ index a9d330e06a..745785a8ae 100644
qemu_rootfs: Option<String>,
}
-@@ -560,7 +555,6 @@ impl Config {
+@@ -549,7 +544,6 @@ impl Config {
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
config.rustc_default_linker = rust.default_linker.clone();
@@ -230,7 +208,7 @@ index a9d330e06a..745785a8ae 100644
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
-@@ -604,7 +598,6 @@ impl Config {
+@@ -592,7 +586,6 @@ impl Config {
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
target.linker = cfg.linker.clone().map(PathBuf::from);
target.crt_static = cfg.crt_static.clone();
@@ -239,10 +217,10 @@ index a9d330e06a..745785a8ae 100644
config.target_config.insert(INTERNER.intern_string(triple.clone()), target);
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
-index 0cf84a6298..4845e93a0e 100755
+index b0c3c97024..5128897bf7 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
-@@ -112,28 +112,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
+@@ -105,28 +105,6 @@ v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk",
"aarch64-linux-android NDK standalone path")
v("x86_64-linux-android-ndk", "target.x86_64-linux-android.android-ndk",
"x86_64-linux-android NDK standalone path")
@@ -272,10 +250,10 @@ index 0cf84a6298..4845e93a0e 100755
"rootfs in qemu testing, you probably don't want to use this")
v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs",
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
-index 30e84bc13f..cf6f410ccb 100644
+index 74c04bac6b..aa91600ea7 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
-@@ -861,14 +861,6 @@ impl Build {
+@@ -849,14 +849,6 @@ impl Build {
}
}
@@ -291,19 +269,10 @@ index 30e84bc13f..cf6f410ccb 100644
fn no_std(&self, target: Interned<String>) -> Option<bool> {
self.config.target_config.get(&target)
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
-index 724cb5841f..5af34e441c 100644
+index fe547a6b15..a452c874c4 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
-@@ -21,7 +21,7 @@
- use std::collections::HashMap;
- use std::env;
- use std::ffi::{OsString, OsStr};
--use std::fs::{self, File};
-+use std::fs::File;
- use std::io::Read;
- use std::path::PathBuf;
- use std::process::Command;
-@@ -186,34 +186,6 @@ pub fn check(build: &mut Build) {
+@@ -169,34 +169,6 @@ pub fn check(build: &mut Build) {
}
}
@@ -352,12 +321,12 @@ index ba2d32a929..412c37fdd1 100644
--disable-docs
diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile
-index e2484b7224..1855b7f3e5 100644
+index ab2dd5a399..a9569fe6d4 100644
--- a/src/ci/docker/dist-various-1/Dockerfile
+++ b/src/ci/docker/dist-various-1/Dockerfile
-@@ -116,13 +116,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
- CC_armebv7r_none_eabi=arm-none-eabi-gcc
-
+@@ -128,13 +128,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
+ CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
+
ENV RUST_CONFIGURE_ARGS \
- --musl-root-armv5te=/musl-armv5te \
- --musl-root-arm=/musl-arm \
@@ -382,10 +351,10 @@ index 06f8a2fbba..f5dd379528 100644
--disable-docs
diff --git a/src/librustc_target/spec/linux_musl_base.rs b/src/librustc_target/spec/linux_musl_base.rs
-index 7a3f3c2a51..32fe2f880a 100644
+index 1bc90d1a73..e26a5240a6 100644
--- a/src/librustc_target/spec/linux_musl_base.rs
+++ b/src/librustc_target/spec/linux_musl_base.rs
-@@ -13,53 +13,12 @@ use spec::{LinkerFlavor, TargetOptions};
+@@ -3,28 +3,12 @@ use spec::{LinkerFlavor, TargetOptions};
pub fn opts() -> TargetOptions {
let mut base = super::linux_base::opts();
@@ -400,31 +369,6 @@ index 7a3f3c2a51..32fe2f880a 100644
// argument is *not* necessary for normal builds, but it can't hurt!
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
-- // There's a whole bunch of circular dependencies when dealing with MUSL
-- // unfortunately. To put this in perspective libc is statically linked to
-- // liblibc and libunwind is statically linked to libstd:
-- //
-- // * libcore depends on `fmod` which is in libc (transitively in liblibc).
-- // liblibc, however, depends on libcore.
-- // * compiler-rt has personality symbols that depend on libunwind, but
-- // libunwind is in libstd which depends on compiler-rt.
-- //
-- // Recall that linkers discard libraries and object files as much as
-- // possible, and with all the static linking and archives flying around with
-- // MUSL the linker is super aggressively stripping out objects. For example
-- // the first case has fmod stripped from liblibc (it's in its own object
-- // file) so it's not there when libcore needs it. In the second example all
-- // the unused symbols from libunwind are stripped (each is in its own object
-- // file in libstd) before we end up linking compiler-rt which depends on
-- // those symbols.
-- //
-- // To deal with these circular dependencies we just force the compiler to
-- // link everything as a group, not stripping anything out until everything
-- // is processed. The linker will still perform a pass to strip out object
-- // files but it won't do so until all objects/archives have been processed.
-- base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-(".to_string());
-- base.post_link_args.insert(LinkerFlavor::Gcc, vec!["-Wl,-)".to_string()]);
--
- // When generating a statically linked executable there's generally some
- // small setup needed which is listed in these files. These are provided by
- // a musl toolchain and are linked by default by the `musl-gcc` script. Note
@@ -440,5 +384,5 @@ index 7a3f3c2a51..32fe2f880a 100644
base.crt_static_default = true;
// These targets allow the user to choose between static and dynamic linking.
--
-2.19.2
+2.21.0