Skip to content

Commit

Permalink
Rollup merge of #130781 - monkeydbobo:mdb/fix_up_cross_compile_osx, r…
Browse files Browse the repository at this point in the history
…=davidtwco

Fix up setting strip = true in Cargo.toml makes build scripts fail in…

Fix issue: #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.
  • Loading branch information
matthiaskrgr authored Sep 25, 2024
2 parents 0055895 + 802bf71 commit 81ac893
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,16 +1087,17 @@ fn link_natively(
let strip = sess.opts.cg.strip;

if sess.target.is_like_osx {
let stripcmd = "/usr/bin/strip";
match (strip, crate_type) {
(Strip::Debuginfo, _) => {
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S"))
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
}
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x"))
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
}
(Strip::Symbols, _) => {
strip_symbols_with_external_utility(sess, "strip", out_filename, None)
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
}
(Strip::None, _) => {}
}
Expand Down

0 comments on commit 81ac893

Please sign in to comment.