Skip to content

Commit

Permalink
Unrolled build for rust-lang#133217
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#133217 - xingxue-ibm:fix-strip, r=compiler-errors

[AIX] Add option -X32_64 to the "strip" command

The AIX `strip` utility requires option `-X` to specify the object mode. This patch adds the `-X32_64` option to the `strip` command so that it can handle both 32-bit and 64-bit objects. The parameter `option` of function `strip_symbols_with_external_utility`, previously a single string, has been changed to `options`, an array of string slices, to accommodate multiple `strip` options.
  • Loading branch information
rust-timer authored Nov 23, 2024
2 parents 386a7c7 + 02f51ec commit 317d65e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,14 +1117,14 @@ fn link_natively(
let stripcmd = "rust-objcopy";
match (strip, crate_type) {
(Strip::Debuginfo, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-S"])
}
// 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"))
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
}
(Strip::Symbols, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[])
}
(Strip::None, _) => {}
}
Expand All @@ -1141,7 +1141,7 @@ fn link_natively(
match strip {
// Always preserve the symbol table (-x).
Strip::Debuginfo => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
}
// Strip::Symbols is handled via the --strip-all linker option.
Strip::Symbols => {}
Expand All @@ -1158,11 +1158,15 @@ fn link_natively(
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_with_external_utility(sess, stripcmd, out_filename, &[
"-X32_64", "-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_symbols_with_external_utility(sess, stripcmd, out_filename, &[
"-X32_64", "-r",
])
}
Strip::None => {}
}
Expand All @@ -1181,12 +1185,10 @@ fn strip_symbols_with_external_utility(
sess: &Session,
util: &str,
out_filename: &Path,
option: Option<&str>,
options: &[&str],
) {
let mut cmd = Command::new(util);
if let Some(option) = option {
cmd.arg(option);
}
cmd.args(options);

let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
Expand Down

0 comments on commit 317d65e

Please sign in to comment.