Skip to content

Commit

Permalink
support lto (#6140)
Browse files Browse the repository at this point in the history
* support lto

* use relative path

* add another variable to control lto

* remove unnecessary code
  • Loading branch information
sfc-gh-zyang authored Dec 14, 2021
1 parent 1452680 commit 7697460
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmake/ConfigureCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,19 @@ else()
set(DTRACE_PROBES 1)
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
set(USE_LTO OFF CACHE BOOL "Do link time optimization")
if (USE_LTO)
set(USE_LTO OFF CACHE BOOL "Do link time optimization")
if (USE_LTO)
if (CLANG)
set(CLANG_LTO_STRATEGY "Thin" CACHE STRING "LLVM LTO strategy (Thin, or Full)")
if (CLANG_LTO_STRATEGY STREQUAL "Full")
add_compile_options($<$<CONFIG:Release>:-flto=full>)
else()
add_compile_options($<$<CONFIG:Release>:-flto=thin>)
endif()
set(CMAKE_RANLIB "llvm-ranlib")
set(CMAKE_AR "llvm-ar")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options($<$<CONFIG:Release>:-flto>)
set(CMAKE_AR "gcc-ar")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
Expand Down

0 comments on commit 7697460

Please sign in to comment.