diff --git a/lib/compiler-cranelift/src/compiler.rs b/lib/compiler-cranelift/src/compiler.rs index 8cc67bec59e..d6379cddf44 100644 --- a/lib/compiler-cranelift/src/compiler.rs +++ b/lib/compiler-cranelift/src/compiler.rs @@ -13,7 +13,7 @@ use crate::eh::{ use crate::translator::CraneliftUnwindInfo; use crate::{ address_map::get_function_address_map, - config::Cranelift, + config::{Cranelift, CraneliftOptLevel}, func_environ::{FuncEnvironment, get_function_name}, trampoline::{ FunctionBuilderContext, make_trampoline_dynamic_function, make_trampoline_function_call, @@ -726,11 +726,26 @@ impl Compiler for CraneliftCompiler { } fn deterministic_id(&self) -> String { + let mut components = vec![self.name()]; + components.push(match self.config.opt_level { + CraneliftOptLevel::None => "opt0", + CraneliftOptLevel::Speed => "opts", + CraneliftOptLevel::SpeedAndSize => "optsz", + }); if self.config.experimental_artifact { - String::from("cranelift-elf") - } else { - String::from("cranelift") + components.push("exp_art"); + } + if self.config.enable_nan_canonicalization { + components.push("nan_canon"); } + if self.config.enable_pic { + components.push("pic"); + } + if self.config.allow_experimental_unaligned_memory_accesses { + components.push("unaligned_mem"); + } + + components.join("-") } /// Get the middlewares for this compiler diff --git a/lib/compiler-cranelift/src/config.rs b/lib/compiler-cranelift/src/config.rs index 8ea7042811e..928b7b0c70e 100644 --- a/lib/compiler-cranelift/src/config.rs +++ b/lib/compiler-cranelift/src/config.rs @@ -110,14 +110,14 @@ pub enum CraneliftOptLevel { /// consumed by `wasmer_engine::Engine::new`. #[derive(Debug, Clone)] pub struct Cranelift { - enable_nan_canonicalization: bool, + pub(crate) enable_nan_canonicalization: bool, pub(crate) allow_experimental_unaligned_memory_accesses: bool, enable_verifier: bool, pub(crate) enable_perfmap: bool, pub(crate) debugger: Option, - enable_pic: bool, + pub(crate) enable_pic: bool, pub(crate) experimental_artifact: bool, - opt_level: CraneliftOptLevel, + pub(crate) opt_level: CraneliftOptLevel, /// The number of threads to use for compilation. pub num_threads: NonZero, /// The middleware chain. diff --git a/lib/compiler-llvm/src/compiler.rs b/lib/compiler-llvm/src/compiler.rs index 428dff04bd9..e4bcae343e0 100644 --- a/lib/compiler-llvm/src/compiler.rs +++ b/lib/compiler-llvm/src/compiler.rs @@ -185,20 +185,30 @@ impl Compiler for LLVMCompiler { } fn deterministic_id(&self) -> String { - format!( - "llvm-{}{}", - match self.config.opt_level { - inkwell::OptimizationLevel::None => "opt0", - inkwell::OptimizationLevel::Less => "optl", - inkwell::OptimizationLevel::Default => "optd", - inkwell::OptimizationLevel::Aggressive => "opta", - }, - if self.config.experimental_artifact { - "-elf" - } else { - "" - } - ) + let mut components = vec![self.name()]; + components.push(match self.config.opt_level { + inkwell::OptimizationLevel::None => "opt0", + inkwell::OptimizationLevel::Less => "optl", + inkwell::OptimizationLevel::Default => "optd", + inkwell::OptimizationLevel::Aggressive => "opta", + }); + if self.config.experimental_artifact { + components.push("exp_art"); + } + if self.config.enable_nan_canonicalization { + components.push("nan_canon"); + } + if self.config.enable_non_volatile_memops { + components.push("non_vol_mem"); + } + if self.config.is_pic { + components.push("pic"); + } + if self.config.enable_readonly_funcref_table { + components.push("ro_ftable"); + } + + components.join("-") } /// Get the middlewares for this compiler diff --git a/lib/compiler-llvm/src/config.rs b/lib/compiler-llvm/src/config.rs index 57ea2be61de..8792abfd7a5 100644 --- a/lib/compiler-llvm/src/config.rs +++ b/lib/compiler-llvm/src/config.rs @@ -117,7 +117,7 @@ pub struct LLVM { pub(crate) enable_perfmap: bool, pub(crate) debugger: Option, pub(crate) opt_level: LLVMOptLevel, - is_pic: bool, + pub(crate) is_pic: bool, pub(crate) experimental_artifact: bool, pub(crate) callbacks: Option, /// The middleware chain. diff --git a/lib/compiler-singlepass/src/compiler.rs b/lib/compiler-singlepass/src/compiler.rs index 0842b0a233b..c3a7b96407b 100644 --- a/lib/compiler-singlepass/src/compiler.rs +++ b/lib/compiler-singlepass/src/compiler.rs @@ -424,11 +424,18 @@ impl Compiler for SinglepassCompiler { } fn deterministic_id(&self) -> String { + let mut components = vec![self.name()]; if self.config.experimental_artifact { - String::from("singlepass-elf") - } else { - String::from("singlepass") + components.push("exp_art"); + } + if self.config.enable_nan_canonicalization { + components.push("nan_canon"); } + if self.config.allow_experimental_unaligned_memory_accesses { + components.push("unaligned_mem"); + } + + components.join("-") } /// Get the middlewares for this compiler