From 3e56de31105a39c5647c36f27e94cb90d5e4d508 Mon Sep 17 00:00:00 2001 From: Josip Ponjavic Date: Thu, 9 Dec 2021 18:07:16 +0100 Subject: [PATCH] 5.15.7-3 (clr 5.15.6-1105) add option to build with clang/llvm --- .SRCINFO | 2 +- PKGBUILD | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index e614578..5618e21 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = linux-clear pkgdesc = Clear Linux pkgver = 5.15.7 - pkgrel = 2 + pkgrel = 3 url = https://github.com/clearlinux-pkgs/linux arch = x86_64 license = GPL2 diff --git a/PKGBUILD b/PKGBUILD index 8ce72cb..13880d4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -71,6 +71,9 @@ _subarch= # 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 @@ -79,12 +82,15 @@ _srcname=linux-${_major} _clr=${_major}.6-1105 pkgbase=linux-clear pkgver=${_major}.${_minor} -pkgrel=2 +pkgrel=3 pkgdesc='Clear Linux' arch=('x86_64') url="https://github.com/clearlinux-pkgs/linux" license=('GPL2') makedepends=('bc' 'cpio' 'git' 'kmod' 'libelf' 'pahole' 'xmlto') +if [ -n "$_use_llvm_lto" ]; then + makedepends+=(clang llvm lld python) +fi options=('!strip') _gcc_more_v='20210914' source=( @@ -97,6 +103,13 @@ source=( "0001-sysctl-add-sysctl-to-disallow-unprivileged-CLONE_NEW.patch::https://raw.githubusercontent.com/xanmod/linux-patches/8ba6612318090567422d49ccc79bc7bbe5484cfc/linux-5.15.y-xanmod/userns/0001-sysctl-add-sysctl-to-disallow-unprivileged-CLONE_NEW.patch" ) +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})" @@ -196,7 +209,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 @@ -206,10 +230,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 @@ -232,17 +256,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 $(