Implement runtime checks for compilation settings (#3899)
* Implement runtime checks for compilation settings This commit fills out a few FIXME annotations by implementing run-time checks that when a `Module` is created it has compatible codegen settings for the current host (as `Module` is proof of "this code can run"). This is done by implementing new `Engine`-level methods which validate compiler settings. These settings are validated on `Module::new` as well as when loading serialized modules. Settings are split into two categories, one for "shared" top-level settings and one for ISA-specific settings. Both categories now have allow-lists hardcoded into `Engine` which indicate the acceptable values for each setting (if applicable). ISA-specific settings are checked with the Rust standard library's `std::is_x86_feature_detected!` macro. Other macros for other platforms are not stable at this time but can be added here if necessary. Closes #3897 * Fix fall-through logic to actually be correct * Use a `OnceCell`, not an `AtomicBool` * Fix some broken tests
This commit is contained in:
@@ -66,7 +66,7 @@ fn test_module_serialize_fail() -> Result<()> {
|
||||
)?;
|
||||
|
||||
let mut config = Config::new();
|
||||
config.cranelift_opt_level(OptLevel::None);
|
||||
config.static_memory_maximum_size(0);
|
||||
let mut store = Store::new(&Engine::new(&config)?, ());
|
||||
match unsafe { deserialize_and_instantiate(&mut store, &buffer) } {
|
||||
Ok(_) => bail!("expected failure at deserialization"),
|
||||
|
||||
Reference in New Issue
Block a user