summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosip Ponjavic2022-10-17 18:53:14 +0200
committerJosip Ponjavic2022-10-17 18:53:14 +0200
commit66c6cdc4e26ada606dafc5d99f9b9e1441facb8e (patch)
treee7e27e3985fc97ada220c5a11bb5da03970b4102
parent8bbfcd57889feed2379140c199e5083f40c8544f (diff)
downloadaur-66c6cdc4e26ada606dafc5d99f9b9e1441facb8e.tar.gz
Add option to compile with llvm
-rw-r--r--PKGBUILD38
1 files changed, 31 insertions, 7 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 37b7460c3c75..33db4d714560 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -71,6 +71,9 @@
# a new kernel is released, but again, convenient for package bumps.
: "${_use_current:=""}"
+# Enable compiling with LLVM
+: "${_use_llvm_lto:=""}"
+
### IMPORTANT: Do no edit below this line unless you know what you're doing
_major=5.15
@@ -85,6 +88,9 @@ arch=('x86_64')
url="https://github.com/clearlinux-pkgs/linux-lts2021"
license=('GPL2')
makedepends=('bc' 'cpio' 'git' 'libelf' 'pahole' 'xmlto')
+if [ -n "$_use_llvm_lto" ]; then
+ makedepends+=(clang llvm lld python)
+fi
options=('!strip')
_gcc_more_v='20220315'
source=(
@@ -95,6 +101,13 @@ source=(
"more-uarches-$_gcc_more_v.tar.gz::https://github.com/graysky2/kernel_compiler_patch/archive/$_gcc_more_v.tar.gz"
)
+if [ -n "$_use_llvm_lto" ]; then
+ BUILD_FLAGS=(
+ LLVM=1
+ LLVM_IAS=1
+ )
+fi
+
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
@@ -185,7 +198,18 @@ prepare() {
# Library routines
scripts/config --enable FONT_TER16x32
- make olddefconfig
+ if [ -n "$_use_llvm_lto" ]; then
+ scripts/config --disable LTO_NONE \
+ --enable LTO \
+ --enable LTO_CLANG \
+ --enable ARCH_SUPPORTS_LTO_CLANG \
+ --enable ARCH_SUPPORTS_LTO_CLANG_THIN \
+ --enable HAS_LTO_CLANG \
+ --enable LTO_CLANG_THIN \
+ --enable HAVE_GCC_PLUGINS
+ fi
+
+ make ${BUILD_FLAGS[*]} olddefconfig
diff -u $srcdir/$pkgbase/config .config || :
# https://github.com/graysky2/kernel_compiler_patch
@@ -195,10 +219,10 @@ prepare() {
if [ -n "$_subarch" ]; then
# user wants a subarch so apply choice defined above interactively via 'yes'
- yes "$_subarch" | make oldconfig
+ yes "$_subarch" | make ${BUILD_FLAGS[*]} oldconfig
else
# no subarch defined so allow user to pick one
- make oldconfig
+ make ${BUILD_FLAGS[*]} oldconfig
fi
### Optionally use running kernel's config
@@ -221,17 +245,17 @@ prepare() {
if [ -n "$_localmodcfg" ]; then
if [ -e $HOME/.config/modprobed.db ]; then
echo "Running Steven Rostedt's make localmodconfig now"
- make LSMOD=$HOME/.config/modprobed.db localmodconfig
+ make ${BUILD_FLAGS[*]} LSMOD=$HOME/.config/modprobed.db localmodconfig
else
echo "No modprobed.db data found"
exit
fi
fi
- make -s kernelrelease > version
+ make ${BUILD_FLAGS[*]} -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
- [[ -z "$_makenconfig" ]] || make nconfig
+ [[ -z "$_makenconfig" ]] || make ${BUILD_FLAGS[*]} nconfig
### Save configuration for later reuse
cp -Tf ./.config "${startdir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"
@@ -239,7 +263,7 @@ prepare() {
build() {
cd ${_srcname}
- make all
+ make ${BUILD_FLAGS[*]} all
}
_package() {