Skip to content

Commit f15a539

Browse files
committedAug 10, 2024·
expand zstd debuginfo compression test
it now checks zlib and zstd, via rustc and rust-lld
1 parent 70c5fd7 commit f15a539

File tree

1 file changed

+23
-10
lines changed
  • tests/run-make/compressed-debuginfo-zstd

1 file changed

+23
-10
lines changed
 

‎tests/run-make/compressed-debuginfo-zstd/rmake.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
// Checks the `compress-debug-sections` option on rust-lld.
1+
// Checks debuginfo compression both for the always-enabled zlib, and when the optional zstd is
2+
// enabled:
3+
// - via rustc's `debuginfo-compression`,
4+
// - and via rust-lld's `compress-debug-sections`
25

3-
//@ needs-rust-lld
4-
//@ needs-llvm-zstd
6+
//@ needs-llvm-zstd: we want LLVM/LLD to be built with zstd support
7+
//@ needs-rust-lld: the system linker will most likely not support zstd
58
//@ only-linux
69
//@ ignore-cross-compile
710

8-
// FIXME: This test isn't comprehensive and isn't covering all possible combinations.
9-
10-
use run_make_support::{llvm_readobj, run_in_tmpdir, rustc};
11+
use run_make_support::{llvm_readobj, run_in_tmpdir, Rustc};
1112

1213
fn check_compression(compression: &str, to_find: &str) {
14+
// check compressed debug sections via rustc flag
15+
prepare_and_check(to_find, |rustc| {
16+
rustc.arg(&format!("-Zdebuginfo-compression={compression}"))
17+
});
18+
19+
// check compressed debug sections via rust-lld flag
20+
prepare_and_check(to_find, |rustc| {
21+
rustc.link_arg(&format!("-Wl,--compress-debug-sections={compression}"))
22+
});
23+
}
24+
25+
fn prepare_and_check<F: FnOnce(&mut Rustc) -> &mut Rustc>(to_find: &str, prepare_rustc: F) {
1326
run_in_tmpdir(|| {
14-
let out = rustc()
27+
let mut rustc = Rustc::new();
28+
rustc
1529
.arg("-Zlinker-features=+lld")
1630
.arg("-Clink-self-contained=+linker")
1731
.arg("-Zunstable-options")
1832
.arg("-Cdebuginfo=full")
19-
.link_arg(&format!("-Wl,--compress-debug-sections={compression}"))
20-
.input("main.rs")
21-
.run();
33+
.input("main.rs");
34+
prepare_rustc(&mut rustc).run();
2235
llvm_readobj().arg("-t").arg("main").run().assert_stdout_contains(to_find);
2336
});
2437
}

0 commit comments

Comments
 (0)