@@ -1087,9 +1087,7 @@ fn link_natively(
10871087    let  strip = sess. opts . cg . strip ; 
10881088
10891089    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" ; 
10931091        match  ( strip,  crate_type)  { 
10941092            ( Strip :: Debuginfo ,  _)  => { 
10951093                strip_symbols_with_external_utility ( sess,  stripcmd,  out_filename,  Some ( "-S" ) ) 
@@ -1105,11 +1103,14 @@ fn link_natively(
11051103        } 
11061104    } 
11071105
1108-     if  sess. target . os  ==  "illumos"  { 
1106+     if  sess. target . is_like_solaris  { 
11091107        // Many illumos systems will have both the native 'strip' utility and 
11101108        // the GNU one. Use the native version explicitly and do not rely on 
11111109        // 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"  } ; 
11131114        match  strip { 
11141115            // Always preserve the symbol table (-x). 
11151116            Strip :: Debuginfo  => { 
@@ -1122,6 +1123,10 @@ fn link_natively(
11221123    } 
11231124
11241125    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+         } 
11251130        let  stripcmd = "/usr/bin/strip" ; 
11261131        match  strip { 
11271132            Strip :: Debuginfo  => { 
@@ -1149,6 +1154,13 @@ fn strip_symbols_with_external_utility(
11491154    if  let  Some ( option)  = option { 
11501155        cmd. arg ( option) ; 
11511156    } 
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+ 
11521164    let  prog = cmd. arg ( out_filename) . output ( ) ; 
11531165    match  prog { 
11541166        Ok ( prog)  => { 
0 commit comments