Change in osmo-ttcn3-hacks[master]: default to number of CPUs for parallel make jobs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Mon Jun 25 15:53:32 UTC 2018


Stefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/9731 )

Change subject: default to number of CPUs for parallel make jobs
......................................................................

default to number of CPUs for parallel make jobs

The previous default behaviour was to always run 'make -j8', which
can cause C++ build failures on machines which are low on memory.
"Low" being a relative measure; I've seen failures with 4GB of RAM.

Rather than assuming a beefy 8-core box, try to detect the number
of available CPU cores with nproc(1) from GNU coreutils and set
the number of parallel make jobs to the number of CPU cores.

If this command is not available, default to a safe choice: -j1
Note that installing ccache will speed up repeated builds a lot
more than -jX ever will, so falling back to -j1 isn't very bad.

Change-Id: I61c3ea1b3cb5b64eecb08ad6c390594f70cdf785
---
M Makefile
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/Makefile b/Makefile
index fcd6601..a12a504 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,10 @@
 SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sip sysinfo
 
-PARALLEL_MAKE ?= -j8
+NPROC=$(shell nproc 2>/dev/null)
+ifeq ($(NPROC),)
+NPROC=1
+endif
+PARALLEL_MAKE ?= -j$(NPROC)
 
 # This master makefile allows you to do things like
 # 	make clean	(remove all generated binary, c++ and symlinks)

-- 
To view, visit https://gerrit.osmocom.org/9731
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I61c3ea1b3cb5b64eecb08ad6c390594f70cdf785
Gerrit-Change-Number: 9731
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180625/1bfbe3fa/attachment.htm>


More information about the gerrit-log mailing list