Skip to content

Commit 61f4dc2

Browse files
authored
build: disable LTO by default (#3440)
Disabled link-time optimization (LTO) by default and removed related conditions to simplify CMake configuration. Users need to manually enable LTO by `-DENABLE_LTO=ON` if they want LTO.
1 parent 2815e08 commit 61f4dc2

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,11 @@ option(ASAN_WITH_LSAN "enable leak sanitizer while address sanitizer is enabled"
3030
option(ENABLE_STATIC_LIBSTDCXX "link kvrocks with static library of libstd++ instead of shared library" ON)
3131
option(ENABLE_LUAJIT "enable use of luaJIT instead of lua" ON)
3232
option(ENABLE_OPENSSL "enable openssl to support tls connection" OFF)
33-
option(ENABLE_LTO "enable link-time optimization" ON)
33+
option(ENABLE_LTO "enable link-time optimization" OFF)
3434
set(SYMBOLIZE_BACKEND "" CACHE STRING "symbolization backend library for cpptrace (libbacktrace, libdwarf, or empty)")
3535
set(PORTABLE 0 CACHE STRING "build a portable binary (disable arch-specific optimizations)")
3636
option(ENABLE_NEW_ENCODING "enable new encoding (#1033) for storing 64bit size and expire time in milliseconds" ON)
3737

38-
# to save build time in debug mode
39-
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
40-
set(ENABLE_LTO OFF)
41-
endif()
42-
4338
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
4439
cmake_policy(SET CMP0135 NEW)
4540
endif()
@@ -144,7 +139,6 @@ endif()
144139

145140
if (CMAKE_HOST_APPLE)
146141
set(DISABLE_JEMALLOC ON)
147-
set(ENABLE_LTO OFF)
148142
endif ()
149143

150144
if(NOT DISABLE_JEMALLOC)
@@ -298,17 +292,6 @@ else()
298292
target_compile_definitions(kvrocks_objs PUBLIC METADATA_ENCODING_VERSION=0)
299293
endif()
300294

301-
# disable LTO on ARM due to toolchain stability issues
302-
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER)
303-
if(CMAKE_SYSTEM_PROCESSOR_LOWER MATCHES "^(aarch64|arm64|arm)")
304-
set(ENABLE_LTO OFF)
305-
endif()
306-
307-
# disable LTO on GCC <= 9 due to an ICE
308-
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))
309-
set(ENABLE_LTO OFF)
310-
endif()
311-
312295
if(ENABLE_LTO)
313296
include(CheckIPOSupported)
314297
check_ipo_supported(RESULT ipo_result OUTPUT ipo_output LANGUAGES CXX)

0 commit comments

Comments
 (0)