diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 8325b1d2a27ac..cb3c794c212f2 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -206,31 +206,35 @@ fn main() { // Cargo will be very different than the runtime directory structure. // // All that's a really long winded way of saying that if we use - // `-Crpath` then the executables generated have the wrong rpath of + // `-C rpath` then the executables generated have the wrong rpath of // something like `$ORIGIN/deps` when in fact the way we distribute // rustc requires the rpath to be `$ORIGIN/../lib`. // // So, all in all, to set up the correct rpath we pass the linker - // argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it + // argument manually via `-C link-args=-rpath,...`. Plus isn't it // fun to pass a flag to a tool to pass a flag to pass a flag to a tool // to change a flag in a binary? if env::var("RUSTC_RPATH") == Ok("true".to_string()) { - let rpath = if target.contains("apple") { - + let rpath_flags = if target.contains("apple") { // Note that we need to take one extra step on macOS to also pass - // `-Wl,-instal_name,@rpath/...` to get things to work right. To + // `-install_name,@rpath/...` to get things to work right. To // do that we pass a weird flag to the compiler to get it to do // so. Note that this is definitely a hack, and we should likely // flesh out rpath support more fully in the future. cmd.arg("-Z").arg("osx-rpath-install-name"); - Some("-Wl,-rpath,@loader_path/../lib") + Some(&["-rpath", "@loader_path/../lib"]) } else if !target.contains("windows") { - Some("-Wl,-rpath,$ORIGIN/../lib") + Some(&["-rpath", "$ORIGIN/../lib"]) } else { None }; - if let Some(rpath) = rpath { - cmd.arg("-C").arg(format!("link-args={}", rpath)); + if let Some(rpath_flags) = rpath_flags { + for rpath_flag in rpath_flags { + if stage == "0" { + cmd.arg("-C").arg("link-arg=-Xlinker"); + } + cmd.arg("-C").arg(format!("link-arg={}", rpath_flag)); + } } } diff --git a/src/librustc_back/target/aarch64_apple_ios.rs b/src/librustc_back/target/aarch64_apple_ios.rs index cff6eb534b1e5..152f73d518abc 100644 --- a/src/librustc_back/target/aarch64_apple_ios.rs +++ b/src/librustc_back/target/aarch64_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_os: "ios".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: TargetOptions { features: "+neon,+fp-armv8,+cyclone".to_string(), eliminate_frame_pointer: false, diff --git a/src/librustc_back/target/apple_base.rs b/src/librustc_back/target/apple_base.rs index 159f93a74c683..ed6a46e56718f 100644 --- a/src/librustc_back/target/apple_base.rs +++ b/src/librustc_back/target/apple_base.rs @@ -9,8 +9,43 @@ // except according to those terms. use std::env; +use std::io; +use std::process::Command; +use std::str; -use target::{LinkArgs, TargetOptions}; +use target::TargetOptions; + +pub fn xcrun(print_arg: &str, sdk_name: &str) -> io::Result { + Command::new("xcrun").arg(print_arg).arg("--sdk").arg(sdk_name).output().and_then(|output| { + if output.status.success() { + Ok(str::from_utf8(&output.stdout[..]).unwrap().trim().to_string()) + } else { + let error = format!( + "process exit with error: {}", + str::from_utf8(&output.stderr[..]).unwrap(), + ); + Err(io::Error::new(io::ErrorKind::Other, &error[..])) + } + }) +} + +pub fn get_sdk_root(sdk_name: &str) -> Result { + xcrun("--show-sdk-path", sdk_name).map_err(|e| { + format!("failed to get {} SDK path: {}", sdk_name, e) + }) +} + +pub fn get_sdk_version(sdk_name: &str) -> Result { + xcrun("--show-sdk-version", sdk_name).map_err(|e| { + format!("failed to get {} SDK version: {}", sdk_name, e) + }) +} + +pub fn get_deployment_target() -> String { + env::var("MACOSX_DEPLOYMENT_TARGET").or_else(|_e| { + get_sdk_version("macosx") + }).unwrap_or("10.7".to_string()) +} pub fn opts() -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 @@ -22,15 +57,11 @@ pub fn opts() -> TargetOptions { // MACOSX_DEPLOYMENT_TARGET set to 10.6 will cause the linker to generate // warnings about the usage of ELF TLS. // - // Here we detect what version is being requested, defaulting to 10.7. ELF - // TLS is flagged as enabled if it looks to be supported. - let deployment_target = env::var("MACOSX_DEPLOYMENT_TARGET").ok(); - let version = deployment_target.as_ref().and_then(|s| { - let mut i = s.splitn(2, "."); - i.next().and_then(|a| i.next().map(|b| (a, b))) - }).and_then(|(a, b)| { - a.parse::().and_then(|a| b.parse::().map(|b| (a, b))).ok() - }).unwrap_or((10, 7)); + // Here we detect what version is being requested. ELF TLS is flagged as + // enabled if it looks to be supported. + let deployment_target = get_deployment_target(); + let mut i = deployment_target.splitn(2, '.').map(|s| s.parse::().unwrap()); + let version = (i.next().unwrap(), i.next().unwrap()); TargetOptions { // macOS has -dead_strip, which doesn't rely on function_sections @@ -43,9 +74,9 @@ pub fn opts() -> TargetOptions { dll_prefix: "lib".to_string(), dll_suffix: ".dylib".to_string(), archive_format: "bsd".to_string(), - pre_link_args: LinkArgs::new(), exe_allocation_crate: super::maybe_jemalloc(), has_elf_tls: version >= (10, 7), + linker: "ld".to_string(), .. Default::default() } } diff --git a/src/librustc_back/target/apple_ios_base.rs b/src/librustc_back/target/apple_ios_base.rs index 4b02d0b60b8b5..30b4ba39fcdea 100644 --- a/src/librustc_back/target/apple_ios_base.rs +++ b/src/librustc_back/target/apple_ios_base.rs @@ -9,8 +9,6 @@ // except according to those terms. use LinkerFlavor; -use std::io; -use std::process::Command; use target::{LinkArgs, TargetOptions}; use self::Arch::*; @@ -37,30 +35,6 @@ impl Arch { } } -pub fn get_sdk_root(sdk_name: &str) -> Result { - let res = Command::new("xcrun") - .arg("--show-sdk-path") - .arg("-sdk") - .arg(sdk_name) - .output() - .and_then(|output| { - if output.status.success() { - Ok(String::from_utf8(output.stdout).unwrap()) - } else { - let error = String::from_utf8(output.stderr); - let error = format!("process exit with error: {}", - error.unwrap()); - Err(io::Error::new(io::ErrorKind::Other, - &error[..])) - } - }); - - match res { - Ok(output) => Ok(output.trim().to_string()), - Err(e) => Err(format!("failed to get {} SDK path: {}", sdk_name, e)) - } -} - fn build_pre_link_args(arch: Arch) -> Result { let sdk_name = match arch { Armv7 | Armv7s | Arm64 => "iphoneos", @@ -69,13 +43,13 @@ fn build_pre_link_args(arch: Arch) -> Result { let arch_name = arch.to_string(); - let sdk_root = get_sdk_root(sdk_name)?; + let sdk_root = super::apple_base::get_sdk_root(sdk_name)?; let mut args = LinkArgs::new(); - args.insert(LinkerFlavor::Gcc, + args.insert(LinkerFlavor::Ld, vec!["-arch".to_string(), arch_name.to_string(), - "-Wl,-syslibroot".to_string(), + "-syslibroot".to_string(), sdk_root]); Ok(args) diff --git a/src/librustc_back/target/armv7_apple_ios.rs b/src/librustc_back/target/armv7_apple_ios.rs index 67d3d12fb5776..80771f72a199e 100644 --- a/src/librustc_back/target/armv7_apple_ios.rs +++ b/src/librustc_back/target/armv7_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_os: "ios".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: TargetOptions { features: "+v7,+vfp3,+neon".to_string(), max_atomic_width: Some(64), diff --git a/src/librustc_back/target/armv7s_apple_ios.rs b/src/librustc_back/target/armv7s_apple_ios.rs index e4cc89ab21140..a81354921ccbb 100644 --- a/src/librustc_back/target/armv7s_apple_ios.rs +++ b/src/librustc_back/target/armv7s_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_os: "ios".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: TargetOptions { features: "+v7,+vfp4,+neon".to_string(), max_atomic_width: Some(64), diff --git a/src/librustc_back/target/i386_apple_ios.rs b/src/librustc_back/target/i386_apple_ios.rs index 82eae1a31a9ad..5d6cbf9676054 100644 --- a/src/librustc_back/target/i386_apple_ios.rs +++ b/src/librustc_back/target/i386_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_os: "ios".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: TargetOptions { max_atomic_width: Some(64), stack_probes: true, diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index 14937f9aa55b6..226f897ca0c5b 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -15,7 +15,6 @@ pub fn target() -> TargetResult { let mut base = super::apple_base::opts(); base.cpu = "yonah".to_string(); base.max_atomic_width = Some(64); - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]); base.stack_probes = true; Ok(Target { @@ -28,7 +27,7 @@ pub fn target() -> TargetResult { target_os: "macos".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: base, }) } diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 7599a60ba5ada..3679b45d89e7c 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -53,7 +53,7 @@ use syntax::abi::{Abi, lookup as lookup_abi}; use {LinkerFlavor, PanicStrategy, RelroLevel}; mod android_base; -mod apple_base; +pub mod apple_base; mod apple_ios_base; mod arm_base; mod bitrig_base; diff --git a/src/librustc_back/target/x86_64_apple_darwin.rs b/src/librustc_back/target/x86_64_apple_darwin.rs index 71ac360eb9906..b544283824b03 100644 --- a/src/librustc_back/target/x86_64_apple_darwin.rs +++ b/src/librustc_back/target/x86_64_apple_darwin.rs @@ -16,7 +16,6 @@ pub fn target() -> TargetResult { base.cpu = "core2".to_string(); base.max_atomic_width = Some(128); // core2 support cmpxchg16b base.eliminate_frame_pointer = false; - base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]); base.stack_probes = true; Ok(Target { @@ -29,7 +28,7 @@ pub fn target() -> TargetResult { target_os: "macos".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: base, }) } diff --git a/src/librustc_back/target/x86_64_apple_ios.rs b/src/librustc_back/target/x86_64_apple_ios.rs index eed99e3784ce0..4d53a66e62119 100644 --- a/src/librustc_back/target/x86_64_apple_ios.rs +++ b/src/librustc_back/target/x86_64_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_os: "ios".to_string(), target_env: "".to_string(), target_vendor: "apple".to_string(), - linker_flavor: LinkerFlavor::Gcc, + linker_flavor: LinkerFlavor::Ld, options: TargetOptions { max_atomic_width: Some(64), stack_probes: true, diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index e0eef1f5764b2..ad626389c4685 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -1108,9 +1108,9 @@ fn add_upstream_rust_crates(cmd: &mut Linker, } } - // We must link the sanitizer runtime using -Wl,--whole-archive but since - // it's packed in a .rlib, it contains stuff that are not objects that will - // make the linker error. So we must remove those bits from the .rlib before + // We must link the sanitizer runtime using --whole-archive but since it's + // packed in a .rlib, it contains stuff that are not objects that will make + // the linker error. So we must remove those bits from the .rlib before // linking it. fn link_sanitizer_runtime(cmd: &mut Linker, sess: &Session, @@ -1129,7 +1129,7 @@ fn add_upstream_rust_crates(cmd: &mut Linker, // FIXME: Remove this logic into librustc_*san once Cargo supports it let rpath = cratepath.parent().unwrap(); let rpath = rpath.to_str().expect("non-utf8 component in path"); - cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); + cmd.args(&["-rpath".into(), rpath.into()]); } let dst = tmpdir.join(cratepath.file_name().unwrap()); diff --git a/src/librustc_trans/back/linker.rs b/src/librustc_trans/back/linker.rs index aa29c3cc12058..6ecd13b02c441 100644 --- a/src/librustc_trans/back/linker.rs +++ b/src/librustc_trans/back/linker.rs @@ -23,7 +23,7 @@ use rustc::middle::dependency_format::Linkage; use rustc::session::Session; use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel}; use rustc::ty::TyCtxt; -use rustc_back::LinkerFlavor; +use rustc_back::{LinkerFlavor, target}; use serialize::{json, Encoder}; /// For all the linkers we support, and information they might @@ -66,6 +66,7 @@ impl LinkerInfo { info: self, hinted_static: false, is_ld: false, + building_executable: true, }) as Box } LinkerFlavor::Ld => { @@ -75,6 +76,7 @@ impl LinkerInfo { info: self, hinted_static: false, is_ld: true, + building_executable: true, }) as Box } LinkerFlavor::Binaryen => { @@ -126,22 +128,29 @@ pub struct GccLinker<'a> { hinted_static: bool, // Keeps track of the current hinting mode. // Link as ld is_ld: bool, + // Keeps track of product being an executable. + building_executable: bool, } impl<'a> GccLinker<'a> { /// Argument that must be passed *directly* to the linker /// - /// These arguments need to be prepended with '-Wl,' when a gcc-style linker is used + /// These arguments need to be preceded by '-Xlinker' when a gcc-style + /// linker is used. fn linker_arg(&mut self, arg: S) -> &mut Self where S: AsRef { if !self.is_ld { - let mut os = OsString::from("-Wl,"); - os.push(arg.as_ref()); - self.cmd.arg(os); - } else { - self.cmd.arg(arg); + self.cmd.arg("-Xlinker"); } + self.cmd.arg(arg); + self + } + + fn add_lib>(&mut self, lib: S) -> &mut Self { + let mut os = OsString::from("-l"); + os.push(lib.as_ref()); + self.cmd.arg(os); self } @@ -171,8 +180,8 @@ impl<'a> GccLinker<'a> { } impl<'a> Linker for GccLinker<'a> { - fn link_dylib(&mut self, lib: &str) { self.hint_dynamic(); self.cmd.arg("-l").arg(lib); } - fn link_staticlib(&mut self, lib: &str) { self.hint_static(); self.cmd.arg("-l").arg(lib); } + fn link_dylib(&mut self, lib: &str) { self.hint_dynamic(); self.add_lib(lib); } + fn link_staticlib(&mut self, lib: &str) { self.hint_static(); self.add_lib(lib); } fn link_rlib(&mut self, lib: &Path) { self.hint_static(); self.cmd.arg(lib); } fn include_path(&mut self, path: &Path) { self.cmd.arg("-L").arg(path); } fn framework_path(&mut self, path: &Path) { self.cmd.arg("-F").arg(path); } @@ -182,11 +191,15 @@ impl<'a> Linker for GccLinker<'a> { fn partial_relro(&mut self) { self.linker_arg("-z,relro"); } fn full_relro(&mut self) { self.linker_arg("-z,relro,-z,now"); } fn build_static_executable(&mut self) { self.cmd.arg("-static"); } - fn args(&mut self, args: &[String]) { self.cmd.args(args); } + fn args(&mut self, args: &[String]) { + for arg in args { + self.linker_arg(arg); + } + } fn link_rust_dylib(&mut self, lib: &str, _path: &Path) { self.hint_dynamic(); - self.cmd.arg("-l").arg(lib); + self.add_lib(lib); } fn link_framework(&mut self, framework: &str) { @@ -202,25 +215,22 @@ impl<'a> Linker for GccLinker<'a> { // functions, etc. fn link_whole_staticlib(&mut self, lib: &str, search_path: &[PathBuf]) { self.hint_static(); - let target = &self.sess.target.target; - if !target.options.is_like_osx { - self.linker_arg("--whole-archive").cmd.arg("-l").arg(lib); - self.linker_arg("--no-whole-archive"); + if self.sess.target.target.options.is_like_osx { + self.linker_arg("-force_load"); + // let-binding needed to appease borrowck. + let lib = archive::find_library(lib, search_path, &self.sess); + self.linker_arg(lib); } else { - // -force_load is the macOS equivalent of --whole-archive, but it - // involves passing the full path to the library to link. - let mut v = OsString::from("-force_load,"); - v.push(&archive::find_library(lib, search_path, &self.sess)); - self.linker_arg(&v); + self.linker_arg("--whole-archive").add_lib(lib); + self.linker_arg("--no-whole-archive"); } } fn link_whole_rlib(&mut self, lib: &Path) { self.hint_static(); if self.sess.target.target.options.is_like_osx { - let mut v = OsString::from("-force_load,"); - v.push(lib); - self.linker_arg(&v); + self.linker_arg("-force_load"); + self.linker_arg(lib); } else { self.linker_arg("--whole-archive").cmd.arg(lib); self.linker_arg("--no-whole-archive"); @@ -280,18 +290,20 @@ impl<'a> Linker for GccLinker<'a> { } fn build_dylib(&mut self, out_filename: &Path) { + self.building_executable = false; + // On mac we need to tell the linker to let this library be rpathed if self.sess.target.target.options.is_like_osx { - self.cmd.arg("-dynamiclib"); self.linker_arg("-dylib"); // Note that the `osx_rpath_install_name` option here is a hack // purely to support rustbuild right now, we should get a more // principled solution at some point to force the compiler to pass - // the right `-Wl,-install_name` with an `@rpath` in it. + // the right `-install_name` with an `@rpath` in it. if self.sess.opts.cg.rpath || self.sess.opts.debugging_opts.osx_rpath_install_name { - let mut v = OsString::from("-install_name,@rpath/"); + self.linker_arg("-install_name"); + let mut v = OsString::from("@rpath/"); v.push(out_filename.file_name().unwrap()); self.linker_arg(&v); } @@ -313,7 +325,6 @@ impl<'a> Linker for GccLinker<'a> { return } - let mut arg = OsString::new(); let path = tmpdir.join("list"); debug!("EXPORTED SYMBOLS:"); @@ -349,24 +360,16 @@ impl<'a> Linker for GccLinker<'a> { } if self.sess.target.target.options.is_like_osx { - if !self.is_ld { - arg.push("-Wl,") - } - arg.push("-exported_symbols_list,"); + self.linker_arg("-exported_symbols_list"); + self.linker_arg(&path); } else if self.sess.target.target.options.is_like_solaris { - if !self.is_ld { - arg.push("-Wl,") - } - arg.push("-M,"); + self.linker_arg("-M"); + self.linker_arg(&path); } else { - if !self.is_ld { - arg.push("-Wl,") - } - arg.push("--version-script="); + let mut arg = OsString::from("--version-script="); + arg.push(&path); + self.linker_arg(&arg); } - - arg.push(&path); - self.cmd.arg(arg); } fn subsystem(&mut self, subsystem: &str) { @@ -374,6 +377,20 @@ impl<'a> Linker for GccLinker<'a> { } fn finalize(&mut self) -> Command { + if self.sess.target.target.options.is_like_osx && self.is_ld { + self.cmd.arg("-macosx_version_min"); + let deployment_target = target::apple_base::get_deployment_target(); + self.cmd.arg(&deployment_target); + + if self.building_executable { + let mut i = deployment_target.splitn(2, '.').map(|s| s.parse::().unwrap()); + let version = (i.next().unwrap(), i.next().unwrap()); + if version < (10, 8) { + self.cmd.arg("-lcrt1.10.6.o"); + } + } + } + self.hint_dynamic(); // Reset to default before returning the composed command line. let mut cmd = Command::new(""); ::std::mem::swap(&mut cmd, &mut self.cmd); diff --git a/src/librustc_trans/back/rpath.rs b/src/librustc_trans/back/rpath.rs index 8e5e7d376488b..f8f44c8f660f3 100644 --- a/src/librustc_trans/back/rpath.rs +++ b/src/librustc_trans/back/rpath.rs @@ -26,41 +26,30 @@ pub struct RPathConfig<'a> { } pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec { - // No rpath on windows - if !config.has_rpath { - return Vec::new(); - } - let mut flags = Vec::new(); - debug!("preparing the RPATH!"); + // No rpath on windows + if config.has_rpath { + debug!("preparing the RPATH!"); + + let libs = config.used_crates.iter().filter_map(|&(_, ref l)| { + l.option() + }).collect::>(); - let libs = config.used_crates.clone(); - let libs = libs.iter().filter_map(|&(_, ref l)| l.option()).collect::>(); - let rpaths = get_rpaths(config, &libs); - flags.extend_from_slice(&rpaths_to_flags(&rpaths)); + for rpath in get_rpaths(config, &libs) { + flags.push("-rpath".into()); + flags.push(rpath); + } - // Use DT_RUNPATH instead of DT_RPATH if available - if config.linker_is_gnu { - flags.push("-Wl,--enable-new-dtags".to_string()); + // Use DT_RUNPATH instead of DT_RPATH if available + if config.linker_is_gnu { + flags.push("--enable-new-dtags".into()); + } } flags } -fn rpaths_to_flags(rpaths: &[String]) -> Vec { - let mut ret = Vec::new(); - for rpath in rpaths { - if rpath.contains(',') { - ret.push("-Wl,-rpath".into()); - ret.push("-Xlinker".into()); - ret.push(rpath.clone()); - } else { - ret.push(format!("-Wl,-rpath,{}", &(*rpath))); - } - } - return ret; -} fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec { debug!("output: {:?}", config.out_filename.display()); @@ -91,8 +80,7 @@ fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec { rpaths.extend_from_slice(&fallback_rpaths); // Remove duplicates - let rpaths = minimize_rpaths(&rpaths); - return rpaths; + minimize_rpaths(&rpaths) } fn get_rpaths_relative_to_output(config: &mut RPathConfig, @@ -187,20 +175,9 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec { #[cfg(all(unix, test))] mod tests { use super::{RPathConfig}; - use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; + use super::{minimize_rpaths, get_rpath_relative_to_output}; use std::path::{Path, PathBuf}; - #[test] - fn test_rpaths_to_flags() { - let flags = rpaths_to_flags(&[ - "path1".to_string(), - "path2".to_string() - ]); - assert_eq!(flags, - ["-Wl,-rpath,path1", - "-Wl,-rpath,path2"]); - } - #[test] fn test_minimize1() { let res = minimize_rpaths(&[ @@ -264,19 +241,4 @@ mod tests { assert_eq!(res, "$ORIGIN/../lib"); } } - - #[test] - fn test_xlinker() { - let args = rpaths_to_flags(&[ - "a/normal/path".to_string(), - "a,comma,path".to_string() - ]); - - assert_eq!(args, vec![ - "-Wl,-rpath,a/normal/path".to_string(), - "-Wl,-rpath".to_string(), - "-Xlinker".to_string(), - "a,comma,path".to_string() - ]); - } } diff --git a/src/test/run-make/fpic/Makefile b/src/test/run-make/fpic/Makefile index 6de58c2db18d3..2b260beafd6c7 100644 --- a/src/test/run-make/fpic/Makefile +++ b/src/test/run-make/fpic/Makefile @@ -7,7 +7,10 @@ ifeq ($(UNAME),Darwin) all: else ifdef IS_WINDOWS all: -else +else ifeq ($(findstring stage0,$(RUST_BUILD_STAGE)),stage0) all: $(RUSTC) hello.rs -C link-args=-Wl,-z,text +else +all: + $(RUSTC) hello.rs -C link-args='-z text' endif