#_ _ _ _____ #| |__ | | __ _ ___| | ___ __ ___ ___ ___ _ __ |___ / #| '_ \| |/ _` |/ __| |/ / '_ ` _ \ / _ \ / _ \| '_ \ |_ \ #| |_) | | (_| | (__| <| | | | | | (_) | (_) | | | |___) | #|_.__/|_|\__,_|\___|_|\_\_| |_| |_|\___/ \___/|_| |_|____/ #Maintainer: blackmoon3 #Credits: Jan Alexander Steffens (heftig) #Credits: Andreas Radke #Credits: MischiefTomato #Credits: Joan Figueras #Credits: Torge Matthies #Credits: Yoshi2889 #Credits: Tobias Powalowski #Credits: Thomas Baechler ################################# Arch ################################ ARCH=x86 ################################# Grep GCC version ################################ _gccversion=$(gcc -dumpversion) ################################# CC/CXX/HOSTCC/HOSTCXX ################################ #Set compiler to build the kernel #Set '1' to build with GCC #Set '2' to build with CLANG and LLVM #Default is empty. It will build with GCC. To build with different compiler just use : env _compiler=(1 or 2) makepkg -s if [ -z ${_compiler+x} ]; then _compiler= fi if [[ "$_compiler" = "1" ]]; then _compiler=1 BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++) elif [[ "$_compiler" = "2" ]]; then _compiler=2 BUILD_FLAGS=(CC=clang CXX=clang++ HOSTCC=clang HOSTCXX=clang++ LD=ld.lld LLVM=1 LLVM_IAS=1) else _compiler=1 BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++) fi ################################################################################### pkgbase=linux-cpu-optimized 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 with graysky2 kernel_compiler_patch' 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) if [[ "$_compiler" = "2" ]]; then makedepends+=(clang llvm llvm-libs lld python) fi 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 # CPU patches 0001-x86-kconfig-more-uarches-for-kernel-5.17.patch 0002-XANMOD-Makefile-Move-ARM-and-x86-instruction-set-sel.patch 0013-optimize_harder_O3.patch # Arch patches 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 # Set LTO with CLANG/LLVM if [[ "$_compiler" = "2" ]]; then 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 "" fi 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 msg "Patch addition config" msg2 "Enable CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE (O3) (0013-optimize_harder_O3.patch) (Replace O2 by O3)" scripts/config --disable CONFIG_CC_OPTIMIZE_FOR_SIZE scripts/config --enable CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE sleep 2s #msg2 "Set CPU optimization" # You can always set the CPU optimization by manualy # disable CONFIG_GENERIC_CPU and set the optimization # you want # Ex. if you what alderlake optimization #scripts/config --disable CONFIG_GENERIC_CPU #scripts/config --enable CONFIG_MALDERLAKE #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 if [[ "$_compiler" = "1" ]]; then make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig elif [[ "$_compiler" = "2" ]]; then make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig fi plain "" make -s kernelrelease > version msg2 "Prepared $pkgbase version $(