From aa692a577eee7fa1aaa72d29efeb860bbae6572f Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Tue, 24 Oct 2023 14:59:05 +0800 Subject: [PATCH 1/3] [AIX] Remove AixLinker's debuginfo() implementation `-s` option doesn't perfectly fit into debuginfo()'s semantics and may unexpectedly remove metadata in shared libraries. Remove the implementation and suggest user to use `strip` utility instead. --- compiler/rustc_codegen_ssa/src/back/linker.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index e52efd8695558..9bdff2abee9ee 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1639,16 +1639,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) {} From e74e6e767d4b5cc1f033cee5b5ef4704dd8fee31 Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Tue, 5 Mar 2024 15:37:37 +0800 Subject: [PATCH 2/3] Rebased --- compiler/rustc_codegen_ssa/src/back/link.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index fcb3602b7349c..b52e6242d992d 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1080,6 +1080,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 removes 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(()) } From b1c390989fc8b74aa36f445cd66316a8ca96455d Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Tue, 5 Mar 2024 15:42:31 +0800 Subject: [PATCH 3/3] Adjust wording --- compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b52e6242d992d..a8d6963294df3 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1088,7 +1088,7 @@ fn link_natively<'a>( strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-l")) } Strip::Symbols => { - // Must be noted this option removes symbol __aix_rust_metadata and thus removes .info section which contains metadata. + // 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 => {}