[Mlir-commits] [mlir] 3adb0ac - [mlir][py] Fix python modules build with clang-cl due to requiring exceptions
Markus Böck
llvmlistbot at llvm.org
Fri Jan 6 13:48:16 PST 2023
Author: Markus Böck
Date: 2023-01-06T22:48:14+01:00
New Revision: 3adb0ac183242cd18931dc0dc011385403727f92
URL: https://github.com/llvm/llvm-project/commit/3adb0ac183242cd18931dc0dc011385403727f92
DIFF: https://github.com/llvm/llvm-project/commit/3adb0ac183242cd18931dc0dc011385403727f92.diff
LOG: [mlir][py] Fix python modules build with clang-cl due to requiring exceptions
The generator expression previously used to enable exceptions would not work since the compiler id of clang-cl is Clang, even if used via clang-cl.
The patch fixes that by replacing the generator expression with simple logic, setting the right compiler flags for all MSVC like compilers (including clang-cl) and all GCC like compilers.
Differential Revision: https://reviews.llvm.org/D141155
Added:
Modified:
mlir/cmake/modules/AddMLIRPython.cmake
Removed:
################################################################################
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 706413776b9e5..9227c5186d736 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -607,15 +607,13 @@ function(add_mlir_python_extension libname extname)
# The extension itself must be compiled with RTTI and exceptions enabled.
# Also, some warning classes triggered by pybind11 are disabled.
- target_compile_options(${libname} PRIVATE
- $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
- # Enable RTTI and exceptions.
- -frtti -fexceptions
- >
- $<$<CXX_COMPILER_ID:MSVC>:
- # Enable RTTI and exceptions.
- /EHsc /GR>
- )
+ set(eh_rtti_enable)
+ if (MSVC)
+ set(eh_rtti_enable /EHsc /GR)
+ elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE)
+ set(eh_rtti_enable -frtti -fexceptions)
+ endif ()
+ target_compile_options(${libname} PRIVATE ${eh_rtti_enable})
# Configure the output to match python expectations.
set_target_properties(
More information about the Mlir-commits
mailing list