Skip to content

Commit 7154ac7

Browse files
authored
Document why we don't enable LTO on RelWithDebInfo (#1588)
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 6b2b0bc commit 7154ac7

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

cmake/common/defaults.cmake

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,24 @@ endif()
9090
# - https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
9191
# - https://llvm.org/docs/FatLTO.html
9292

93-
if(SOURCEMETA_COMPILER_GCC AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS)
94-
message(STATUS "Enabling Fat LTO")
95-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -ffat-lto-objects")
96-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
97-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
98-
endif()
93+
# Note we don't enable LTO on RelWithDebInfo, as it breaks debugging symbols
94+
# on at least AppleClang, making stepping through source code impossible.
95+
96+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
97+
if(SOURCEMETA_COMPILER_GCC AND NOT BUILD_SHARED_LIBS)
98+
message(STATUS "Enabling Fat LTO")
99+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -ffat-lto-objects")
100+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
101+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
102+
endif()
99103

100-
# TODO: Make this work on Linux on LLVM
101-
if(SOURCEMETA_COMPILER_LLVM AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS AND APPLE)
102-
message(STATUS "Enabling Fat LTO")
103-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full")
104-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=full")
105-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full")
104+
# TODO: Make this work on Linux on LLVM
105+
if(SOURCEMETA_COMPILER_LLVM AND NOT BUILD_SHARED_LIBS AND APPLE)
106+
message(STATUS "Enabling Fat LTO")
107+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full")
108+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=full")
109+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full")
110+
endif()
106111
endif()
107112

108113
# Attempt to enable SIMD (SSE/AVX/NEON)

0 commit comments

Comments
 (0)