mirror of https://github.com/llvm/torch-mlir
Fix some compiler option and warning levels.
parent
48a0b0ec7f
commit
adb8094108
|
@ -20,6 +20,7 @@ endif()
|
|||
project(npcomp LANGUAGES CXX C)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Options and settings
|
||||
|
@ -65,6 +66,14 @@ set(NPCOMP_TABLEGEN_ARGS "")
|
|||
# IREE configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function(npcomp_add_iree_src)
|
||||
# TODO: Find a way to fix this upstream as globally demoting warnings
|
||||
# like this is a really bad thing to be doing. Also, Abseil seems to try
|
||||
# really hard to keep us from touching these so some still get through.
|
||||
add_compile_options(-Wno-sign-compare -Wno-unused-template)
|
||||
add_subdirectory("${NPCOMP_IREE_SRCDIR}" "iree" EXCLUDE_FROM_ALL)
|
||||
endfunction()
|
||||
|
||||
if(NPCOMP_ENABLE_IREE)
|
||||
add_compile_definitions(NPCOMP_ENABLE_IREE)
|
||||
string(APPEND NPCOMP_TABLEGEN_ARGS "-DNPCOMP_ENABLE_IREE")
|
||||
|
@ -74,7 +83,7 @@ if(NPCOMP_ENABLE_IREE)
|
|||
set(IREE_BUILD_SAMPLES OFF CACHE BOOL "Override IREE setting" FORCE)
|
||||
set(IREE_BUILD_PYTHON_BINDINGS ON CACHE BOOL "Override IREE setting" FORCE)
|
||||
set(IREE_MLIR_DEP_MODE "DISABLED" CACHE STRING "Override IREE setting")
|
||||
add_subdirectory("${NPCOMP_IREE_SRCDIR}" "iree" EXCLUDE_FROM_ALL)
|
||||
npcomp_add_iree_src()
|
||||
else()
|
||||
find_package(IREE REQUIRED CONFIG)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
function(npcomp_iree_target_compile_options target)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wno-sign-compare
|
||||
>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:>
|
||||
)
|
||||
endfunction()
|
|
@ -0,0 +1,14 @@
|
|||
function(npcomp_python_target_compile_options target)
|
||||
target_compile_options(${target} PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
# Enable RTTI and exceptions.
|
||||
-frtti -fexceptions
|
||||
# Noisy pybind warnings
|
||||
-Wno-unused-value
|
||||
-Wno-covered-switch-default
|
||||
>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
# Enable RTTI and exceptions.
|
||||
/EHsc /GR>
|
||||
)
|
||||
endfunction()
|
|
@ -2,14 +2,12 @@
|
|||
# NPCOMPBackendIREEPythonModule
|
||||
################################################################################
|
||||
|
||||
include(NpcompPython)
|
||||
include(NpcompIREEBackend)
|
||||
|
||||
set(PYBIND_SOURCES
|
||||
PythonModule.cpp
|
||||
)
|
||||
set_source_files_properties(
|
||||
${PYBIND_SOURCES}
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
"-frtti -fexceptions")
|
||||
|
||||
add_library(NPCOMPBackendIREEPythonModule
|
||||
${PYBIND_SOURCES}
|
||||
)
|
||||
|
@ -20,3 +18,6 @@ target_link_libraries(NPCOMPBackendIREEPythonModule
|
|||
iree_compiler_Dialect_HAL_Transforms_Transforms
|
||||
iree_compiler_Dialect_VM_Transforms_Transforms
|
||||
)
|
||||
|
||||
npcomp_python_target_compile_options(NPCOMPBackendIREEPythonModule)
|
||||
npcomp_iree_target_compile_options(NPCOMPBackendIREEPythonModule)
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
# NPCOMPPythonCommon
|
||||
################################################################################
|
||||
|
||||
if(MSVC)
|
||||
# Exceptions and RTTI
|
||||
set(extension_cflags "/EHsc /GR")
|
||||
else()
|
||||
set(extension_cflags "-frtti -fexceptions")
|
||||
endif()
|
||||
include(NpcompPython)
|
||||
|
||||
set(PYBIND_SOURCES
|
||||
MlirInit.cpp
|
||||
|
@ -17,9 +12,6 @@ set(PYBIND_SOURCES
|
|||
PybindUtils.cpp
|
||||
CoreDialects.cpp
|
||||
)
|
||||
set_source_files_properties(
|
||||
${PYBIND_SOURCES}
|
||||
PROPERTIES COMPILE_FLAGS "${extension_cflags}")
|
||||
|
||||
add_library(NPCOMPPythonCommon
|
||||
${PYBIND_SOURCES}
|
||||
|
@ -43,3 +35,5 @@ target_link_libraries(NPCOMPPythonCommon
|
|||
MLIRPass
|
||||
MLIRTransforms
|
||||
)
|
||||
|
||||
npcomp_python_target_compile_options(NPCOMPPythonCommon)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# Native extensions
|
||||
################################################################################
|
||||
|
||||
include(NpcompPython)
|
||||
|
||||
# Normally on unix-like platforms, extensions are built as "MODULE" libraries
|
||||
# and do not explicitly link to the python shared object. This allows for
|
||||
# come greater deployment flexibility since the extension will bind to
|
||||
|
@ -15,13 +17,6 @@
|
|||
set(NPCOMP_PYEXT_LINK_MODE SHARED)
|
||||
set(NPCOMP_PYEXT_LIBADD ${PYTHON_LIBRARIES})
|
||||
|
||||
if(MSVC)
|
||||
# Exceptions and RTTI
|
||||
set(extension_cflags "/EHsc /GR")
|
||||
else()
|
||||
set(extension_cflags "-frtti -fexceptions")
|
||||
endif()
|
||||
|
||||
if(NPCOMP_ENABLE_IREE)
|
||||
list(APPEND NPCOMP_PYEXT_LIBADD NPCOMPBackendIREEPythonModule)
|
||||
endif()
|
||||
|
@ -92,3 +87,5 @@ target_link_libraries(${extension_target}
|
|||
|
||||
${NPCOMP_PYEXT_LIBADD}
|
||||
)
|
||||
|
||||
npcomp_python_target_compile_options(${extension_target})
|
||||
|
|
Loading…
Reference in New Issue