@@ -1087,7 +1087,8 @@ fn link_natively(
10871087 let strip = sess. opts . cg . strip ;
10881088
10891089 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" ;
10911092 match ( strip, crate_type) {
10921093 ( Strip :: Debuginfo , _) => {
10931094 strip_symbols_with_external_utility ( sess, stripcmd, out_filename, Some ( "-S" ) )
@@ -1103,11 +1104,14 @@ fn link_natively(
11031104 }
11041105 }
11051106
1106- if sess. target . os == "illumos" {
1107+ if sess. target . is_like_solaris {
11071108 // Many illumos systems will have both the native 'strip' utility and
11081109 // the GNU one. Use the native version explicitly and do not rely on
11091110 // 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" } ;
11111115 match strip {
11121116 // Always preserve the symbol table (-x).
11131117 Strip :: Debuginfo => {
@@ -1120,6 +1124,10 @@ fn link_natively(
11201124 }
11211125
11221126 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+ }
11231131 let stripcmd = "/usr/bin/strip" ;
11241132 match strip {
11251133 Strip :: Debuginfo => {
@@ -1147,6 +1155,13 @@ fn strip_symbols_with_external_utility(
11471155 if let Some ( option) = option {
11481156 cmd. arg ( option) ;
11491157 }
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+
11501165 let prog = cmd. arg ( out_filename) . output ( ) ;
11511166 match prog {
11521167 Ok ( prog) => {
0 commit comments