I'm building app with flto and I want to parallelise it on all cores that are used in make e.g if I run it with make -j4
then on 4 cores
Example:
cmake_minimum_required(VERSION 2.8)
project(a)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=jobserver")
add_executable(a a.cpp b.cpp)
where a.cpp
and b.cpp
are any reasonable cpps (and one of them has main)
Running with make -j2
gives me:
-- Configuring done
-- Generating done
-- Build files have been written to: ...
[ 33%] Building CXX object CMakeFiles/a.dir/b.cpp.o
[ 66%] Building CXX object CMakeFiles/a.dir/a.cpp.o
[100%] Linking CXX executable a
make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
[100%] Built target a
So, only one core is used. Is it possible to pass information about jobserver to gcc here?