-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#102 remove IS_LTS env in *.yml, but not change build.sh accordingly, which makes build.sh always selects to non-ccache branch. Add option parser like that in setup.sh and modify *.yml, which should fix ccache. Also remove old SMT detection code. `nproc` itself already respects SMT. Like with 8C,16T processor, `nproc` will return 16. `nproc --all` basically is same as `nproc` but it will ignore cgroup limitation forced by containers like docker, and also on motherboards supporting hotplug cpus it will return max possible cpu slots instead of the number of installed count. So yeah, sometimes `nproc --all` returns a bigger number than `nproc`, but those "extra" cpus aren't actually available for use. So let's just use `nproc`. But use 2*nproc might still make sense if compilation is actually IO-bounded. I tested nproc vs 2*nproc on my private repo's action. It seems like no noticable difference though. Maybe we should revisit the thread count decision someday later. (cherry picked from commit f05d3d5c422738ad90237753b9bd60396ded6238)
- Loading branch information
Showing
4 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,67 @@ | ||
# | ||
if [ "$(cat /sys/devices/system/cpu/smt/active)" = "1" ]; then | ||
export LOGICAL_CORES=$(($(nproc --all) * 2)) | ||
else | ||
export LOGICAL_CORES=$(nproc --all) | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "Usage: build.sh [options]" | ||
echo "Options:" | ||
echo " -b|--branch <LTS|MAIN> - Specify the Xanmod kernel branch to build. (Default: MAIN)" | ||
echo " -j|--jobs <num> - Specify the number of jobs to use for parallel compilation. (Default: $(nproc))" | ||
echo " -h - Show this help message." | ||
} | ||
|
||
# Parse options with getopt | ||
temp=$(getopt -o 'b:j:h' --long 'branch:,jobs:,help' -n 'build.sh' -- "$@") | ||
if [ $? -ne 0 ]; then | ||
# unsupported options provided | ||
# NOTE: error log not needed, will be reported by getopt | ||
usage | ||
exit 1 | ||
fi | ||
eval set -- "$temp" | ||
unset temp | ||
while true; do | ||
case "$1" in | ||
'-b'|'--branch') | ||
BRANCH="$2" | ||
shift 2 | ||
# check if branch is LTS or MAIN | ||
if [ "$BRANCH" != "LTS" ] && [ "$BRANCH" != "MAIN" ]; then | ||
echo "Invalid branch: $BRANCH" | ||
exit 2 | ||
fi | ||
continue | ||
;; | ||
'-j'|'--jobs') | ||
LOGICAL_CORES="$2" | ||
shift 2 | ||
continue | ||
;; | ||
'-h'|'--help') | ||
usage | ||
exit 0 | ||
;; | ||
'--') | ||
shift | ||
break | ||
;; | ||
*) | ||
# should not happen | ||
echo "Unhandled option: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
# Default values | ||
BRANCH=${BRANCH:-MAIN} | ||
|
||
LOGICAL_CORES=${LOGICAL_CORES:-$(nproc)} | ||
|
||
# | ||
# Compile | ||
# | ||
if [ "$IS_LTS" = "NO" ]; then | ||
if [ "$BRANCH" = "MAIN" ]; then | ||
echo -e "Using $LOGICAL_CORES jobs for this non-LTS build..." | ||
make CC='ccache clang -Qunused-arguments -fcolor-diagnostics' LLVM=1 LLVM_IAS=1 -j$LOGICAL_CORES | ||
else | ||
elif [ "$BRANCH" = "LTS" ]; then | ||
echo -e "Using $LOGICAL_CORES jobs for this LTS build..." | ||
make LLVM=1 LLVM_IAS=1 -j$LOGICAL_CORES | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters