Massage MAKE_JOBS for sys/debian.sh too ##build

This commit is contained in:
pancake 2022-06-09 19:09:43 +02:00
parent 44b3dff342
commit 88f5284422
4 changed files with 56 additions and 51 deletions

View File

@ -48,6 +48,10 @@ jobs:
run: |
cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg
./configure --without-capstone && make -j
- name: Building muon/samu
run: |
r2pm -gci muon samu
muon m && samu -C m -j5
build-acr-gperf:
name: linux-acr-gperf
runs-on: ubuntu-20.04

View File

@ -1,51 +1,8 @@
#!/bin/sh
GetPlatform() {
# Get OS and platform to decide if we need to limit memory usage
# during the build
PLATFORM=$(uname -a)
case "$PLATFORM" in
"Linux raspberrypi"*) MAX_MEM_PER_JOB=300000;;
"Linux"*) MAX_MEM_PER_JOB=150000;;
*) MAX_MEM_PER_JOB=200000 # If platform is not Linux (fallback value)
esac
}
BuildJobsThrottler(){
echo "Building on Linux : computing number of allowed parallel jobs."
echo "Maximum allowed RAM memory per job is $MAX_MEM_PER_JOB kB."
# Get number of CPUs on this target
# getconf does not exit on Darwin. Use sysctl on Darwin machines.
CPU_N=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu)
printf "Number of CPUs is %s and " "$CPU_N"
# Get remaining RAM that could be used for this build
FREE_RAM=$(grep MemAvailable /proc/meminfo | sed 's/[^0-9]//g')
DEFAULT_MAX_MEM_PER_JOB=200000
[ -z "${MAX_MEM_PER_JOB}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent devision by 0
# Assuming we may have many 300MB compilation jobs running in parallel
MEM_ALLOWED_JOBS=$((FREE_RAM / MAX_MEM_PER_JOB))
echo "current free RAM allows us to run $MEM_ALLOWED_JOBS jobs in parallel."
# Set number of build jobs to be run in parallel as the minimum between $MEM_ALLOWED_JOBS and $CPU_N
MAKE_JOBS=$((MEM_ALLOWED_JOBS<CPU_N?MEM_ALLOWED_JOBS:CPU_N))
if [ ${MAKE_JOBS} -lt 1 ]; then
MAKE_JOBS=8
fi
echo "So, the build will run on $MAKE_JOBS job(s)."
}
OSNAME=$(uname)
if [ "${OSNAME}" = Linux ]; then
# Identify current platform
GetPlatform
# Define number of parallel jobs depending on ncpus and memory
BuildJobsThrottler
fi
source `dirname $0`/make-jobs.inc.sh
if [ -z "${MAKE}" ]; then
MAKE=make
@ -53,7 +10,6 @@ if [ -z "${MAKE}" ]; then
[ $? = 0 ] && MAKE=gmake
fi
[ -z "${MAKE_JOBS}" ] && MAKE_JOBS=12
[ -z "${CERTID}" ] && CERTID=org.radare.radare2
# find root

View File

@ -18,13 +18,10 @@ DEVDIR=dist/debian/radare2-dev/root
# clean
rm -rf "${PKGDIR}" "${DEVDIR}"
if [ -z "$CFLAGS" ]; then
export CFLAGS="-Wno-cpp -Wno-unused-result"
## export CFLAGS="${CFLAGS} -Wno-stringop-truncation"
fi
CFLAGS="-O2 ${CFLAGS}"
source `dirname $0`/make-jobs.inc.sh
export CFLAGS="-Wno-cpp -Wno-unused-result ${CFLAGS} -O2"
# build
export
./configure --prefix=/usr --with-checks-level=0
[ $? != 0 ] && exit 1
make -j4

48
sys/make-jobs.inc.sh Normal file
View File

@ -0,0 +1,48 @@
[ -z "${MAKE_JOBS}" ] && MAKE_JOBS=12
export MAKE_JOBS
GetPlatform() {
# Get OS and platform to decide if we need to limit memory usage
# during the build
PLATFORM=$(uname -a)
case "$PLATFORM" in
"Linux raspberrypi"*) MAX_MEM_PER_JOB=300000;;
"Linux"*) MAX_MEM_PER_JOB=150000;;
*) MAX_MEM_PER_JOB=200000 # If platform is not Linux (fallback value)
esac
}
BuildJobsThrottler(){
echo "Building on Linux : computing number of allowed parallel jobs."
echo "Maximum allowed RAM memory per job is $MAX_MEM_PER_JOB kB."
# Get number of CPUs on this target
# getconf does not exit on Darwin. Use sysctl on Darwin machines.
CPU_N=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu)
printf "Number of CPUs is %s and " "$CPU_N"
# Get remaining RAM that could be used for this build
FREE_RAM=$(grep MemAvailable /proc/meminfo | sed 's/[^0-9]//g')
DEFAULT_MAX_MEM_PER_JOB=200000
[ -z "${MAX_MEM_PER_JOB}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent devision by 0
# Assuming we may have many 300MB compilation jobs running in parallel
MEM_ALLOWED_JOBS=$((FREE_RAM / MAX_MEM_PER_JOB))
echo "current free RAM allows us to run $MEM_ALLOWED_JOBS jobs in parallel."
# Set number of build jobs to be run in parallel as the minimum between $MEM_ALLOWED_JOBS and $CPU_N
export MAKE_JOBS=$((MEM_ALLOWED_JOBS<CPU_N?MEM_ALLOWED_JOBS:CPU_N))
if [ ${MAKE_JOBS} -lt 1 ]; then
MAKE_JOBS=8
fi
echo "So, the build will run on $MAKE_JOBS job(s)."
}
if [ "${OSNAME}" = Linux ]; then
# Identify current platform
GetPlatform
# Define number of parallel jobs depending on ncpus and memory
BuildJobsThrottler
fi