Skip to content

Commit

Permalink
Disable LTO if compiling with clang and asan due to likely compiler bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oipo committed Jan 5, 2025
1 parent 430a69f commit 0cabced
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,6 @@ else()
set(ICHOR_BUILDING_DEBUG OFF)
endif()


if(CMAKE_BUILD_TYPE STREQUAL "Release")
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT LTO_ERROR)
if(LTO_SUPPORTED)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if(ICHOR_COMPILER_ID STREQUAL "clang")
set(CMAKE_C_COMPILE_OPTIONS_IPO "-flto=full")
set(CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=full")
endif()
set(ICHOR_LTO ON)
message(STATUS "Enabled LTO")
else()
set(ICHOR_LTO OFF)
message(STATUS "LTO not supported: ${LTO_ERROR}")
endif()
endif()

option(ICHOR_BUILD_EXAMPLES "Build examples" ON)
option(ICHOR_BUILD_BENCHMARKS "Build benchmarks" ON)
option(ICHOR_BUILD_TESTING "Build tests" ON)
Expand Down Expand Up @@ -96,6 +77,27 @@ option(ICHOR_USE_HIREDIS "Add hiredis dependency" OFF)
option(ICHOR_MUSL "Use when building for musl instead of glibc" OFF)
option(ICHOR_AARCH64 "Use when building for aarch64. Turns off some x86-specific compiler flags." OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT (ICHOR_COMPILER_ID STREQUAL "clang" AND ICHOR_USE_SANITIZERS))
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT LTO_ERROR)
if(LTO_SUPPORTED)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if(ICHOR_COMPILER_ID STREQUAL "clang")
set(CMAKE_C_COMPILE_OPTIONS_IPO "-flto=full")
set(CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=full")
endif()
set(ICHOR_LTO ON)
message(STATUS "Enabled LTO")
else()
set(ICHOR_LTO OFF)
message(STATUS "LTO not supported: ${LTO_ERROR}")
endif()
else()
set(ICHOR_LTO OFF)
message(STATUS "Disabled LTO")
endif()

set(BUILD_TESTING OFF) #disable Catch 2 testing

if(ICHOR_COMPILER_ID STREQUAL "clang")
Expand Down

0 comments on commit 0cabced

Please sign in to comment.