Skip to content

Commit 159f31c

Browse files
committed
codegen_ssa: use llvm-objcopy for macOS strip
1 parent 4726b17 commit 159f31c

File tree

1 file changed

+9
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+9
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -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"))
@@ -1147,6 +1148,13 @@ fn strip_symbols_with_external_utility(
11471148
if let Some(option) = option {
11481149
cmd.arg(option);
11491150
}
1151+
1152+
let mut new_path = sess.get_tools_search_paths(false);
1153+
if let Some(path) = env::var_os("PATH") {
1154+
new_path.extend(env::split_paths(&path));
1155+
}
1156+
cmd.env("PATH", env::join_paths(new_path).unwrap());
1157+
11501158
let prog = cmd.arg(out_filename).output();
11511159
match prog {
11521160
Ok(prog) => {

0 commit comments

Comments
 (0)