# _ _ _ _ _____ #| |__ | | __ _ ___| | _____| | ___ _|___ / #| '_ \| |/ _` |/ __| |/ / __| |/ / | | | |_ \ #| |_) | | (_| | (__| <\__ \ <| |_| |___) | #|_.__/|_|\__,_|\___|_|\_\___/_|\_\\__, |____/ # |___/ #Maintainer: blacksky3 #Credits: Jan Alexander Steffens (heftig) #Credits: Andreas Radke #Credits: Luca Stefani ################################# Arch ################################ ARCH=x86 ################################# Grep GCC version ################################ _gccversion=$(gcc -dumpversion) ################################# CC/CXX/HOSTCC/HOSTCXX ################################ #Set kernel to build with LLVM/CLANG BUILD_FLAGS=(CC=clang CXX=clang++ HOSTCC=clang HOSTCXX=clang++ LD=ld.lld LLVM=1 LLVM_IAS=1) ################################################################################### pkgbase=linux-llvm pkgname=("$pkgbase" "$pkgbase-headers") for _p in "${pkgname[@]}"; do eval "package_$_p() { $(declare -f "_package${_p#$pkgbase}") _package${_p#$pkgbase} }" done pkgver=6.3.8 _pkgver=6.3.8 pkgrel=1 major=6.3 commit=e7308a977d83f3cf94ed228b0f6b9b65a4d9139c arch=(x86_64) pkgdesc='The Linux kernel and modules - Build with LLVM/CLANG' url='https://www.kernel.org/' license=(GPL2) makedepends=(bc kmod libelf pahole cpio perl tar xz xmlto git) makedepends+=(bison flex zstd make patch gcc gcc-libs glibc binutils) makedepends+=(clang llvm llvm-libs lld python) # For LLVM/CLANG options=(!strip) archlinuxpath=https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/$commit source=(https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$_pkgver.tar.xz ${archlinuxpath}/config 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch) export KBUILD_BUILD_HOST=archlinux export KBUILD_BUILD_USER=$pkgbase export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})" prepare(){ cd ${srcdir}/linux-$_pkgver local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" [[ $src = *.patch ]] || continue msg2 "Applying patch $src..." patch -Np1 < "../$src" done plain "" # Copy the config file first # Copy "${srcdir}"/config to "${srcdir}"/linux-${_pkgver}/.config msg2 "Copy "${srcdir}"/config to "${srcdir}"/linux-$_pkgver/.config" cp "${srcdir}"/config .config sleep 2s plain "" # Remove gcc-plugin if gcc version = 13.0.0 if [[ "$_gccversion" = "13.0.0" ]]; then msg2 "Remove GCC_PLUGINS" scripts/config --disable CONFIG_HAVE_GCC_PLUGINS scripts/config --disable CONFIG_GCC_PLUGINS sleep 2s plain "" fi msg "Set LLVM/CLANG LTO" msg2 "Enable THIN LTO" scripts/config --enable CONFIG_LTO scripts/config --enable CONFIG_LTO_CLANG scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN scripts/config --disable CONFIG_LTO_NONE scripts/config --enable CONFIG_HAS_LTO_CLANG scripts/config --disable CONFIG_LTO_CLANG_FULL scripts/config --enable CONFIG_LTO_CLANG_THIN scripts/config --enable CONFIG_HAVE_GCC_PLUGINS #msg2 "Enable FULL LTO" #scripts/config --enable CONFIG_LTO #scripts/config --enable CONFIG_LTO_CLANG #scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG #scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN #scripts/config --disable CONFIG_LTO_NONE #scripts/config --enable CONFIG_HAS_LTO_CLANG #scripts/config --enable CONFIG_LTO_CLANG_FULL #scripts/config --disable CONFIG_LTO_CLANG_THIN #scripts/config --enable CONFIG_HAVE_GCC_PLUGINS #msg2 "Disable LTO" #scripts/config --enable CONFIG_LTO_NONE sleep 2s plain "" msg "Apply some Archlinux config" msg2 "Compress modules by default (following Arch's kernel)" scripts/config --enable CONFIG_MODULE_COMPRESS_ZSTD sleep 2s msg2 "CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team" scripts/config --enable CONFIG_STACK_VALIDATION sleep 2s msg2 "Enable IKCONFIG following Arch's philosophy" scripts/config --enable CONFIG_IKCONFIG scripts/config --enable CONFIG_IKCONFIG_PROC sleep 2s msg2 "Enable FUNCTION_TRACER/GRAPH_TRACER" scripts/config --enable CONFIG_FUNCTION_TRACER scripts/config --enable CONFIG_STACK_TRACER sleep 2s msg2 "Enable CONFIG_USER_NS_UNPRIVILEGED" scripts/config --enable CONFIG_USER_NS sleep 2s plain "" msg2 "Supress depmod" sed -i '2iexit 0' scripts/depmod.sh sleep 2s plain "" # Setting localversion msg2 "Setting localversion..." # --save-scmversion as been removed in upstream # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/setlocalversion?h=v6.3-rc1&id=f6e09b07cc12a4d104bb19fe7566b0636f60c413 # scripts/setlocalversion --save-scmversion echo "-${pkgbase}" > localversion plain "" # Config make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig plain "" make -s kernelrelease > version msg2 "Prepared $pkgbase version $(