Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5570b0d

Browse files
committed
Test --compress-debug-sections with rust-lld.
1 parent c473dac commit 5570b0d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Test linking using `cc` with `rust-lld`, using the unstable CLI described in MCP 510
2+
// see https://github.com/rust-lang/compiler-team/issues/510 for more info
3+
4+
fn main() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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} or did not find {compression} at build time"
29+
),
30+
);
31+
}
32+
});
33+
}
34+
35+
fn main() {
36+
check_compression("zlib", "ZLIB");
37+
check_compression("zstd", "ZSTD");
38+
}

0 commit comments

Comments
 (0)