aboutsummaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2016-09-17 18:22:38 +0100
committerRenato Golin <renato.golin@linaro.org>2016-09-17 20:46:12 +0100
commit250b7aa1f79ef4377c7ae3e55560849db5b5bcf9 (patch)
tree693e4a025a21c302cd6d98fdd6088d7a03e6fca1 /helpers
parent2f8ac15f73eb1c3b072b3126e3a82827c2fc07dd (diff)
downloadlinaro-scripts-250b7aa1f79ef4377c7ae3e55560849db5b5bcf9.tar.gz
Add LINK_JOBS logic to all three builder scripts
The stress, helper and bisect build scripts needed the LLVM_LINK_JOBS option to make sure it doesn't run out of memory while linking, especially in SoCs that have a lot more cores than RAM (ex. HiKey). This patch calculates the jobs by seeing how much RAM the target has and adding +1, as link jobs rarely take more than 1GB, but the final ones do use several hundred. Also making sure we don't exceed the number of cores. A few other small changes: * Replace "else if" by "elif" * Build only minimal targets on ARM (even o full build) * Fixed a -j$PARALLEL bug introduced by a prvious commit * Converted a few backticks into $() Change-Id: If4f2189623338d2924357ecd3d4ee18feb522c32
Diffstat (limited to 'helpers')
-rwxr-xr-xhelpers/llvm-build27
1 files changed, 22 insertions, 5 deletions
diff --git a/helpers/llvm-build b/helpers/llvm-build
index 0cef8a0..0556b6e 100755
--- a/helpers/llvm-build
+++ b/helpers/llvm-build
@@ -11,7 +11,8 @@
safe_run verify_env
## CMD line options and defaults
-PARALLEL=-j`grep -c proc /proc/cpuinfo`
+CPUS=$(grep -c proc /proc/cpuinfo)
+PARALLEL=-j$CPUS
build_dir=$LLVM_BLD
install_dir=$LLVM_INSTALL
build_type=Release
@@ -23,6 +24,8 @@ update=false
check=false
master=false
inst=false
+minimal_targets="-DLLVM_TARGETS_TO_BUILD='ARM;X86;AArch64'"
+link_jobs=
if [ "$1" = "-h" ]; then
echo $syntax
@@ -32,7 +35,7 @@ fi
## Choose between make and ninja
make=make
generator="Unix Makefiles"
-if which ninja 2>&1 > /dev/null; then
+if which ninja > /dev/null 2>&1; then
make=ninja
generator="Ninja"
fi
@@ -41,7 +44,21 @@ fi
if [ "$LLVM_DEBUG" = true ]; then
build_type=Debug
shared=-DBUILD_SHARED_LIBS=True
- targets=-DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"
+ targets=$minimal_targets
+fi
+
+# Building on ARM?
+if grep -q "ARM.* Processor" /proc/cpuinfo; then
+ targets=$minimal_targets
+ if [ "$make" = "ninja" ]; then
+ link=$(free -g | awk '/Mem/ {print $2}')
+ if [ "$link" -gt "$CPUS" ]; then
+ link=$CPUS
+ else
+ link=$((link+1))
+ fi
+ link_jobs="-DLLVM_PARALLEL_LINK_JOBS=$link"
+ fi
fi
## Make sure sure build dir is there
@@ -65,8 +82,8 @@ if [ ! -f build.ninja ] && [ ! -f Makefile ]; then
-DLLVM_ENABLE_ASSERTIONS=True \
-DPYTHON_EXECUTABLE=/usr/bin/python2 \
-DCMAKE_INSTALL_PREFIX=$install_dir \
- -DLLVM_LIT_ARGS="-sv -j$PARALLEL" \
- $LLVM_CMAKE_FLAGS $targets $shared
+ -DLLVM_LIT_ARGS="-sv $PARALLEL" \
+ $LLVM_CMAKE_FLAGS $targets $shared $link_jobs
fi
## Build