@@ -1034,16 +1034,36 @@ 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 , _) => {
1038
+ strip_symbols_with_external_utility ( sess, "strip" , & out_filename, Some ( "-S" ) )
1039
+ }
1038
1040
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
1039
1041
( 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 )
1041
1046
}
1042
- ( Strip :: Symbols , _) => strip_symbols_in_osx ( sess, & out_filename, None ) ,
1043
1047
( Strip :: None , _) => { }
1044
1048
}
1045
1049
}
1046
1050
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
+
1047
1067
Ok ( ( ) )
1048
1068
}
1049
1069
@@ -1055,8 +1075,13 @@ fn strip_value(sess: &Session) -> Strip {
1055
1075
}
1056
1076
}
1057
1077
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) ;
1060
1085
if let Some ( option) = option {
1061
1086
cmd. arg ( option) ;
1062
1087
}
@@ -1067,14 +1092,14 @@ fn strip_symbols_in_osx<'a>(sess: &'a Session, out_filename: &Path, option: Opti
1067
1092
let mut output = prog. stderr . clone ( ) ;
1068
1093
output. extend_from_slice ( & prog. stdout ) ;
1069
1094
sess. struct_warn ( & format ! (
1070
- "stripping debug info with `strip ` failed: {}" ,
1071
- prog. status
1095
+ "stripping debug info with `{} ` failed: {}" ,
1096
+ util , prog. status
1072
1097
) )
1073
1098
. note ( & escape_string ( & output) )
1074
1099
. emit ( ) ;
1075
1100
}
1076
1101
}
1077
- Err ( e) => sess. fatal ( & format ! ( "unable to run `strip `: {}" , e) ) ,
1102
+ Err ( e) => sess. fatal ( & format ! ( "unable to run `{} `: {}" , util , e) ) ,
1078
1103
}
1079
1104
}
1080
1105
0 commit comments