diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index dd297033098..98489643fd0 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -60,12 +60,14 @@ impl Compiler for CraneliftCompiler { module_translation_state: &ModuleTranslationState, function_body_inputs: PrimaryMap>, ) -> Result { - let isa = self.config().isa(target); + let config = self.config(); + let flags = self.config().flags(compile_info.features.simd); + let isa = config.isa(target, flags); let frontend_config = isa.frontend_config(); let memory_styles = &compile_info.memory_styles; let table_styles = &compile_info.table_styles; let mut module = (*compile_info.module).clone(); - self.config.middlewares.apply_on_module_info(&mut module); + config.middlewares.apply_on_module_info(&mut module); compile_info.module = Arc::new(module); let module = &compile_info.module; let signatures = module @@ -126,7 +128,7 @@ impl Compiler for CraneliftCompiler { &mut context.func, &mut func_env, *i, - &self.config, + &config, )?; let mut code_buf: Vec = Vec::new(); diff --git a/lib/compiler-cranelift/src/config.rs b/lib/compiler-cranelift/src/config.rs index 6a1f139c3f1..a956c57723c 100644 --- a/lib/compiler-cranelift/src/config.rs +++ b/lib/compiler-cranelift/src/config.rs @@ -32,7 +32,6 @@ pub enum CraneliftOptLevel { pub struct Cranelift { enable_nan_canonicalization: bool, enable_verifier: bool, - enable_simd: bool, enable_pic: bool, opt_level: CraneliftOptLevel, /// The middleware chain. @@ -48,7 +47,6 @@ impl Cranelift { enable_verifier: false, opt_level: CraneliftOptLevel::Speed, enable_pic: false, - enable_simd: true, middlewares: vec![], } } @@ -69,7 +67,7 @@ impl Cranelift { } /// Generates the ISA for the provided target - pub fn isa(&self, target: &Target) -> Box { + pub fn isa(&self, target: &Target, flags: settings::Flags) -> Box { let mut builder = lookup(target.triple().clone()).expect("construct Cranelift ISA for triple"); // Cpu Features @@ -120,11 +118,11 @@ impl Cranelift { builder.enable("has_lzcnt").expect("should be valid flag"); } - builder.finish(self.flags()) + builder.finish(flags) } /// Generates the flags for the compiler - pub fn flags(&self) -> settings::Flags { + pub fn flags(&self, enable_simd: bool) -> settings::Flags { let mut flags = settings::builder(); // There are two possible traps for division, and this way @@ -158,7 +156,7 @@ impl Cranelift { ) .expect("should be valid flag"); - let enable_simd = if self.enable_simd { "true" } else { "false" }; + let enable_simd = if enable_simd { "true" } else { "false" }; flags .set("enable_simd", enable_simd) .expect("should be valid flag");