diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 125ed8d3e63d2..ac1bfcfb45afd 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -584,13 +584,23 @@ pub(crate) unsafe fn create_module<'ll>( ); } - if llvm_version >= (24, 0, 0) && sess.target.singlethread(&sess.internal_target_features) { - llvm::add_module_flag_str( - llmod, - llvm::ModuleFlagMergeBehavior::Error, - "thread-model", - "single", - ); + if llvm_version >= (24, 0, 0) { + if sess.target.singlethread(&sess.internal_target_features) { + llvm::add_module_flag_str( + llmod, + llvm::ModuleFlagMergeBehavior::Error, + "thread-model", + "single", + ); + } + if wants_wasm_eh(&sess.target) { + llvm::add_module_flag_str( + llmod, + llvm::ModuleFlagMergeBehavior::Error, + "exception-model", + "wasm", + ); + } } // Add module flags specified via -Z llvm_module_flag diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 494521ce18582..35d5597795a9e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -458,10 +458,11 @@ extern "C" void LLVMRustAddLibraryInfo(LLVMTargetMachineRef T, TLII.disableAllFunctions(); unwrap(PMR)->add(new TargetLibraryInfoWrapperPass(TLII)); #if LLVM_VERSION_GE(24, 0) - // LLVM 24 removed TargetOptions::EABIVersion; the EABI version is now - // derived from the target triple instead. - unwrap(PMR)->add(new RuntimeLibraryInfoWrapper( - Options->ExceptionModel, Options->MCOptions.ABIName, Options->VecLib)); + // LLVM 24 removed TargetOptions::EABIVersion and ExceptionModel; the EABI + // version and exception model are now derived from the target triple and + // module flags respectively instead. + unwrap(PMR)->add(new RuntimeLibraryInfoWrapper(Options->MCOptions.ABIName, + Options->VecLib)); #elif LLVM_VERSION_GE(22, 0) unwrap(PMR)->add(new RuntimeLibraryInfoWrapper( TargetTriple, Options->ExceptionModel, Options->FloatABIType,