diff options
Diffstat (limited to 'community/rust/musl-support-dynamic-linking.patch')
| -rw-r--r-- | community/rust/musl-support-dynamic-linking.patch | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/community/rust/musl-support-dynamic-linking.patch b/community/rust/musl-support-dynamic-linking.patch index efbbd7f0b0..c6441272bb 100644 --- a/community/rust/musl-support-dynamic-linking.patch +++ b/community/rust/musl-support-dynamic-linking.patch @@ -16,18 +16,16 @@ diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 90fd31ecbd..28520a2c60 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs -@@ -205,6 +205,17 @@ fn main() { +@@ -205,6 +205,15 @@ fn main() { } } } + + if let Ok(s) = env::var("RUST_CRT_STATIC") { + if s == "true" { -+ cmd.arg("-Z").arg("unstable-options"); + cmd.arg("-C").arg("target-feature=+crt-static"); + } + if s == "false" { -+ cmd.arg("-Z").arg("unstable-options"); + cmd.arg("-C").arg("target-feature=-crt-static"); + } + } @@ -38,14 +36,21 @@ diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7c35151a6d..c83b6cc24c 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs -@@ -94,14 +94,17 @@ pub fn std_link(build: &Build, - t!(fs::create_dir_all(&libdir)); - add_to_sysroot(&out_dir, &libdir); +@@ -94,21 +94,24 @@ pub fn std_link(build: &Build, + let libdir = build.sysroot_libdir(target_compiler, target); + add_to_sysroot(&libdir, &libstd_stamp(build, compiler, target)); - if target.contains("musl") && !target.contains("mips") { + if target.contains("musl") { copy_musl_third_party_objects(build, target, &libdir); } + + if build.config.sanitizers && compiler.stage != 0 && target == "x86_64-apple-darwin" { + // The sanitizers are only built in stage1 or above, so the dylibs will + // be missing in stage0 and causes panic. See the `std()` function above + // for reason why the sanitizers are not built in stage0. + copy_apple_sanitizer_dylibs(&build.native_dir(target), "osx", &libdir); + } } /// Copies the crt(1,i,n).o startup objects @@ -144,22 +149,12 @@ diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 36a887e062..1075e4f0cf 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs -@@ -34,6 +34,7 @@ use syntax::parse::ParseSess; - use syntax::symbol::Symbol; - use syntax::{ast, codemap}; - use syntax::feature_gate::AttributeType; -+use syntax::feature_gate::UnstableFeatures; - use syntax_pos::{Span, MultiSpan}; - - use rustc_back::PanicStrategy; -@@ -380,6 +381,34 @@ impl Session { +@@ -380,6 +381,24 @@ impl Session { self.opts.debugging_opts.enable_nonzeroing_move_hints } + pub fn crt_static(&self) -> bool { + let requested_features = self.opts.cg.target_feature.split(','); -+ let unstable_options = self.opts.debugging_opts.unstable_options; -+ let is_nightly = UnstableFeatures::from_environment().is_nightly_build(); + let found_negative = requested_features.clone().any(|r| r == "-crt-static"); + let found_positive = requested_features.clone().any(|r| r == "+crt-static"); + @@ -173,14 +168,6 @@ index 36a887e062..1075e4f0cf 100644 + found_positive + }; + -+ // If we switched from the default then that's only allowed on nightly, so -+ // gate that here. -+ if (found_positive || found_negative) && (!is_nightly || !unstable_options) { -+ self.fatal("specifying the `crt-static` target feature is only allowed \ -+ on the nightly channel with `-Z unstable-options` passed \ -+ as well"); -+ } -+ + return crt_static; + } + @@ -235,21 +222,11 @@ diff --git a/src/librustc_driver/target_features.rs b/src/librustc_driver/target index 124e7aafcc..492ceecaf1 100644 --- a/src/librustc_driver/target_features.rs +++ b/src/librustc_driver/target_features.rs -@@ -12,7 +12,6 @@ use syntax::ast; - use llvm::LLVMRustHasFeature; - use rustc::session::Session; - use rustc_trans::back::write::create_target_machine; --use syntax::feature_gate::UnstableFeatures; - use syntax::symbol::Symbol; - use libc::c_char; - -@@ -49,31 +48,7 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) { - } +@@ -25,21 +25,7 @@ pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) { + cfg.insert((tf, Some(feat))); } - let requested_features = sess.opts.cg.target_feature.split(','); -- let unstable_options = sess.opts.debugging_opts.unstable_options; -- let is_nightly = UnstableFeatures::from_environment().is_nightly_build(); - let found_negative = requested_features.clone().any(|r| r == "-crt-static"); - let found_positive = requested_features.clone().any(|r| r == "+crt-static"); - @@ -263,14 +240,6 @@ index 124e7aafcc..492ceecaf1 100644 - found_positive - }; - -- // If we switched from the default then that's only allowed on nightly, so -- // gate that here. -- if (found_positive || found_negative) && (!is_nightly || !unstable_options) { -- sess.fatal("specifying the `crt-static` target feature is only allowed \ -- on the nightly channel with `-Z unstable-options` passed \ -- as well"); -- } -- - if crt_static { + if sess.crt_static() { cfg.insert((tf, Some(Symbol::intern("crt-static")))); |
