Skip to content

Commit 81ac893

Browse files
authored
Rollup merge of rust-lang#130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r=davidtwco
Fix up setting strip = true in Cargo.toml makes build scripts fail in… Fix issue: rust-lang#110536 Strip binary is PATH dependent which breaks builds in MacOS. For example, on my Mac, the output of 'which strip' is '/opt/homebrew/opt/binutils/bin/strip', which leads to incorrect 'strip' results. Therefore, just like on other systems, it is also necessary to specify 'stripcmd' on macOS. However, it seems that there is a bug in binutils [bugzilla-Bug 31571](https://sourceware.org/bugzilla/show_bug.cgi?id=31571), which leads to the problem mentioned above.
2 parents 0055895 + 802bf71 commit 81ac893

File tree

1 file changed

+4
-3
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+4
-3
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1087,16 +1087,17 @@ fn link_natively(
10871087
let strip = sess.opts.cg.strip;
10881088

10891089
if sess.target.is_like_osx {
1090+
let stripcmd = "/usr/bin/strip";
10901091
match (strip, crate_type) {
10911092
(Strip::Debuginfo, _) => {
1092-
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S"))
1093+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
10931094
}
10941095
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
10951096
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1096-
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x"))
1097+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
10971098
}
10981099
(Strip::Symbols, _) => {
1099-
strip_symbols_with_external_utility(sess, "strip", out_filename, None)
1100+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
11001101
}
11011102
(Strip::None, _) => {}
11021103
}

0 commit comments

Comments
 (0)