clang-tidy breaks when enabling parallel LTO for gcc
Hi,
when enabling LTO for gcc using CMAKE_INTERPROCEDURAL_OPTIMIZATION=ON, I try to achieve parallel LTO by modifying CMAKE_${lang}_COMPILE_OPTIONS_IPO
variables to -flto=${IPO_PROCESSOR_COUNT}
. This variable is adaptable by user.
The setup is actually a bit more complex:
foreach ( lang C CXX )
if ( CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" )
set ( CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_COMMAND}\" -E env MAKE=${IPO_MAKE_EXECUTABLE} ${CMAKE_${lang}_LINK_EXECUTABLE}" )
set ( CMAKE_${lang}_COMPILE_OPTIONS_IPO -flto=${IPO_PROCESSOR_COUNT} )
endif ()
endforeach ( lang )
The CMAKE_${lang}_COMPILE_OPTIONS_IPO
content is also forwarded to clang-tidy. This is actually unexpected!
It also breaks clang-tidy for this case as clang does not understand -flto=8
.
There is absolutely no need to forward LTO parameters to clang-tidy.
If you have better suggestions how to handle this, please tell me.
Edited by Hendrik Sattler