Skip to content

Commit 217e201

Browse files
committed
aix linker use noipath
1 parent 3fee0f1 commit 217e201

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,13 @@ fn add_upstream_rust_crates(
27352735
.find(|(ty, _)| *ty == crate_type)
27362736
.expect("failed to find crate type in dependency format list");
27372737

2738+
if sess.target.is_like_aix {
2739+
// Unlike GNU's ld, AIX linker doesn't feature `-soname=...` when output
2740+
// a shared library. Instead, AIX linker offers `(no)ipath`. See
2741+
// https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command.
2742+
cmd.link_or_cc_arg("-bnoipath");
2743+
}
2744+
27382745
for &cnum in &codegen_results.crate_info.used_crates {
27392746
// We may not pass all crates through to the linker. Some crates may appear statically in
27402747
// an existing dylib, meaning we'll pick up all the symbols from the dylib.

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,9 +1622,9 @@ impl<'a> Linker for AixLinker<'a> {
16221622
}
16231623
}
16241624

1625-
fn link_dylib_by_name(&mut self, name: &str, _verbatim: bool, _as_needed: bool) {
1625+
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, _as_needed: bool) {
16261626
self.hint_dynamic();
1627-
self.link_or_cc_arg(format!("-l{name}"));
1627+
self.link_or_cc_arg(if verbatim { String::from(name) } else { format!("-l{name}") });
16281628
}
16291629

16301630
fn link_dylib_by_path(&mut self, path: &Path, _as_needed: bool) {
@@ -1635,7 +1635,7 @@ impl<'a> Linker for AixLinker<'a> {
16351635
fn link_staticlib_by_name(&mut self, name: &str, verbatim: bool, whole_archive: bool) {
16361636
self.hint_static();
16371637
if !whole_archive {
1638-
self.link_or_cc_arg(format!("-l{name}"));
1638+
self.link_or_cc_arg(if verbatim { String::from(name) } else { format!("-l{name}") });
16391639
} else {
16401640
let mut arg = OsString::from("-bkeepfile:");
16411641
arg.push(find_native_static_library(name, verbatim, self.sess));

0 commit comments

Comments
 (0)