|
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` |
2 | 5 |
|
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 |
5 | 8 | //@ only-linux
|
6 | 9 | //@ ignore-cross-compile
|
7 | 10 |
|
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}; |
11 | 12 |
|
12 | 13 | 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) { |
13 | 26 | run_in_tmpdir(|| {
|
14 |
| - let out = rustc() |
| 27 | + let mut rustc = Rustc::new(); |
| 28 | + rustc |
15 | 29 | .arg("-Zlinker-features=+lld")
|
16 | 30 | .arg("-Clink-self-contained=+linker")
|
17 | 31 | .arg("-Zunstable-options")
|
18 | 32 | .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(); |
22 | 35 | llvm_readobj().arg("-t").arg("main").run().assert_stdout_contains(to_find);
|
23 | 36 | });
|
24 | 37 | }
|
|
0 commit comments