Skip to content

Commit

Permalink
Change the "option" parameter of function strip_symbols_with_external…
Browse files Browse the repository at this point in the history
…_utility to "options" which is now a vector of strings and add "-X32_64" for AIX.
  • Loading branch information
xingxue-ibm committed Nov 19, 2024
1 parent 7d40450 commit d98b139
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,13 @@ fn link_natively(
let stripcmd = "rust-objcopy";
match (strip, crate_type) {
(Strip::Debuginfo, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
let strip_options = vec!["-S".to_string()];
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some(&strip_options))
}
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
let strip_options = vec!["-x".to_string()];
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some(&strip_options))
}
(Strip::Symbols, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
Expand All @@ -1131,7 +1133,8 @@ fn link_natively(
match strip {
// Always preserve the symbol table (-x).
Strip::Debuginfo => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
let strip_options = vec!["-x".to_string()];
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some(&strip_options))
}
// Strip::Symbols is handled via the --strip-all linker option.
Strip::Symbols => {}
Expand All @@ -1145,14 +1148,17 @@ fn link_natively(
sess.dcx().emit_warn(errors::AixStripNotUsed);
}
let stripcmd = "/usr/bin/strip";
let mut strip_options = vec!["-X32_64".to_string()];
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_options.push("-l".to_string());
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some(&strip_options))
}
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_options.push("-r".to_string());
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some(&strip_options))
}
Strip::None => {}
}
Expand All @@ -1165,11 +1171,13 @@ fn strip_symbols_with_external_utility(
sess: &Session,
util: &str,
out_filename: &Path,
option: Option<&str>,
options: Option<&[String]>,
) {
let mut cmd = Command::new(util);
if let Some(option) = option {
cmd.arg(option);
if let Some(opts) = options {
for option in opts {
cmd.arg(option);
}
}

let mut new_path = sess.get_tools_search_paths(false);
Expand Down

0 comments on commit d98b139

Please sign in to comment.