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