Skip to content

Commit 2807f88

Browse files
committedDec 17, 2024
build: Allow passing LLVM=1
1 parent 5128dd6 commit 2807f88

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed
 

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ To build modules pass `MODULES=1`
130130

131131
To convert all modules to builtin, pass `MOD2YES=1`.
132132

133+
To build with llvm pass `LLVM=1`, only works using the latest Fedora or Ubuntu image.
134+
133135
To build with clang pass `CLANG=1`, only works using the latest Fedora or Ubuntu image.
134136

135137
For a quiet build pass `QUIET=1`, for verbose pass `VERBOSE=1`.

‎build/scripts/build.sh

+4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ if [[ "$task" == "kernel" ]]; then
173173
if [[ -n "$LLVM_IAS" ]]; then
174174
cmd+="-e LLVM_IAS=$LLVM_IAS "
175175
fi
176+
177+
if [[ -n "$LLVM" ]]; then
178+
cmd+="-e LLVM=$LLVM "
179+
fi
176180
fi
177181

178182
if [[ "$task" == "ppctests" ]]; then

‎build/scripts/container-build.sh

+14-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ echo "## ARCH = $ARCH"
1010
echo "## CROSS_COMPILE = $CROSS_COMPILE"
1111
echo "## gcc = $gcc_version"
1212

13-
if [[ -n "$CLANG" ]]; then
13+
if [[ -n "$CLANG" || -n "$LLVM" ]]; then
1414
clang_version=$(clang --version | head -1)
1515
echo "## clang = $clang_version"
1616
fi
@@ -40,7 +40,7 @@ rc=0
4040

4141
if [[ "$1" == "kernel" ]]; then
4242
cc="${CROSS_COMPILE}gcc"
43-
if [[ -n "$CLANG" ]]; then
43+
if [[ -n "$CLANG" || -n "$LLVM" ]]; then
4444
cc="clang"
4545
fi
4646

@@ -50,8 +50,12 @@ if [[ "$1" == "kernel" ]]; then
5050

5151
cc="CC=$cc"
5252

53+
if [[ -n "$LLVM" ]]; then
54+
llvm="LLVM=1"
55+
fi
56+
5357
if [[ -n "$PRE_CLEAN" ]]; then
54-
(set -x; make $verbose $quiet "$cc" clean)
58+
(set -x; make $verbose $quiet $llvm "$cc" clean)
5559
fi
5660

5761
if [[ "$DEFCONFIG" == .config* || "$DEFCONFIG" == *.config ]]; then
@@ -61,7 +65,7 @@ if [[ "$1" == "kernel" ]]; then
6165
# Strip off any suffix after the first '+' used for unique naming
6266
DEFCONFIG="${DEFCONFIG%%+*}"
6367
echo "## DEFCONFIG = $DEFCONFIG"
64-
(set -x; make $verbose $quiet "$cc" $DEFCONFIG)
68+
(set -x; make $verbose $quiet $llvm "$cc" $DEFCONFIG)
6569
fi
6670

6771
if [[ -n "$MERGE_CONFIG" ]]; then
@@ -73,13 +77,13 @@ if [[ "$1" == "kernel" ]]; then
7377
# merge_config.sh always writes its TMP files to $PWD, so we have to
7478
# change into /output before running it.
7579
(cd /output; set -x; /linux/scripts/kconfig/merge_config.sh -m .config ${configs[@]})
76-
(set -x; make $verbose $quiet "$cc" olddefconfig)
80+
(set -x; make $verbose $quiet $llvm "$cc" olddefconfig)
7781
fi
7882

7983
rc=$?
8084

8185
if [[ -n "$MOD2YES" ]]; then
82-
(set -x; make $verbose $quiet "$cc" mod2yesconfig)
86+
(set -x; make $verbose $quiet $llvm "$cc" mod2yesconfig)
8387
fi
8488

8589
if [[ -n "$REPRODUCIBLE" ]]; then
@@ -98,7 +102,7 @@ if [[ "$1" == "kernel" ]]; then
98102
if [[ -n "$SPARSE" ]]; then
99103
rm -f /output/sparse.log
100104
touch /output/sparse.log
101-
(set -x; make C=$SPARSE CF=">> /output/sparse.log 2>&1" $verbose $quiet "$cc" -j $JFACTOR)
105+
(set -x; make C=$SPARSE CF=">> /output/sparse.log 2>&1" $verbose $quiet $llvm "$cc" -j $JFACTOR)
102106

103107
rc=$?
104108

@@ -107,7 +111,7 @@ if [[ "$1" == "kernel" ]]; then
107111
rc=$?
108112
fi
109113
else
110-
(set -x; make $verbose $quiet "$cc" -j $JFACTOR)
114+
(set -x; make $verbose $quiet $llvm "$cc" -j $JFACTOR)
111115
rc=$?
112116
fi
113117
fi
@@ -120,7 +124,7 @@ if [[ "$1" == "kernel" ]]; then
120124
# Clean out any old modules
121125
rm -rf $mod_path
122126

123-
(set -x; make $verbose $quiet -j $JFACTOR "$cc" INSTALL_MOD_PATH=$mod_path modules_install)
127+
(set -x; make $verbose $quiet -j $JFACTOR $llvm "$cc" INSTALL_MOD_PATH=$mod_path modules_install)
124128
rc=$?
125129
if [[ $rc -eq 0 ]]; then
126130
tar -cjf /output/modules.tar.bz2 -C $mod_path lib
@@ -144,7 +148,7 @@ if [[ "$1" == "kernel" ]]; then
144148
fi
145149

146150
if [[ -n "$POST_CLEAN" ]]; then
147-
(set -x; make $verbose $quiet "$cc" clean)
151+
(set -x; make $verbose $quiet $llvm "$cc" clean)
148152
fi
149153
elif [[ "$1" == "docs" ]]; then
150154
(set -x -o pipefail; make $verbose $quiet -j $JFACTOR htmldocs 2>&1 | tee /output/docs.log)

0 commit comments

Comments
 (0)