Skip to content

Commit 6a7687c

Browse files
authored
[mlir][python] Support CLANG_CL (#121075)
1 parent a1328c0 commit 6a7687c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

mlir/cmake/modules/AddMLIR.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ function(add_mlir_aggregate name)
584584
# TODO: Should be transitive.
585585
set_target_properties(${name} PROPERTIES
586586
MLIR_AGGREGATE_EXCLUDE_LIBS "${_embed_libs}")
587-
if(MSVC)
587+
if(WIN32)
588588
set_property(TARGET ${name} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
589589
endif()
590590

mlir/cmake/modules/AddMLIRPython.cmake

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)