@@ -512,7 +512,7 @@ function(add_mlir_python_common_capi_library name)
512512 )
513513 add_dependencies (${name} ${_header_sources_target} )
514514
515- if (MSVC )
515+ if (WIN32 )
516516 set_property (TARGET ${name} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON )
517517 endif ()
518518 set_target_properties (${name} PROPERTIES
@@ -649,6 +649,15 @@ function(add_mlir_python_extension libname extname)
649649 message (FATAL_ERROR "Unhandled arguments to add_mlir_python_extension(${libname} , ... : ${ARG_UNPARSED_ARGUMENTS} " )
650650 endif ()
651651
652+ # The extension itself must be compiled with RTTI and exceptions enabled.
653+ # Also, some warning classes triggered by pybind11 are disabled.
654+ set (eh_rtti_enable)
655+ if (MSVC )
656+ set (eh_rtti_enable /EHsc /GR)
657+ elseif (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)
658+ set (eh_rtti_enable -frtti -fexceptions)
659+ endif ()
660+
652661 # The actual extension library produces a shared-object or DLL and has
653662 # sources that must be compiled in accordance with pybind11 needs (RTTI and
654663 # exceptions).
@@ -671,18 +680,11 @@ function(add_mlir_python_extension libname extname)
671680 -Wno-nested-anon-types
672681 -Wno-c++98-compat-extra-semi
673682 -Wno-covered-switch-default
683+ ${eh_rtti_enable}
674684 )
675685 endif ()
676686 endif ()
677687
678- # The extension itself must be compiled with RTTI and exceptions enabled.
679- # Also, some warning classes triggered by pybind11 are disabled.
680- set (eh_rtti_enable)
681- if (MSVC )
682- set (eh_rtti_enable /EHsc /GR)
683- elseif (LLVM_COMPILER_IS_GCC_COMPATIBLE)
684- set (eh_rtti_enable -frtti -fexceptions)
685- endif ()
686688 target_compile_options (${libname} PRIVATE ${eh_rtti_enable} )
687689
688690 # Configure the output to match python expectations.
0 commit comments