diff options
| author | bors <bors@rust-lang.org> | 2024-01-26 22:12:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-26 22:12:35 +0000 |
| commit | c073f56a416b541fc66e46fb5265dad870da9229 (patch) | |
| tree | c55971383f7dc516ca9b27a80dc9d949cd583c48 /compiler/rustc_codegen_cranelift/src/lib.rs | |
| parent | e7bbe8ce933123a8e327c79e38bcb790595e6a65 (diff) | |
| parent | 37018026f0a4b119778e07d6a44b149de8dcfd0c (diff) | |
Auto merge of #120395 - bjorn3:sync_cg_clif-2024-01-26, r=bjorn3
Subtree sync for rustc_codegen_cranelift A couple of fixes as well as an update to Cranelift 0.104, which includes a fix for the ABI of `Option<u128>`. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/lib.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/lib.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index b482f0dd2f0..416f87fcc87 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -18,7 +18,6 @@ extern crate rustc_fs_util; extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; -extern crate rustc_interface; extern crate rustc_metadata; extern crate rustc_session; extern crate rustc_span; @@ -42,7 +41,7 @@ use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_session::config::OutputFilenames; use rustc_session::Session; -use rustc_span::Symbol; +use rustc_span::{sym, Symbol}; pub use crate::config::*; use crate::prelude::*; @@ -190,8 +189,17 @@ impl CodegenBackend for CraneliftCodegenBackend { } } - fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> { - vec![] // FIXME necessary for #[cfg(target_feature] + fn target_features(&self, sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> { + // FIXME return the actually used target features. this is necessary for #[cfg(target_feature)] + if sess.target.arch == "x86_64" && sess.target.os != "none" { + // x86_64 mandates SSE2 support + vec![Symbol::intern("fxsr"), sym::sse, Symbol::intern("sse2")] + } else if sess.target.arch == "aarch64" && sess.target.os != "none" { + // AArch64 mandates Neon support + vec![sym::neon] + } else { + vec![] + } } fn print_version(&self) { @@ -305,16 +313,13 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::Tar let flags = settings::Flags::new(flags_builder); let isa_builder = match sess.opts.cg.target_cpu.as_deref() { - Some("native") => { - let builder = cranelift_native::builder_with_options(true).unwrap(); - builder - } + Some("native") => cranelift_native::builder_with_options(true).unwrap(), Some(value) => { let mut builder = cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| { sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err)); }); - if let Err(_) = builder.enable(value) { + if builder.enable(value).is_err() { sess.dcx() .fatal("the specified target cpu isn't currently supported by Cranelift."); } |
