Skip to content

Commit 8558b35

Browse files
committed
Use safer strip=symbols-flag for dylibs on macOS
1 parent 7092d42 commit 8558b35

File tree

1 file changed

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

1 file changed

+8
-4
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
10031003
let strip = strip_value(sess);
10041004

10051005
if sess.target.is_like_osx {
1006-
match strip {
1007-
Strip::Debuginfo => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
1008-
Strip::Symbols => strip_symbols_in_osx(sess, &out_filename, None),
1009-
Strip::None => {}
1006+
match (strip, crate_type) {
1007+
(Strip::Debuginfo, _) => strip_symbols_in_osx(sess, &out_filename, Some("-S")),
1008+
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
1009+
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1010+
strip_symbols_in_osx(sess, &out_filename, Some("-x"))
1011+
}
1012+
(Strip::Symbols, _) => strip_symbols_in_osx(sess, &out_filename, None),
1013+
(Strip::None, _) => {}
10101014
}
10111015
}
10121016
}

0 commit comments

Comments
 (0)