Skip to content

Commit 92f5144

Browse files
authored
Rollup merge of #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.
2 parents 6e1c115 + 02f51ec commit 92f5144

File tree

1 file changed

+12
-10
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+12
-10
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1117,14 +1117,14 @@ fn link_natively(
11171117
let stripcmd = "rust-objcopy";
11181118
match (strip, crate_type) {
11191119
(Strip::Debuginfo, _) => {
1120-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
1120+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-S"])
11211121
}
11221122
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
11231123
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1124-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
1124+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
11251125
}
11261126
(Strip::Symbols, _) => {
1127-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
1127+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[])
11281128
}
11291129
(Strip::None, _) => {}
11301130
}
@@ -1141,7 +1141,7 @@ fn link_natively(
11411141
match strip {
11421142
// Always preserve the symbol table (-x).
11431143
Strip::Debuginfo => {
1144-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
1144+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &["-x"])
11451145
}
11461146
// Strip::Symbols is handled via the --strip-all linker option.
11471147
Strip::Symbols => {}
@@ -1158,11 +1158,15 @@ fn link_natively(
11581158
match strip {
11591159
Strip::Debuginfo => {
11601160
// FIXME: AIX's strip utility only offers option to strip line number information.
1161-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-l"))
1161+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[
1162+
"-X32_64", "-l",
1163+
])
11621164
}
11631165
Strip::Symbols => {
11641166
// Must be noted this option might remove symbol __aix_rust_metadata and thus removes .info section which contains metadata.
1165-
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-r"))
1167+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[
1168+
"-X32_64", "-r",
1169+
])
11661170
}
11671171
Strip::None => {}
11681172
}
@@ -1181,12 +1185,10 @@ fn strip_symbols_with_external_utility(
11811185
sess: &Session,
11821186
util: &str,
11831187
out_filename: &Path,
1184-
option: Option<&str>,
1188+
options: &[&str],
11851189
) {
11861190
let mut cmd = Command::new(util);
1187-
if let Some(option) = option {
1188-
cmd.arg(option);
1189-
}
1191+
cmd.args(options);
11901192

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

0 commit comments

Comments
 (0)