build: configure LTO

Related-To: NEO-9328
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
Artur Harasimiuk
2024-03-12 11:52:58 +00:00
committed by Compute-Runtime-Automation
parent 8d83f7603c
commit 7be113df2b
2 changed files with 20 additions and 1 deletions

View File

@@ -173,6 +173,25 @@ endif()
include(CheckCXXCompilerFlag)
if(UNIX)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND(
${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0 OR
(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.0 AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 13.0
)))
message(STATUS "Disabling LTO because compiler is ${CMAKE_CXX_COMPILER_ID} v${CMAKE_CXX_COMPILER_VERSION}")
set(NEO_DISABLE_LTO TRUE)
endif()
if(NOT NEO_DISABLE_LTO)
check_cxx_compiler_flag("-flto=auto" COMPILER_SUPPORTS_FLTO_AUTO)
if(COMPILER_SUPPORTS_FLTO_AUTO)
message(STATUS "enabling lto=auto, disabling ld.lld")
set(NEO_DISABLE_LD_LLD TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=auto")
check_cxx_compiler_flag("-ffat-lto-objects" COMPILER_SUPPORTS_FAT_LTO_OBJECTS)
if(COMPILER_SUPPORTS_FAT_LTO_OBJECTS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffat-lto-objects")
endif()
endif()
endif()
find_program(__LD_GOLD_FOUND ld.gold)
find_program(__LD_LLD_FOUND ld.lld)
check_cxx_compiler_flag(-fuse-ld=lld COMPILER_SUPPORTS_LLD)

View File

@@ -31,7 +31,7 @@ components:
branch: master
dest_dir: infra
fetch_tags: true
revision: v5813
revision: v5818
type: git
internal:
branch: master