1
Fork 0

Change to pass "strip" options in an array of string slices and add option "-X32_64" for AIX.

This commit is contained in:
Xing Xue 2024-11-19 14:16:47 -05:00
parent 7d40450b2d
commit 02f51ec2bd

View file

@ -1107,14 +1107,14 @@ fn link_natively(
let stripcmd = "rust-objcopy"; let stripcmd = "rust-objcopy";
match (strip, crate_type) { match (strip, crate_type) {
(Strip::Debuginfo, _) => { (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) // Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => { (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, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None) strip_symbols_with_external_utility(sess, stripcmd, out_filename, &[])
} }
(Strip::None, _) => {} (Strip::None, _) => {}
} }
@ -1131,7 +1131,7 @@ fn link_natively(
match strip { match strip {
// Always preserve the symbol table (-x). // Always preserve the symbol table (-x).
Strip::Debuginfo => { 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 is handled via the --strip-all linker option.
Strip::Symbols => {} Strip::Symbols => {}
@ -1148,11 +1148,15 @@ fn link_natively(
match strip { match strip {
Strip::Debuginfo => { Strip::Debuginfo => {
// FIXME: AIX's strip utility only offers option to strip line number information. // 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 => { Strip::Symbols => {
// Must be noted this option might remove 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_symbols_with_external_utility(sess, stripcmd, out_filename, &[
"-X32_64", "-r",
])
} }
Strip::None => {} Strip::None => {}
} }
@ -1165,12 +1169,10 @@ fn strip_symbols_with_external_utility(
sess: &Session, sess: &Session,
util: &str, util: &str,
out_filename: &Path, out_filename: &Path,
option: Option<&str>, options: &[&str],
) { ) {
let mut cmd = Command::new(util); let mut cmd = Command::new(util);
if let Some(option) = option { cmd.args(options);
cmd.arg(option);
}
let mut new_path = sess.get_tools_search_paths(false); let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") { if let Some(path) = env::var_os("PATH") {