Rollup merge of #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: https://github.com/rust-lang/rust/issues/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.
This commit is contained in:
Matthias Krüger 2024-09-25 20:10:59 +02:00 committed by GitHub
commit 81ac893d3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1087,16 +1087,17 @@ fn link_natively(
let strip = sess.opts.cg.strip; let strip = sess.opts.cg.strip;
if sess.target.is_like_osx { if sess.target.is_like_osx {
let stripcmd = "/usr/bin/strip";
match (strip, crate_type) { match (strip, crate_type) {
(Strip::Debuginfo, _) => { (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) // Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => { (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, _) => {
strip_symbols_with_external_utility(sess, "strip", out_filename, None) strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
} }
(Strip::None, _) => {} (Strip::None, _) => {}
} }