diff --git a/lib/clif-backend/src/lib.rs b/lib/clif-backend/src/lib.rs index 02bf479aa..59d3416ba 100644 --- a/lib/clif-backend/src/lib.rs +++ b/lib/clif-backend/src/lib.rs @@ -49,13 +49,15 @@ fn get_isa(config: Option<&CompilerConfig>) -> Box { if config.nan_canonicalization { builder.set("enable_nan_canonicalization", "true").unwrap(); } - enable_verifier = !config.disable_debug_mode_verification; + enable_verifier = config.enable_verification; } else { // Set defaults if no config found. - enable_verifier = true; + // NOTE: cfg(test) probably does nothing when not running `cargo test` + // on this crate + enable_verifier = cfg!(test) || cfg!(debug_assertions); } - if (cfg!(test) || cfg!(debug_assertions)) && enable_verifier { + if enable_verifier { builder.set("enable_verifier", "true").unwrap(); } else { builder.set("enable_verifier", "false").unwrap(); diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index 2b0f54c4f..c6235475d 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -106,7 +106,7 @@ impl BackendCompilerConfig { } /// Configuration data for the compiler -#[derive(Debug, Default)] +#[derive(Debug)] pub struct CompilerConfig { /// Symbol information generated from emscripten; used for more detailed debug messages pub symbol_map: Option>, @@ -136,11 +136,12 @@ pub struct CompilerConfig { /// Enabling this makes execution deterministic but increases runtime overhead. pub nan_canonicalization: bool, - /// Turns off verification that is done by default when `debug_assertions` are enabled - /// (for example in 'debug' builds). Enabling this flag will make compilation faster at the - /// cost of not detecting bugs in the compiler. The verification steps that this flag - /// disables are disabled by default in 'release' builds. - pub disable_debug_mode_verification: bool, + /// Turns on verification that is done by default when `debug_assertions` are enabled + /// (for example in 'debug' builds). Disabling this flag will make compilation faster + /// in debug mode at the cost of not detecting bugs in the compiler. + /// + /// These verifications are disabled by default in 'release' builds. + pub enable_verification: bool, pub features: Features, @@ -154,6 +155,30 @@ pub struct CompilerConfig { pub generate_debug_info: bool, } +impl Default for CompilerConfig { + fn default() -> Self { + Self { + symbol_map: Default::default(), + memory_bound_check_mode: Default::default(), + enforce_stack_check: Default::default(), + track_state: Default::default(), + full_preemption: Default::default(), + nan_canonicalization: Default::default(), + features: Default::default(), + triple: Default::default(), + cpu_name: Default::default(), + cpu_features: Default::default(), + backend_specific_config: Default::default(), + generate_debug_info: Default::default(), + + // Default verification to 'on' when testing or running in debug mode. + // NOTE: cfg(test) probably does nothing when not running `cargo test` + // on this crate + enable_verification: cfg!(test) || cfg!(debug_assertions), + } + } +} + impl CompilerConfig { /// Use this to check if we should be generating debug information. /// This function takes into account the features that runtime-core was diff --git a/lib/spectests/tests/spectest.rs b/lib/spectests/tests/spectest.rs index c3d1ecce7..1748816ed 100644 --- a/lib/spectests/tests/spectest.rs +++ b/lib/spectests/tests/spectest.rs @@ -337,6 +337,7 @@ mod tests { threads: true, }, nan_canonicalization: true, + enable_verification: true, ..Default::default() }; let module = compile_with_config(&module.into_vec(), config) @@ -776,6 +777,7 @@ mod tests { threads: true, }, nan_canonicalization: true, + enable_verification: true, ..Default::default() }; compile_with_config(&module.into_vec(), config) @@ -829,6 +831,7 @@ mod tests { threads: true, }, nan_canonicalization: true, + enable_verification: true, ..Default::default() }; compile_with_config(&module.into_vec(), config) @@ -881,6 +884,7 @@ mod tests { threads: true, }, nan_canonicalization: true, + enable_verification: true, ..Default::default() }; let module = compile_with_config(&module.into_vec(), config) @@ -977,6 +981,7 @@ mod tests { threads: true, }, nan_canonicalization: true, + enable_verification: true, ..Default::default() }; let module = compile_with_config(&module.into_vec(), config)