diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
commit | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (patch) | |
tree | 6a77b463f700e090df586672c26b9fe765fd115b /mlir/cmake/modules/AddMLIRPython.cmake | |
parent | ec6892d1c979ce0b84c86918d5cdbb03037b409a (diff) | |
parent | 6d16b1c5c468a79ecf867293023c89ac518ecdda (diff) | |
download | llvm-users/chapuni/cov/single/nextcount-base.zip llvm-users/chapuni/cov/single/nextcount-base.tar.gz llvm-users/chapuni/cov/single/nextcount-base.tar.bz2 |
Merge branch 'users/chapuni/cov/single/pair' into users/chapuni/cov/single/nextcount-baseusers/chapuni/cov/single/nextcount-base
Diffstat (limited to 'mlir/cmake/modules/AddMLIRPython.cmake')
-rw-r--r-- | mlir/cmake/modules/AddMLIRPython.cmake | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake index 53a7013..717a503 100644 --- a/mlir/cmake/modules/AddMLIRPython.cmake +++ b/mlir/cmake/modules/AddMLIRPython.cmake @@ -512,7 +512,7 @@ function(add_mlir_python_common_capi_library name) ) add_dependencies(${name} ${_header_sources_target}) - if(MSVC) + if(WIN32) set_property(TARGET ${name} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() set_target_properties(${name} PROPERTIES @@ -649,6 +649,15 @@ function(add_mlir_python_extension libname extname) message(FATAL_ERROR "Unhandled arguments to add_mlir_python_extension(${libname}, ... : ${ARG_UNPARSED_ARGUMENTS}") endif() + # The extension itself must be compiled with RTTI and exceptions enabled. + # Also, some warning classes triggered by pybind11 are disabled. + set(eh_rtti_enable) + if (MSVC) + set(eh_rtti_enable /EHsc /GR) + elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL) + set(eh_rtti_enable -frtti -fexceptions) + endif () + # The actual extension library produces a shared-object or DLL and has # sources that must be compiled in accordance with pybind11 needs (RTTI and # exceptions). @@ -671,18 +680,18 @@ function(add_mlir_python_extension libname extname) -Wno-nested-anon-types -Wno-c++98-compat-extra-semi -Wno-covered-switch-default + ${eh_rtti_enable} ) endif() + + if(APPLE) + # NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind + # doesn't declare this API as undefined in its linker flags. So we need to declare it as such + # for downstream users that do not do something like `-undefined dynamic_lookup`. + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-U -Wl,_PyClassMethod_New") + endif() endif() - # The extension itself must be compiled with RTTI and exceptions enabled. - # Also, some warning classes triggered by pybind11 are disabled. - 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. |