@@ -1085,9 +1085,7 @@ fn link_natively(
1085
1085
let strip = sess. opts . cg . strip ;
1086
1086
1087
1087
if sess. target . is_like_osx {
1088
- // Use system `strip` when running on host macOS.
1089
- // <https://github.com/rust-lang/rust/pull/130781>
1090
- let stripcmd = if cfg ! ( target_os = "macos" ) { "/usr/bin/strip" } else { "strip" } ;
1088
+ let stripcmd = "rust-objcopy" ;
1091
1089
match ( strip, crate_type) {
1092
1090
( Strip :: Debuginfo , _) => {
1093
1091
strip_symbols_with_external_utility ( sess, stripcmd, out_filename, Some ( "-S" ) )
@@ -1103,11 +1101,14 @@ fn link_natively(
1103
1101
}
1104
1102
}
1105
1103
1106
- if sess. target . os == "illumos" {
1104
+ if sess. target . is_like_solaris {
1107
1105
// Many illumos systems will have both the native 'strip' utility and
1108
1106
// the GNU one. Use the native version explicitly and do not rely on
1109
1107
// what's in the path.
1110
- let stripcmd = "/usr/bin/strip" ;
1108
+ //
1109
+ // If cross-compiling and there is not a native version, then use
1110
+ // `llvm-strip` and hope.
1111
+ let stripcmd = if !sess. host . is_like_solaris { "rust-objcopy" } else { "/usr/bin/strip" } ;
1111
1112
match strip {
1112
1113
// Always preserve the symbol table (-x).
1113
1114
Strip :: Debuginfo => {
@@ -1120,6 +1121,10 @@ fn link_natively(
1120
1121
}
1121
1122
1122
1123
if sess. target . is_like_aix {
1124
+ // `llvm-strip` doesn't work for AIX - their strip must be used.
1125
+ if !sess. host . is_like_aix {
1126
+ sess. dcx ( ) . emit_warn ( errors:: AixStripNotUsed ) ;
1127
+ }
1123
1128
let stripcmd = "/usr/bin/strip" ;
1124
1129
match strip {
1125
1130
Strip :: Debuginfo => {
@@ -1147,6 +1152,13 @@ fn strip_symbols_with_external_utility(
1147
1152
if let Some ( option) = option {
1148
1153
cmd. arg ( option) ;
1149
1154
}
1155
+
1156
+ let mut new_path = sess. get_tools_search_paths ( false ) ;
1157
+ if let Some ( path) = env:: var_os ( "PATH" ) {
1158
+ new_path. extend ( env:: split_paths ( & path) ) ;
1159
+ }
1160
+ cmd. env ( "PATH" , env:: join_paths ( new_path) . unwrap ( ) ) ;
1161
+
1150
1162
let prog = cmd. arg ( out_filename) . output ( ) ;
1151
1163
match prog {
1152
1164
Ok ( prog) => {
0 commit comments