Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use rustc_codegen_ssa::{CodegenResults, TargetConfig};
use rustc_log::tracing::info;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_session::Session;
use rustc_session::config::{OutputFilenames, PrintKind, PrintRequest};
use rustc_session::config::OutputFilenames;
use rustc_span::{Symbol, sym};
use rustc_target::spec::{Abi, Arch, Env, Os};

Expand Down Expand Up @@ -160,16 +160,6 @@ impl CodegenBackend for CraneliftCodegenBackend {
}
}

fn print(&self, req: &PrintRequest, out: &mut String, _sess: &Session) {
match req.kind {
// FIXME have a default impl that returns false
PrintKind::BackendHasZstd => {
out.push_str("false\n");
}
_ => {}
}
}

fn target_config(&self, sess: &Session) -> TargetConfig {
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
let target_features = match sess.target.arch {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ impl CodegenBackend for LlvmCodegenBackend {
}
writeln!(out).unwrap();
}
PrintKind::BackendHasZstd => {
let has_zstd = llvm::LLVMRustLLVMHasZstdCompression();
writeln!(out, "{has_zstd}").unwrap();
}
PrintKind::CodeModels => {
writeln!(out, "Available code models:").unwrap();
for name in &["tiny", "small", "kernel", "medium", "large"] {
Expand Down Expand Up @@ -314,6 +310,10 @@ impl CodegenBackend for LlvmCodegenBackend {
llvm_util::print_version();
}

fn has_zstd(&self) -> bool {
llvm::LLVMRustLLVMHasZstdCompression()
}

fn target_config(&self, sess: &Session) -> TargetConfig {
target_config(sess)
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ pub trait CodegenBackend {

fn print_version(&self) {}

/// Value printed by `--print=backend-has-zstd`.
///
/// Used by compiletest to determine whether tests involving zstd compression
/// (e.g. `-Zdebuginfo-compression=zstd`) should be executed or skipped.
fn has_zstd(&self) -> bool {
false
}

/// The metadata loader used to load rlib and dylib metadata.
///
/// Alternative codegen backends may want to use different rlib or dylib formats than the
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,11 @@ fn print_crate_info(
let calling_conventions = rustc_abi::all_names();
println_info!("{}", calling_conventions.join("\n"));
}
BackendHasZstd => {
let has_zstd: bool = codegen_backend.has_zstd();
println_info!("{has_zstd}");
}
RelocationModels
| BackendHasZstd
| CodeModels
| TlsModels
| TargetCPUs
Expand Down
4 changes: 4 additions & 0 deletions src/tools/compiletest/src/directives/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ fn has_symlinks() -> bool {
}

fn llvm_has_zstd(config: &Config) -> bool {
// FIXME(#149764): This actually queries the compiler's _default_ backend,
// which is usually LLVM, but can be another backend depending on the value
// of `rust.codegen-backends` in bootstrap.toml.

// The compiler already knows whether LLVM was built with zstd or not,
// so compiletest can just ask the compiler.
let output = query_rustc_output(
Expand Down
Loading