summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2020-02-04 21:26:38 +0100
committerGitHub <noreply@github.com>2020-02-04 21:26:38 +0100
commitab525cc48abdbbbed1f772e58e9fe21474f70f07 (patch)
treed22e319ba3237edb725ab798c17aab4231b57b51
parent955465e5f42b1353f69f3bd884908a7ef91ce13b (diff)
downloadNim-ab525cc48abdbbbed1f772e58e9fe21474f70f07.tar.gz
build_all.sh update (#13320)
* Don't overload the system, don't crash when you can't determine the CPU count and don't rely on bash

* Extract to variable

* Limit number of spawned jobs for systems with weak IO

* Use proper arithmetic braces
-rw-r--r--build_all.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/build_all.sh b/build_all.sh
index 9c5aa3d91..2ed2233e9 100644
--- a/build_all.sh
+++ b/build_all.sh
@@ -23,7 +23,7 @@ build_nim_csources_via_script(){
 build_nim_csources(){
   # avoid changing dir in case of failure
   (
-    if [[ $# -ne 0 ]]; then
+    if [ $# -ne 0 ]; then
       # some args were passed (eg: `--cpu i386`), need to call build.sh
       build_nim_csources_via_script "$@"
     else
@@ -33,7 +33,8 @@ build_nim_csources(){
       if [ "$unamestr" = 'FreeBSD' ]; then
         makeX=gmake
       fi
-      which $makeX && echo_run $makeX -C csources -j -l 80 || build_nim_csources_via_script
+      nCPU=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || 1)
+      which $makeX && echo_run $makeX -C csources -j $((nCPU + 2)) -l $nCPU || build_nim_csources_via_script
     fi
   )
   # keep $nim_csources in case needed to investigate bootstrap issues