Comment
The change only adjusts how the PKGBUILD chooses a parallel build job count. It still reads local system information from /proc/meminfo, lscpu, and nproc, and only writes a numeric MOZ_PARALLEL_BUILD value into the generated mozconfig when the computed value matches a number. There are no new network fetches, privilege escalations, persistence mechanisms, or writes outside the build tree. The main effect is a build-performance heuristic change, not a security-sensitive one. One minor concern is that it now invokes lscpu unconditionally, which could fail on unusual build environments, but that is a reliability issue rather than a security issue.
@@ -370,27 +370,29 @@ ac_add_options --enable-lto=cross,full
END
fi
- # build paralleism
- local _mem _nproc _cores
- _mem=$(grep -Pom1 '^MemFree.*\b\K[0-9]+' /proc/meminfo)
- _nproc=$(nproc)
+ # build parallelism
+ local _mem _threads _cores _jobs
+ _mem=$(grep -Pom1 '^MemAvailable:\s*\K[0-9]+' /proc/meminfo)
+ _cores=$(lscpu | grep -Pom1 'per socket:\s*\K[0-9]+')
+ _threads=$(nproc)
+ _jobs="auto"
- if [[ "${_build_limit_cores::1}" == "t" ]]; then
+ if [[ "${_build_limit_cores}" =~ ^[at] ]]; then
# calculate core availability based on free RAM and CPU count
- _cores=$((_mem / (1024 * 1024) < _nproc ? _mem / (1024 * 1024) : _nproc))
- _cores=$((_cores < 1 ? 1 : _cores))
+ _jobs=$((_mem / (1024 * 1024) < _cores ? _mem / (1024 * 1024) : _cores - 1))
+ _jobs=$((_jobs < 1 ? 1 : _jobs))
elif ((${_build_limit_cores:-0} > 0)); then
# user-specified, capped by CPU count
- _cores=$((_build_limit_cores > _nproc ? _nproc : _build_limit_cores))
+ _jobs=$((_build_limit_cores > _threads ? _threads : _build_limit_cores))
+ _jobs=$((_jobs < 1 ? 1 : _jobs))
fi
- if [ -n "${_cores:-}" ]; then
- printf '\nFree RAM: %s\nCores: %s\nUsing: %s\n\n' "$((_mem / (1024 * 1024)))" "$_nproc" "$_cores"
+ printf '\n:: Free RAM: %-5s Cores: %-5s Threads: %-5s Jobs: %-5s\n\n' "$((_mem / (1024 * 1024)))" "$_cores" "$_threads" "$_jobs"
+
+ if [[ "$_jobs" =~ ^[0-9]+$ ]]; then
cat >> ../mozconfig << END
-mk_add_options MOZ_PARALLEL_BUILD=${_cores}
+mk_add_options MOZ_PARALLEL_BUILD=${_jobs}
END
- else
- printf '\nFree RAM: %s\nCores: %s\nUsing: auto\n\n' "$((_mem / (1024 * 1024)))" "$_nproc"
fi
# apply patches