Skip to content

Commit 13e676f

Browse files
committed
Use the target cpu from the target spec when -Ctarget-cpu isn't used
Rather than nehalem on x86_64 and the cranelift default on other targets. Fixes #1148
1 parent cba05a7 commit 13e676f

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/lib.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn TargetIs
312312

313313
let flags = settings::Flags::new(flags_builder);
314314

315-
let isa_builder = match sess.opts.cg.target_cpu.as_deref() {
316-
Some("native") => cranelift_native::builder_with_options(true).unwrap(),
317-
Some(value) => {
315+
let isa_builder = match sess.opts.cg.target_cpu.as_deref().unwrap_or(sess.target.cpu.as_ref()) {
316+
"native" => cranelift_native::builder_with_options(true).unwrap(),
317+
value => {
318318
let mut builder =
319319
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
320320
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
@@ -325,18 +325,6 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn TargetIs
325325
}
326326
builder
327327
}
328-
None => {
329-
let mut builder =
330-
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
331-
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
332-
});
333-
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
334-
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
335-
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
336-
builder.enable("nehalem").unwrap();
337-
}
338-
builder
339-
}
340328
};
341329

342330
match isa_builder.finish(flags) {

0 commit comments

Comments
 (0)