Skip to content

Commit 9e73f56

Browse files
committed
Make --print=backend-has-zstd work by default on any backend
Using a defaulted `CodegenBackend` method that querying for zstd support should automatically print a safe value of `false` on any backend that doesn't specifically indicate the presence or absence of zstd.
1 parent 0b96731 commit 9e73f56

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ impl CodegenBackend for LlvmCodegenBackend {
257257
}
258258
writeln!(out).unwrap();
259259
}
260-
PrintKind::BackendHasZstd => {
261-
let has_zstd = llvm::LLVMRustLLVMHasZstdCompression();
262-
writeln!(out, "{has_zstd}").unwrap();
263-
}
264260
PrintKind::CodeModels => {
265261
writeln!(out, "Available code models:").unwrap();
266262
for name in &["tiny", "small", "kernel", "medium", "large"] {
@@ -314,6 +310,10 @@ impl CodegenBackend for LlvmCodegenBackend {
314310
llvm_util::print_version();
315311
}
316312

313+
fn has_zstd(&self) -> bool {
314+
llvm::LLVMRustLLVMHasZstdCompression()
315+
}
316+
317317
fn target_config(&self, sess: &Session) -> TargetConfig {
318318
target_config(sess)
319319
}

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ pub trait CodegenBackend {
7878

7979
fn print_version(&self) {}
8080

81+
/// Value printed by `--print=backend-has-zstd`.
82+
///
83+
/// Used by compiletest to determine whether tests involving zstd compression
84+
/// (e.g. `-Zdebuginfo-compression=zstd`) should be executed or skipped.
85+
fn has_zstd(&self) -> bool {
86+
false
87+
}
88+
8189
/// The metadata loader used to load rlib and dylib metadata.
8290
///
8391
/// Alternative codegen backends may want to use different rlib or dylib formats than the

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,11 @@ fn print_crate_info(
798798
let calling_conventions = rustc_abi::all_names();
799799
println_info!("{}", calling_conventions.join("\n"));
800800
}
801+
BackendHasZstd => {
802+
let has_zstd: bool = codegen_backend.has_zstd();
803+
println_info!("{has_zstd}");
804+
}
801805
RelocationModels
802-
| BackendHasZstd
803806
| CodeModels
804807
| TlsModels
805808
| TargetCPUs

0 commit comments

Comments
 (0)