Skip to content

Commit ab525cc

Browse files
authored
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
1 parent 955465e commit ab525cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

build_all.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ build_nim_csources_via_script(){
2323
build_nim_csources(){
2424
# avoid changing dir in case of failure
2525
(
26-
if [[ $# -ne 0 ]]; then
26+
if [ $# -ne 0 ]; then
2727
# some args were passed (eg: `--cpu i386`), need to call build.sh
2828
build_nim_csources_via_script "$@"
2929
else
@@ -33,7 +33,8 @@ build_nim_csources(){
3333
if [ "$unamestr" = 'FreeBSD' ]; then
3434
makeX=gmake
3535
fi
36-
which $makeX && echo_run $makeX -C csources -j -l 80 || build_nim_csources_via_script
36+
nCPU=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || 1)
37+
which $makeX && echo_run $makeX -C csources -j $((nCPU + 2)) -l $nCPU || build_nim_csources_via_script
3738
fi
3839
)
3940
# keep $nim_csources in case needed to investigate bootstrap issues

0 commit comments

Comments
 (0)