IPO: Add option to specify number of parallel LTRANS jobs
Currently, when using INTERPROCEDURAL_OPTIMIZATION
, cmake adds -flto ...
to the c flags.
Since GCC 12.1, this results in a warning:
lto-wrapper: warning: using serial compilation of <number of jobs> LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
It expects -flto
to take a number of jobs it should compile in parallel, e.g -flto=8
, -flto=1
, etc.
There is also the option of -flto=auto
, which seems to be the same as -flto=$(nproc)
Currently it seems to fall back to 1 parallel job.
I suggest to append auto
as default value, and give an option to manually overwrite it, e.g.:
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_JOBS 8)
If auto
is not practicable as default, at least append 1
to disable the warnings.
Edited by Brad King