mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-19 19:00:47 +00:00
Make link time optimization work on Linux (#2477)
This commit is contained in:
parent
25c260fdef
commit
4354023913
3 changed files with 15 additions and 10 deletions
|
|
@ -73,7 +73,7 @@ option(onnxruntime_ENABLE_MICROSOFT_INTERNAL "Use this option to enable/disable
|
|||
option(onnxruntime_USE_NUPHAR "Build with Nuphar" OFF)
|
||||
option(onnxruntime_USE_BRAINSLICE "Build with BrainSlice" OFF)
|
||||
option(onnxruntime_USE_TENSORRT "Build with TensorRT support" OFF)
|
||||
option(onnxruntime_ENABLE_LTO "Enable link time optimization" ON)
|
||||
option(onnxruntime_ENABLE_LTO "Enable link time optimization" OFF)
|
||||
option(onnxruntime_CROSS_COMPILING "Cross compiling onnx runtime" OFF)
|
||||
option(onnxruntime_BUILD_SERVER "Build ONNX Runtime Server" OFF)
|
||||
option(onnxruntime_USE_FULL_PROTOBUF "Use full protobuf" OFF)
|
||||
|
|
@ -121,17 +121,19 @@ if(onnxruntime_USE_OPENMP)
|
|||
endif()
|
||||
if(onnxruntime_ENABLE_LTO)
|
||||
#TODO: figure out why nsync doesn't work
|
||||
if(onnxruntime_USE_NSYNC)
|
||||
message(WARNING "IPO is not supported when nsync is in use")
|
||||
set(onnxruntime_ENABLE_LTO OFF)
|
||||
else()
|
||||
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT ipo_enabled OUTPUT ipo_output)
|
||||
if(NOT ipo_enabled)
|
||||
message(WARNING "IPO is not supported by this compiler")
|
||||
set(onnxruntime_ENABLE_LTO OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(UNIX)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
|
||||
set (CMAKE_LDFLAGS "${CMAKE_CXX_FLAGS} -flto")
|
||||
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ onnxruntime_add_include_to_target(onnxruntime_common date_interface)
|
|||
target_include_directories(onnxruntime_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT}
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public")
|
||||
if(onnxruntime_USE_NSYNC)
|
||||
target_compile_definitions(onnxruntime_common PUBLIC USE_NSYNC)
|
||||
target_compile_definitions(onnxruntime_common PUBLIC USE_NSYNC NSYNC_ATOMIC_CPP11)
|
||||
endif()
|
||||
|
||||
target_include_directories(onnxruntime_common PUBLIC ${eigen_INCLUDE_DIRS})
|
||||
|
|
|
|||
|
|
@ -251,8 +251,13 @@ if (onnxruntime_ENABLE_MICROSOFT_INTERNAL)
|
|||
include(onnxruntime_unittests_internal.cmake)
|
||||
endif()
|
||||
|
||||
if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
|
||||
set(ONNXRUNTIME_INTEROP_TEST_LIBS PRIVATE onnxruntime_language_interop onnxruntime_pyop)
|
||||
endif()
|
||||
|
||||
set(ONNXRUNTIME_TEST_LIBS
|
||||
onnxruntime_session
|
||||
${ONNXRUNTIME_INTEROP_TEST_LIBS}
|
||||
${onnxruntime_libs}
|
||||
${PROVIDERS_CUDA}
|
||||
${PROVIDERS_MKLDNN}
|
||||
|
|
@ -414,15 +419,13 @@ endif() # SingleUnitTestProject
|
|||
|
||||
# standalone test for inference session without environment
|
||||
# the normal test executables set up a default runtime environment, which we don't want here
|
||||
if(NOT ipo_enabled)
|
||||
#TODO: figure out why this test doesn't work with gcc LTO
|
||||
AddTest(
|
||||
TARGET onnxruntime_test_framework_session_without_environment_standalone
|
||||
SOURCES "${TEST_SRC_DIR}/framework/inference_session_without_environment/inference_session_without_environment_standalone_test.cc" "${TEST_SRC_DIR}/framework/test_main.cc"
|
||||
LIBS onnxruntime_test_utils ${ONNXRUNTIME_TEST_LIBS}
|
||||
DEPENDS ${onnxruntime_EXTERNAL_DEPENDENCIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# onnxruntime_ir_graph test data
|
||||
|
|
|
|||
Loading…
Reference in a new issue