@@ -1034,16 +1034,30 @@ fn link_natively<'a>(
1034
1034
1035
1035
if sess. target . is_like_osx {
1036
1036
match ( strip, crate_type) {
1037
- ( Strip :: Debuginfo , _) => strip_symbols_in_osx ( sess, & out_filename, Some ( "-S" ) ) ,
1037
+ ( Strip :: Debuginfo , _) => strip_symbols_with_external_utility ( sess, "strip" , & out_filename, Some ( "-S" ) ) ,
1038
1038
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
1039
1039
( Strip :: Symbols , CrateType :: Dylib | CrateType :: Cdylib | CrateType :: ProcMacro ) => {
1040
- strip_symbols_in_osx ( sess, & out_filename, Some ( "-x" ) )
1040
+ strip_symbols_with_external_utility ( sess, "strip" , & out_filename, Some ( "-x" ) )
1041
1041
}
1042
- ( Strip :: Symbols , _) => strip_symbols_in_osx ( sess, & out_filename, None ) ,
1042
+ ( Strip :: Symbols , _) => strip_symbols_with_external_utility ( sess, "strip" , & out_filename, None ) ,
1043
1043
( Strip :: None , _) => { }
1044
1044
}
1045
1045
}
1046
1046
1047
+ if sess. target . os == "illumos" {
1048
+ // Many illumos systems will have both the native 'strip' utility and
1049
+ // the GNU one. Use the native version explicitly and do not rely on
1050
+ // what's in the path.
1051
+ let stripcmd = "/usr/bin/strip" ;
1052
+ match strip {
1053
+ // Always preserve the symbol table (-x).
1054
+ Strip :: Debuginfo => strip_symbols_with_external_utility ( sess, stripcmd, & out_filename, Some ( "-x" ) ) ,
1055
+ // Strip::Symbols is handled via the --strip-all linker option.
1056
+ Strip :: Symbols => { } ,
1057
+ Strip :: None => { }
1058
+ }
1059
+ }
1060
+
1047
1061
Ok ( ( ) )
1048
1062
}
1049
1063
@@ -1055,8 +1069,8 @@ fn strip_value(sess: &Session) -> Strip {
1055
1069
}
1056
1070
}
1057
1071
1058
- fn strip_symbols_in_osx < ' a > ( sess : & ' a Session , out_filename : & Path , option : Option < & str > ) {
1059
- let mut cmd = Command :: new ( "strip" ) ;
1072
+ fn strip_symbols_with_external_utility < ' a > ( sess : & ' a Session , util : & str , out_filename : & Path , option : Option < & str > ) {
1073
+ let mut cmd = Command :: new ( util ) ;
1060
1074
if let Some ( option) = option {
1061
1075
cmd. arg ( option) ;
1062
1076
}
@@ -1067,14 +1081,14 @@ fn strip_symbols_in_osx<'a>(sess: &'a Session, out_filename: &Path, option: Opti
1067
1081
let mut output = prog. stderr . clone ( ) ;
1068
1082
output. extend_from_slice ( & prog. stdout ) ;
1069
1083
sess. struct_warn ( & format ! (
1070
- "stripping debug info with `strip ` failed: {}" ,
1071
- prog. status
1084
+ "stripping debug info with `{} ` failed: {}" ,
1085
+ util , prog. status
1072
1086
) )
1073
1087
. note ( & escape_string ( & output) )
1074
1088
. emit ( ) ;
1075
1089
}
1076
1090
}
1077
- Err ( e) => sess. fatal ( & format ! ( "unable to run `strip `: {}" , e) ) ,
1091
+ Err ( e) => sess. fatal ( & format ! ( "unable to run `{} `: {}" , util , e) ) ,
1078
1092
}
1079
1093
}
1080
1094
0 commit comments