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