Skip to content

Commit

Permalink
Unrolled build for rust-lang#130781
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rust-timer authored Sep 25, 2024
2 parents b511753 + 802bf71 commit 07f6a1a
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 07f6a1a

Please sign in to comment.