Skip to content

Commit

Permalink
Rollup merge of #117118 - bzEq:aix-linker, r=wesleywiser
Browse files Browse the repository at this point in the history
[AIX] Remove AixLinker's debuginfo() implementation

AIX ld's `-s` option doesn't perfectly fit` debuginfo()`'s semantics and may unexpectedly remove metadata in shared libraries. Remove the implementation of `AixLinker` and suggest user to use `strip` utility instead.
  • Loading branch information
matthiaskrgr authored Mar 14, 2024
2 parents 30f74ff + b1c3909 commit 68ca795
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
15 changes: 15 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,21 @@ fn link_natively<'a>(
}
}

if sess.target.is_like_aix {
let stripcmd = "/usr/bin/strip";
match strip {
Strip::Debuginfo => {
// FIXME: AIX's strip utility only offers option to strip line number information.
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-l"))
}
Strip::Symbols => {
// Must be noted this option might remove symbol __aix_rust_metadata and thus removes .info section which contains metadata.
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-r"))
}
Strip::None => {}
}
}

Ok(())
}

Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,16 +1640,7 @@ impl<'a> Linker for AixLinker<'a> {

fn ehcont_guard(&mut self) {}

fn debuginfo(&mut self, strip: Strip, _: &[PathBuf]) {
match strip {
Strip::None => {}
// FIXME: -s strips the symbol table, line number information
// and relocation information.
Strip::Debuginfo | Strip::Symbols => {
self.cmd.arg("-s");
}
}
}
fn debuginfo(&mut self, _: Strip, _: &[PathBuf]) {}

fn no_crt_objects(&mut self) {}

Expand Down

0 comments on commit 68ca795

Please sign in to comment.