Skip to content

Commit

Permalink
Add ThinLTO support for clang
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin committed Jan 16, 2018
1 parent 8b87c4b commit c0ae812
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ OCV_OPTION(ENABLE_INSTRUMENTATION "Instrument functions to collect calls tra
OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CMAKE_COMPILER_IS_GNUCXX) )
OCV_OPTION(ENABLE_BUILD_HARDENING "Enable hardening of the resulting binaries (against security attacks, detects memory corruption, etc)" OFF)
OCV_OPTION(ENABLE_LTO "Enable Link Time Optimization" OFF IF CMAKE_COMPILER_IS_GNUCXX OR MSVC)
OCV_OPTION(ENABLE_THIN_LTO "Enable Thin LTO" OFF IF CMAKE_COMPILER_IS_CLANGCXX)
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
Expand Down
4 changes: 4 additions & 0 deletions cmake/OpenCVCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_extra_compiler_option(-flto)
endif()

if(ENABLE_THIN_LTO)
add_extra_compiler_option(-flto=thin)
endif()

set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} " MATCHES "-O")
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0")
Expand Down

0 comments on commit c0ae812

Please sign in to comment.