cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
+cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
target-lexicon = "0.12.0"
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" }
#cranelift-module = { path = "../wasmtime/cranelift/module" }
+#cranelift-native = { path = ../wasmtime/cranelift/native" }
#cranelift-jit = { path = "../wasmtime/cranelift/jit" }
#cranelift-object = { path = "../wasmtime/cranelift/object" }
let flags = settings::Flags::new(flags_builder);
let variant = cranelift_codegen::isa::BackendVariant::MachInst;
- let mut isa_builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
+
+ let isa_builder = match sess.opts.cg.target_cpu.as_deref() {
+ Some("native") => {
+ let builder = cranelift_native::builder_with_options(variant, true).unwrap();
+ builder
+ }
+ Some(value) => {
+ let mut builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
+ if let Err(_) = builder.enable(value) {
+ sess.fatal("The target cpu isn't currently supported by Cranelift.");
+ }
+ builder
+ }
+ None => {
+ let mut builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
+ // Don't use "haswell" as the default, as it implies `has_lzcnt`.
+ // macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
+ builder.enable("nehalem").unwrap();
+ builder
+ }
+ };
- if let Some(target_cpu) = sess.opts.cg.target_cpu.as_ref() {
- isa_builder.enable(target_cpu).unwrap();
- } else {
- // Don't use "haswell" as the default, as it implies `has_lzcnt`.
- // macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
- isa_builder.enable("nehalem").unwrap();
- }
isa_builder.finish(flags)
}