From fe68b1ab327297fea9ed2fb273fe0a7ac5aedfdd Mon Sep 17 00:00:00 2001 From: Daniel Silverman Date: Fri, 30 Apr 2021 15:53:14 -0700 Subject: [PATCH] Fix linker_args with --target=sparcv9-sun-solaris Moved -z ignore to add_as_needed Trying to cross-compile for sparcv9-sun-solaris getting an error message for -zignore Introduced when -z -ignore was separated here 22d0ab0 No formatting done Reproduce ``` bash rustup target add sparcv9-sun-solaris cargo new --bin hello && cd hello && cargo run --target=sparcv9-sun-solaris ``` config.toml [target.sparcv9-sun-solaris] linker = "gcc" --- compiler/rustc_codegen_ssa/src/back/linker.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 77d8ab49ff258..8ba124a1fa88c 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -432,8 +432,6 @@ impl<'a> Linker for GccLinker<'a> { // insert it here. if self.sess.target.is_like_osx { self.linker_arg("-dead_strip"); - } else if self.sess.target.is_like_solaris { - self.linker_arg("-zignore"); // If we're building a dylib, we don't use --gc-sections because LLVM // has already done the best it can do, and we also don't want to @@ -655,6 +653,10 @@ impl<'a> Linker for GccLinker<'a> { fn add_as_needed(&mut self) { if self.sess.target.linker_is_gnu { self.linker_arg("--as-needed"); + } else if self.sess.target.is_like_solaris { + // -z ignore is the Solaris equivalent to the GNU ld --as-needed option + self.linker_arg("-z"); + self.linker_arg("ignore"); } } }