@@ -1034,16 +1034,36 @@ fn link_natively<'a>(
10341034
10351035 if sess. target . is_like_osx {
10361036 match ( strip, crate_type) {
1037- ( Strip :: Debuginfo , _) => strip_symbols_in_osx ( sess, & out_filename, Some ( "-S" ) ) ,
1037+ ( Strip :: Debuginfo , _) => {
1038+ strip_symbols_with_external_utility ( sess, "strip" , & out_filename, Some ( "-S" ) )
1039+ }
10381040 // Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
10391041 ( Strip :: Symbols , CrateType :: Dylib | CrateType :: Cdylib | CrateType :: ProcMacro ) => {
1040- strip_symbols_in_osx ( sess, & out_filename, Some ( "-x" ) )
1042+ strip_symbols_with_external_utility ( sess, "strip" , & out_filename, Some ( "-x" ) )
1043+ }
1044+ ( Strip :: Symbols , _) => {
1045+ strip_symbols_with_external_utility ( sess, "strip" , & out_filename, None )
10411046 }
1042- ( Strip :: Symbols , _) => strip_symbols_in_osx ( sess, & out_filename, None ) ,
10431047 ( Strip :: None , _) => { }
10441048 }
10451049 }
10461050
1051+ if sess. target . os == "illumos" {
1052+ // Many illumos systems will have both the native 'strip' utility and
1053+ // the GNU one. Use the native version explicitly and do not rely on
1054+ // what's in the path.
1055+ let stripcmd = "/usr/bin/strip" ;
1056+ match strip {
1057+ // Always preserve the symbol table (-x).
1058+ Strip :: Debuginfo => {
1059+ strip_symbols_with_external_utility ( sess, stripcmd, & out_filename, Some ( "-x" ) )
1060+ }
1061+ // Strip::Symbols is handled via the --strip-all linker option.
1062+ Strip :: Symbols => { }
1063+ Strip :: None => { }
1064+ }
1065+ }
1066+
10471067 Ok ( ( ) )
10481068}
10491069
@@ -1055,8 +1075,13 @@ fn strip_value(sess: &Session) -> Strip {
10551075 }
10561076}
10571077
1058- fn strip_symbols_in_osx < ' a > ( sess : & ' a Session , out_filename : & Path , option : Option < & str > ) {
1059- let mut cmd = Command :: new ( "strip" ) ;
1078+ fn strip_symbols_with_external_utility < ' a > (
1079+ sess : & ' a Session ,
1080+ util : & str ,
1081+ out_filename : & Path ,
1082+ option : Option < & str > ,
1083+ ) {
1084+ let mut cmd = Command :: new ( util) ;
10601085 if let Some ( option) = option {
10611086 cmd. arg ( option) ;
10621087 }
@@ -1067,14 +1092,14 @@ fn strip_symbols_in_osx<'a>(sess: &'a Session, out_filename: &Path, option: Opti
10671092 let mut output = prog. stderr . clone ( ) ;
10681093 output. extend_from_slice ( & prog. stdout ) ;
10691094 sess. struct_warn ( & format ! (
1070- "stripping debug info with `strip ` failed: {}" ,
1071- prog. status
1095+ "stripping debug info with `{} ` failed: {}" ,
1096+ util , prog. status
10721097 ) )
10731098 . note ( & escape_string ( & output) )
10741099 . emit ( ) ;
10751100 }
10761101 }
1077- Err ( e) => sess. fatal ( & format ! ( "unable to run `strip `: {}" , e) ) ,
1102+ Err ( e) => sess. fatal ( & format ! ( "unable to run `{} `: {}" , util , e) ) ,
10781103 }
10791104}
10801105
0 commit comments