-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #135034 - Noratrieb:strip-correctly, r=<try>
Pass objcopy args for stripping on OSX When `-Cstrip` was changed in #131405 to use the bundled rust-objcopy instead of /usr/bin/strip on OSX, strip-like arguments were preserved. But strip and objcopy are, while being the same binary, different, they have different defaults depending on which binary they are. Notably, strip strips everything by default, and objcopy doesn't strip anything by default. Additionally, `-S` actually means `--strip-all`, so debuginfo stripped everything and symbols didn't strip anything. We now correctly pass `--strip-debug` and `--strip-all`. fixes #135028 try-jobs: aarch64-apple
- Loading branch information
Showing
3 changed files
with
38 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fn main() { | ||
hey_i_get_compiled(); | ||
} | ||
|
||
#[inline(never)] | ||
fn hey_i_get_compiled() { | ||
println!("Hi! Do or do not strip me, your choice."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@ ignore-windows Windows does not actually strip | ||
|
||
// Test that -Cstrip correctly strips/preserves debuginfo and symbols. | ||
|
||
use run_make_support::{bin_name, llvm_dwarfdump, llvm_nm, rustc}; | ||
|
||
fn main() { | ||
// -Cstrip=none should preserve symbols and debuginfo. | ||
// We use DW_AT (the start of a DWARF attribute name) to ensure that some debuginfo is present. | ||
rustc().arg("hello.rs").arg("-Cstrip=none").run(); | ||
llvm_nm().input(bin_name("hello")).run().assert_stdout_contains("hey_i_get_compiled"); | ||
llvm_dwarfdump().input(bin_name("hello")).run().assert_stdout_contains("DW_AT"); | ||
|
||
// -Cstrip=debuginfo should preserve symbols and strip debuginfo. | ||
rustc().arg("hello.rs").arg("-Cstrip=debuginfo").run(); | ||
llvm_nm().input(bin_name("hello")).run().assert_stdout_contains("hey_i_get_compiled"); | ||
llvm_dwarfdump().input(bin_name("hello")).run().assert_stdout_not_contains("DW_AT"); | ||
|
||
// -Cstrip=symbols should strip symbols and strip debuginfo. | ||
rustc().arg("hello.rs").arg("-Cstrip=symbols").run(); | ||
llvm_nm().input(bin_name("hello")).run().assert_stderr_contains("no symbols"); | ||
llvm_dwarfdump().input(bin_name("hello")).run().assert_stdout_not_contains("DW_AT"); | ||
} |