mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
GNU: Do not use "fat-lto-objects" flags for IPO on Apple platforms
Fat LTO objects contain both traditional object code and the LTO bitcode IR, but the GNU compiler does not support them on Apple platforms. A compile error is raised when `-f[no-]fat-lto-objects` flags are used, so avoid them. This also implies that static Fortran libraries cannot be built with IPO. Fixes: #25931
This commit is contained in:
@@ -151,7 +151,7 @@ macro(__compiler_gnu lang)
|
||||
list(APPEND __lto_flags -flto)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7)
|
||||
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.7 AND NOT APPLE)
|
||||
# '-ffat-lto-objects' introduced since GCC 4.7:
|
||||
# * https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Option-Summary.html (no)
|
||||
# * https://gcc.gnu.org/onlinedocs/gcc-4.7.4/gcc/Option-Summary.html (yes)
|
||||
|
||||
@@ -113,11 +113,15 @@ target_link_libraries(FortranCInterface PUBLIC symbols)
|
||||
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND
|
||||
CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
|
||||
target_compile_options(FortranCInterface PRIVATE "-fno-lto")
|
||||
target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects")
|
||||
if(NOT APPLE)
|
||||
target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects")
|
||||
endif()
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
|
||||
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
|
||||
target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects")
|
||||
if(NOT APPLE)
|
||||
target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[
|
||||
|
||||
Reference in New Issue
Block a user