@@ -1085,9 +1085,7 @@ fn link_natively(
10851085 let strip = sess. opts . cg . strip ;
10861086
10871087 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" ;
10911089 match ( strip, crate_type) {
10921090 ( Strip :: Debuginfo , _) => {
10931091 strip_symbols_with_external_utility ( sess, stripcmd, out_filename, Some ( "-S" ) )
@@ -1103,11 +1101,14 @@ fn link_natively(
11031101 }
11041102 }
11051103
1106- if sess. target . os == "illumos" {
1104+ if sess. target . is_like_solaris {
11071105 // Many illumos systems will have both the native 'strip' utility and
11081106 // the GNU one. Use the native version explicitly and do not rely on
11091107 // 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" } ;
11111112 match strip {
11121113 // Always preserve the symbol table (-x).
11131114 Strip :: Debuginfo => {
@@ -1120,6 +1121,10 @@ fn link_natively(
11201121 }
11211122
11221123 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+ }
11231128 let stripcmd = "/usr/bin/strip" ;
11241129 match strip {
11251130 Strip :: Debuginfo => {
@@ -1147,6 +1152,13 @@ fn strip_symbols_with_external_utility(
11471152 if let Some ( option) = option {
11481153 cmd. arg ( option) ;
11491154 }
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+
11501162 let prog = cmd. arg ( out_filename) . output ( ) ;
11511163 match prog {
11521164 Ok ( prog) => {
0 commit comments