Skip to content

Commit 9f3376e

Browse files
committed
Test --compress-debug-sections with rust-lld.
1 parent 6e9afb8 commit 9f3376e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Checks the `compress-debug-sections` option on rust-lld.
2+
3+
//@ needs-rust-lld
4+
//@ only-linux
5+
//@ ignore-cross-compile
6+
7+
// FIXME: This test isn't comprehensive and isn't covering all possible combinations.
8+
9+
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc};
10+
11+
fn check_compression(compression: &str, to_find: &str) {
12+
run_in_tmpdir(|| {
13+
let out = rustc()
14+
.arg("-Zlinker-features=+lld")
15+
.arg("-Clink-self-contained=+linker")
16+
.arg("-Zunstable-options")
17+
.arg("-Cdebuginfo=full")
18+
.link_arg(&format!("-Wl,--compress-debug-sections={compression}"))
19+
.input("main.rs")
20+
.run_unchecked();
21+
let stderr = out.stderr_utf8();
22+
if stderr.is_empty() {
23+
llvm_readobj().arg("-t").arg("main").run().assert_stdout_contains(to_find);
24+
} else {
25+
assert_contains(
26+
stderr,
27+
format!(
28+
"LLVM was not built with LLVM_ENABLE_{to_find} \
29+
or did not find {compression} at build time"
30+
),
31+
);
32+
}
33+
});
34+
}
35+
36+
fn main() {
37+
check_compression("zlib", "ZLIB");
38+
check_compression("zstd", "ZSTD");
39+
}

0 commit comments

Comments
 (0)