Rollup merge of #131479 - madsmtm:avoid-redundant-dylib, r=jieyouxu

Apple: Avoid redundant `-Wl,-dylib` flag when linking

Seems to have been introduced all the way back in e338a4154b, but should be redundant, `-dynamiclib` should already make `cc` set `-dylib` when linking.

Spotted this while trying to get `-Clinker-flavor=gcc` and `-Clinker-flavor=ld` closer together, not that important to fix.

`@rustbot` label O-apple
This commit is contained in:
Matthias Krüger 2024-10-10 12:49:19 +02:00 committed by GitHub
commit 173c50fb0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -404,11 +404,13 @@ fn push_linker_plugin_lto_args(&mut self, plugin_path: Option<&OsStr>) {
fn build_dylib(&mut self, crate_type: CrateType, out_filename: &Path) {
// On mac we need to tell the linker to let this library be rpathed
if self.sess.target.is_like_osx {
if !self.is_ld {
if self.is_cc() {
// `-dynamiclib` makes `cc` pass `-dylib` to the linker.
self.cc_arg("-dynamiclib");
}
} else {
self.link_arg("-dylib");
// Clang also sets `-dynamic`, but that's implied by `-dylib`, so unnecessary.
}
// Note that the `osx_rpath_install_name` option here is a hack
// purely to support bootstrap right now, we should get a more