Skip to contentSkip to conversation

cmake: use Ninja backend instead of Make

RFC PATCH In review Ross Burton 4 participants 8 messages Jan 16, 2018 – Jan 18, 2018

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 cmake: use Ninja backend instead of Make

The Ninja backend is faster than Make for large projects (takes three minutes off webkitgtk:do_compile for me), so use it by default.

---
 meta/classes/cmake.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta/classes/cmake.bbclass +3 -3
index 10c4edcf1a5..ab29b1f1c23 100644
@@ -1,7 +1,7 @@
 # Path to the CMake file to process.
 OECMAKE_SOURCEPATH ??= "${S}"
 
-DEPENDS_prepend = "cmake-native "
+DEPENDS_prepend = "cmake-native ninja-native "
 B = "${WORKDIR}/build"
 
 # We need to unset CCACHE otherwise cmake gets too confused
@@ -120,7 +120,7 @@ cmake_do_configure() {
 		oecmake_sitefile=
 	fi
 
-	cmake \
+	cmake -GNinja \
 	  $oecmake_sitefile \
 	  ${OECMAKE_SOURCEPATH} \
 	  -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
@@ -141,7 +141,7 @@ cmake_do_configure() {
 	  -Wno-dev
 }
 
-do_compile[progress] = "percent"
+do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
 cmake_do_compile()  {
 	bbnote VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
 	VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
Signature · 1 line
2.11.0
#2 lore raw
In reply to Ross Burton
Quoted 4 lines · Ross Burton

The Ninja backend is faster than Make for large projects (takes three minutes off webkitgtk:do_compile for me), so use it by default.

I tried to test this but it did not apply in master. Could you rebase it?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
Acked-by
#3 lore raw
Quoted 8 lines · Otavio Salvador
Quoted 4 lines · Ross Burton

The Ninja backend is faster than Make for large projects (takes three minutes off webkitgtk:do_compile for me), so use it by default.

I tried to test this but it did not apply in master. Could you rebase it?

On my 64+64 core system that is shared, it reduced a webkit compile from ~ 17 minutes to ~12 minutes for just the compile stage. YMMV.

$ cat webkit-before-compile.log
3.29user 0.50system 17:39.98elapsed 0%CPU
  (0avgtext+0avgdata 28532maxresident)k
0inputs+176outputs (0major+16335minor)pagefaults 0swaps
$ cat webkit-after-compile.log
2.70user 0.47system 12:09.24elapsed 0%CPU
   (0avgtext+0avgdata 28292maxresident)k
0inputs+160outputs (0major+14634minor)pagefaults 0swaps

I'm going to try to build world (oe-core + meta-oe + ...).

Octavio, it's a two line change! :)
This applied to master for me:

commit 3914c66f6e7123a64ab73e2b6707452bbfd10d02

Author: Ross Burton <[email protected]>
Date:   Wed Jan 17 13:09:40 2018 -0500

cmake: use Ninja backend instead of Make

The Ninja backend is faster than Make for large projects (it takes three minutes off webkitgtk:do_compile for example) so use it by default.

meta/classes/cmake.bbclass +2 -2
index a4079dab0d..c46117acde 100644
@@ -1,7 +1,7 @@
 # Path to the CMake file to process.
 OECMAKE_SOURCEPATH ??= "${S}"
 
-DEPENDS_prepend = "cmake-native "
+DEPENDS_prepend = "cmake-native ninja-native "
 B = "${WORKDIR}/build"
 
 # We need to unset CCACHE otherwise cmake gets too confused
@@ -117,7 +117,7 @@ cmake_do_configure() {
 		oecmake_sitefile=
 	fi
 
-	cmake \
+	cmake -GNinja \
 	  $oecmake_sitefile \
 	  ${OECMAKE_SOURCEPATH} \
 	  -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
Signature · 2 lines
# Randy MacLeod.  WR Linux
# Wind River an Intel Company
#4 lore raw
Quoted 24 lines · Randy MacLeod
Quoted 13 lines · Otavio Salvador
Quoted 6 lines · Ross Burton

The Ninja backend is faster than Make for large projects (takes three minutes
off webkitgtk:do_compile for me), so use it by default.

I tried to test this but it did not apply in master. Could you rebase it?

On my 64+64 core system that is shared, it reduced a webkit compile from ~ 17 minutes to ~12 minutes for just the compile stage. YMMV.

$ cat webkit-before-compile.log
3.29user 0.50system 17:39.98elapsed 0%CPU
  (0avgtext+0avgdata 28532maxresident)k
0inputs+176outputs (0major+16335minor)pagefaults 0swaps
Quoted 7 lines
$ cat webkit-after-compile.log
2.70user 0.47system 12:09.24elapsed 0%CPU
   (0avgtext+0avgdata 28292maxresident)k
0inputs+160outputs (0major+14634minor)pagefaults 0swaps

I'm going to try to build world (oe-core + meta-oe + ...).

Good win :)

There appears to be a small number of upstreams that break with ninja, so I'll rework this patch so that the backend is an option but default to Ninja.

Ross

#5 lore raw
Quoted 3 lines · Ross

There appears to be a small number of upstreams that break with ninja, so I'll rework this patch so that the backend is an option but default to Ninja.

When doing so, please rebase on top of my patches and send it as official patch (no RFC). Besides test, it is very welcome.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#6 lore raw
In reply to Burton, Ross
Quoted 1 line · Ross

There appears to be a small number of upstreams that break with ninja, so I'll rework this patch so that the backend is an option but default to Ninja.

The only failure that involved a cmake based package was piglit for my qemux86-64 world build.

It didn't install:
make: Entering directory
'/.../tmp-glibc/work/core2-64-wrs-linux/piglit/1.0+gitrAUTOINC+c8f4fd9eeb-r0/build'
make: *** No rule to make target 'install/strip'. Stop.

so that might not be related to this change. I haven't manually done a world build on master recently.

As expected using ninja for the back-end of cmake just makes the builds faster.

Signature · 2 lines
# Randy MacLeod.  WR Linux
# Wind River an Intel Company
#7 lore raw
Quoted 6 lines · Randy MacLeod
Quoted 1 line · Ross

There appears to be a small number of upstreams that break with ninja, so I'll rework this patch so that the backend is an option but default to Ninja.

The only failure that involved a cmake based package was piglit for my qemux86-64 world build.

Quoted 8 lines

It didn't install:
  make: Entering directory
'/.../tmp-glibc/work/core2-64-wrs-linux/piglit/1.0+gitrAUTOINC+c8f4fd9eeb-r0/build'

make: *** No rule to make target 'install/strip'.  Stop.

so that might not be related to this change. I haven't manually done a world build on master recently.

Apparently already fixed by Ross in master-next:

commit 9fec5ef920bd63fe3cc2e623add0c7aead95ecae

Author: Ross Burton <[email protected]>
Date:   Tue Jan 16 13:25:16 2018 +0000

piglit: override install target name instead of do_install

../Randy

Quoted 4 lines

As expected using ninja for the back-end of cmake just makes the builds faster.

Signature · 2 lines
# Randy MacLeod.  WR Linux
# Wind River an Intel Company