Skip to content

Commit 4ee12e1

Browse files
committed
cmake: use -flto=auto compiler flag when supported
Use -flto=auto compiler flag when supported, this silence this GCC warning: > lto-wrapper: warning: using serial compilation of # LTRANS jobs This also greatly speeds-up the linkage time as it enables LTO multithreading in GCC (either by using Make jobserver if detected, either by detecting CPU cores).
1 parent a006354 commit 4ee12e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmake/DaemonFlags.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,13 @@ else()
423423
# Saigo NaCl compiler doesn't support LTO, the flag is accepted but linking fails
424424
# with “unable to pass LLVM bit-code files to linker” error.
425425
if (USE_LTO AND NOT NACL)
426-
try_c_cxx_flag(LTO "-flto")
426+
try_c_cxx_flag(LTO_AUTO "-flto=auto")
427427

428-
if (FLAG_LTO)
428+
if (NOT FLAG_LTO_AUTO)
429+
try_c_cxx_flag(LTO "-flto")
430+
endif()
431+
432+
if (FLAG_LTO_AUTO OR FLAG_LTO)
429433
# Pass all compile flags to the linker.
430434
set_linker_flag("${CMAKE_CXX_FLAGS}")
431435

0 commit comments

Comments
 (0)