[coreboot-gerrit] New patch to review for coreboot: xcompile: Add core count to .xcompile

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Thu Jan 14 04:53:05 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12937

-gerrit

commit 8fedc4fa0fa5bdf7b87d1ba5ada0e992d2d40e20
Author: Martin Roth <martinroth at google.com>
Date:   Wed Jan 13 20:52:44 2016 -0700

    xcompile: Add core count to .xcompile
    
    I think these four methods should cover most operating systems,
    with many supporting several of the methods.
    
    If we don't find anything, we're not any worse off than we were before.
    The big issue would be if we get an incorrect value.
    
    Change-Id: I4a612d39e93173e9d6e0de892f5bebf716912b1a
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/xcompile/xcompile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index b3dd074..215df25 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -66,10 +66,29 @@ else
 	die "no host compiler found"
 fi
 
+# try to find the core count using various methods
+CORES="$(getconf _NPROCESSORS_ONLN 2>/dev/null)"
+if [ -z "$CORES" ]; then
+	NPROC=$(command -v nproc)
+	if [ -n "$NPROC" ]; then
+		CORES="$($NPROC)"
+	fi
+fi
+if [ -z "$CORES" ]; then
+	SYSCTL=$(command -v sysctl)
+	if [ -n "$SYSCTL" ]; then
+		CORES="$(${SYSCTL} -n hw.ncpu 2>/dev/null)"
+	fi
+fi
+if [ -z "$CORES" ] && [ -f /proc/cpuinfo ]; then
+	 CORES="$(grep 'processor' /proc/cpuinfo 2>/dev/null | wc -l)"
+fi
+
 cat <<EOF
 # platform agnostic and host tools
 IASL:=${IASL}
 HOSTCC?=${HOSTCC}
+CPUS?=${CORES}
 
 EOF
 



More information about the coreboot-gerrit mailing list