mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-30 16:40:57 +00:00
Massage MAKE_JOBS for sys/debian.sh too ##build
This commit is contained in:
parent
44b3dff342
commit
88f5284422
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -48,6 +48,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg
|
cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg
|
||||||
./configure --without-capstone && make -j
|
./configure --without-capstone && make -j
|
||||||
|
- name: Building muon/samu
|
||||||
|
run: |
|
||||||
|
r2pm -gci muon samu
|
||||||
|
muon m && samu -C m -j5
|
||||||
build-acr-gperf:
|
build-acr-gperf:
|
||||||
name: linux-acr-gperf
|
name: linux-acr-gperf
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
46
sys/build.sh
46
sys/build.sh
@ -1,51 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/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)
|
OSNAME=$(uname)
|
||||||
|
|
||||||
if [ "${OSNAME}" = Linux ]; then
|
source `dirname $0`/make-jobs.inc.sh
|
||||||
# Identify current platform
|
|
||||||
GetPlatform
|
|
||||||
# Define number of parallel jobs depending on ncpus and memory
|
|
||||||
BuildJobsThrottler
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${MAKE}" ]; then
|
if [ -z "${MAKE}" ]; then
|
||||||
MAKE=make
|
MAKE=make
|
||||||
@ -53,7 +10,6 @@ if [ -z "${MAKE}" ]; then
|
|||||||
[ $? = 0 ] && MAKE=gmake
|
[ $? = 0 ] && MAKE=gmake
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "${MAKE_JOBS}" ] && MAKE_JOBS=12
|
|
||||||
[ -z "${CERTID}" ] && CERTID=org.radare.radare2
|
[ -z "${CERTID}" ] && CERTID=org.radare.radare2
|
||||||
|
|
||||||
# find root
|
# find root
|
||||||
|
@ -18,13 +18,10 @@ DEVDIR=dist/debian/radare2-dev/root
|
|||||||
# clean
|
# clean
|
||||||
rm -rf "${PKGDIR}" "${DEVDIR}"
|
rm -rf "${PKGDIR}" "${DEVDIR}"
|
||||||
|
|
||||||
if [ -z "$CFLAGS" ]; then
|
source `dirname $0`/make-jobs.inc.sh
|
||||||
export CFLAGS="-Wno-cpp -Wno-unused-result"
|
|
||||||
## export CFLAGS="${CFLAGS} -Wno-stringop-truncation"
|
export CFLAGS="-Wno-cpp -Wno-unused-result ${CFLAGS} -O2"
|
||||||
fi
|
|
||||||
CFLAGS="-O2 ${CFLAGS}"
|
|
||||||
# build
|
# build
|
||||||
export
|
|
||||||
./configure --prefix=/usr --with-checks-level=0
|
./configure --prefix=/usr --with-checks-level=0
|
||||||
[ $? != 0 ] && exit 1
|
[ $? != 0 ] && exit 1
|
||||||
make -j4
|
make -j4
|
||||||
|
48
sys/make-jobs.inc.sh
Normal file
48
sys/make-jobs.inc.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user