From ab6752eefbcffcab9697b85c7b8847be39f1f570 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Tue, 19 Nov 2024 09:44:28 +0800
Subject: [PATCH] Fix the build issue when ulimit -u is unlimited.

---
 build.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/build.sh b/build.sh
index fc9f7fdc..98a304b3 100755
--- a/build.sh
+++ b/build.sh
@@ -92,8 +92,12 @@ function run-make() {
 
     # following is IHEP specific hack due to the limitation of nthreads 150.
     local nthreads=$(ulimit -u)
-    local factor=16
-    nthreads=$((nthreads/factor)) # assume it is safe to divide by scale factor.
+    if [ "$nthreads" = "unlimited" ]; then
+        nthreads=$njobs
+    else
+        local factor=16
+        nthreads=$((nthreads/factor)) # assume it is safe to divide by scale factor.
+    fi
     
     # min(njobs, nthreads)
     njobs=$((njobs<nthreads ?  njobs: nthreads))
-- 
GitLab