diff --git a/lib/compiler-llvm/src/compiler.rs b/lib/compiler-llvm/src/compiler.rs index dca69557a..a8c5d86ce 100644 --- a/lib/compiler-llvm/src/compiler.rs +++ b/lib/compiler-llvm/src/compiler.rs @@ -211,7 +211,7 @@ impl Compiler for LLVMCompiler { fn experimental_native_compile_module<'data, 'module>( &self, target: &Target, - module: &'module CompileModuleInfo, + compile_info: &'module mut CompileModuleInfo, module_translation: &ModuleTranslationState, // The list of function bodies function_body_inputs: &PrimaryMap>, @@ -219,9 +219,13 @@ impl Compiler for LLVMCompiler { // The metadata to inject into the wasmer_metadata section of the object file. wasmer_metadata: &[u8], ) -> Option, CompileError>> { + let mut module = (*compile_info.module).clone(); + self.config.middlewares.apply_on_module_info(&mut module); + compile_info.module = Arc::new(module); + Some(self.compile_native_object( target, - module, + compile_info, module_translation, function_body_inputs, symbol_registry, diff --git a/lib/compiler/src/compiler.rs b/lib/compiler/src/compiler.rs index 7f2997115..6d462851e 100644 --- a/lib/compiler/src/compiler.rs +++ b/lib/compiler/src/compiler.rs @@ -96,7 +96,7 @@ pub trait Compiler { fn experimental_native_compile_module<'data, 'module>( &self, _target: &Target, - _module: &'module CompileModuleInfo, + _module: &'module mut CompileModuleInfo, _module_translation: &ModuleTranslationState, // The list of function bodies _function_body_inputs: &PrimaryMap>,