diff options
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 363 |
1 files changed, 231 insertions, 132 deletions
@@ -1,140 +1,234 @@ -# Maintainer: graysky <therealgraysky AT protonmail DOT com> -# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> +#Maintainer: archdevlab <https://github.com/archdevlab> +#Credits: Jan Alexander Steffens (heftig) <heftig@archlinux.org> +#Credits: Andreas Radke <andyrtr@archlinux.org> +#Credits: graysky <therealgraysky AT protonmail DOT com> + +################################# 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-rc +pkgver=6.9rc1 +_pkgver=6.9-rc1 pkgrel=1 -_srcname=linux-5.19 -_major=5.19 -### on initial release this is null otherwise it is the current stable subversion -### ie 1,2,3 corresponding $_major.1, $_major.3 etc -_minor=7 -_minorc=$((_minor+1)) -### on initial release this is just $_major -[[ -z $_minor ]] && _fullver=$_major || _fullver=$_major.$_minor -#_fullver=$_major.$_minor -_rcver=1 -_rcpatch=patch-${_major}.${_minorc}-rc${_rcver} -pkgver=${_major}.${_minorc}rc${_rcver} +commit=abef9db380deca88617f7014b683667ef6fc81e4 arch=(x86_64) -license=(GPL2) -url="https://www.kernel.org/" +url='https://www.kernel.org/' +license=(GPL-2.0-only) makedepends=( - bc kmod libelf cpio perl tar xz + bc + cpio + gettext + libelf + pahole + perl + python + tar + xz + kmod + xmlto + # htmldocs + graphviz + imagemagick + python-sphinx + python-yaml + texlive-latexextra ) -options=('!strip') -_modprobeddb= -source=( - https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/"$_rcpatch".{xz,sign} - # https://lkml.org/lkml/2019/8/23/712 - #"$_rcpatch.patch::https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/patch/?id=$_srcname.y&id2=v${_major}.${_minor}" - https://www.kernel.org/pub/linux/kernel/v5.x/linux-$_fullver.tar.{xz,sign} - config # the main kernel config file - 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch - 0002-drm-i915-psr-Use-full-update-In-case-of-area-calcula.patch - 0003-drm-i915-Ensure-damage-clip-area-is-within-pipe-area.patch - 0004-mm-vmscan-fix-extreme-overreclaim-and-swap-floods.patch - 0005-soundwire-intel-use-pm_runtime_resume-on-component-p.patch +makedepends+=( + bison + flex + zstd + make + patch + gcc + gcc-libs + glibc + binutils + git ) -validpgpkeys=( - 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds - '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman - 'A2FF3A36AAA56654109064AB19802F8B0D70FC30' # Jan Alexander Steffens (heftig) - 'C7E7849466FE2358343588377258734B41C31549' # David Runge <dvzrv@archlinux.org> +if [[ "$_compiler" = "2" ]]; then + makedepends+=( + clang + llvm + llvm-libs + lld + clang + python + ) +fi +options=( + !debug + !strip ) -b2sums=('755416aee62b7e737ad29a3f552ba462dd4e6f1b8cc6b61c4961ea2ff8a06b68eb69f9d671e8146cfcedc7edff2e184c71bd2bd00e214e4f374b3252719c2975' - 'SKIP' - '9fd934cf511ded0800a387beda79e1d4c7523926c69cae0f4eee62cfbc0fab4b97e666c9a0b79130aff9e17dfc4c222a04a6037776182954b1edc0af9b8517c6' - 'SKIP' - '28b82cdb5faac7f93368bbd5c4a9106f729dd39624abbd7a0acc4909599175af0a987c91bb6c0e348ae1ab2180f5e85c3a04ce6ba03e03b0dee45fe3b81d3847' - '601a38549c139dee5511075133fca55fd6d11821df0d6c94807e9182fd8b09572d59cdf9ae14ff79cd38c8db15feb1d80373cfed938627fac1f05ac7169c9b22' - '0a2fb7535f65e402b1b24e5e86f48dddd004d2ca2feff4a6066e221e55e34d6343eb1e515b62ee03c2ccb19692921593ae5a17ff63fba46c6df6b74bfe37897c' - 'e53054446bb25fea9ba1de582c57da637112219c308255dd4003c040b61bb8d26fcd5bd61515884df91f81611a762edf2fe83493567354c164cf55afbc6e4fa8' - 'b6a3342e9993383e714eeabeb1e2ab6e9f9062af4d0c8551522c3554cc84b93ed3bf4ce22e8e74e1e73f3fd668c334ca2e3e358bd6e75c9d75eb487983ee8bd5' - '5efabcfc95f308af6f22015e6a15b170393773c214711460aaf9d455c4ea74ad258fb3d392f8c0383fb7b10f97c1f237b332544345ff98ba69c4c176728bea60') - +archlinuxpath=https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/$commit +source=(#https://github.com/torvalds/linux/archive/refs/tags/v${_pkgver}.tar.gz + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-${_pkgver}.tar.gz + ${archlinuxpath}/config + # 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() { - # hacky work around for rc1 not getting extracted - # https://bbs.archlinux.org/viewtopic.php?id=265115 - if [[ ! -f "$srcdir/$_rcpatch" ]]; then - xz -dc "$SRCDEST/$_rcpatch.xz" > "$_rcpatch" - fi - - cd linux-${_fullver} - msg2 "Setting version..." - scripts/setlocalversion --save-scmversion - echo "-$pkgrel" > localversion.10-pkgrel - echo "${pkgbase#linux}" > localversion.20-pkgname - - msg2 "Applying $_rcpatch..." - patch -Np1 <"../$_rcpatch" +prepare(){ + cd ${srcdir}/linux-$_pkgver local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" - [[ $src = 0*.patch ]] || continue - echo "Applying patch $src..." + [[ $src = *.patch ]] || continue + msg "Applying patch $src..." patch -Np1 < "../$src" done - msg2 "Setting config..." - cp ../config .config - - # disable CONFIG_DEBUG_INFO at build time otherwise memory usage blows up and - # can easily overwhelm a system with 32 GB of memory using a tmpfs build. - # introduced by FS#66260, see: - # https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/linux&id=663b08666b269eeeeaafbafaee07fd03389ac8d7 - scripts/config --disable CONFIG_DEBUG_INFO - scripts/config --disable CONFIG_CGROUP_BPF - scripts/config --disable CONFIG_BPF_LSM - scripts/config --disable CONFIG_BPF_PRELOAD - scripts/config --disable CONFIG_BPF_LIRC_MODE2 - scripts/config --disable CONFIG_BPF_KPROBE_OVERRIDE - - if [[ -n "$_modprobeddb" ]]; then - #msg "Running Steven Rostedt's make localmodconfig now" - #sudo /usr/bin/modprobed-db recall - #make localmodconfig - msg "Running Steven Rostedt's make localmodconfig now" - if [[ -f $HOME/.config/modprobed.db ]]; then - _useit="$HOME/.config/modprobed.db" - else - _useit="../modprobed.db" - fi - make LSMOD="$_useit" localmodconfig + plain "" + + # Copy the config file first + msg "Copy the config file first..." + cp "${srcdir}"/config .config + + sleep 2s + + plain "" + + # # Remove gcc-plugin if gcc version = 13.0.0 + # if [[ "$_gccversion" = "13.0.0" ]]; then + # + # msg "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 + + msg "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 + + #msg "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 + + #msg "Disable LTO" + #scripts/config --enable CONFIG_LTO_NONE + + sleep 2s + plain "" fi - make olddefconfig - diff -u ../config .config || : - # make nconfig + # Supress depmod + msg "Supress depmod..." + sed -i '2iexit 0' scripts/depmod.sh + + sleep 2s + + plain "" + + # Setting localversion + msg "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 + msg "make olddefconfig..." + make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig + + plain "" make -s kernelrelease > version - msg2 "Prepared $pkgbase version $(<version)" + msg "Prepared $pkgbase version $(<version)" + + plain "" } -build() { - cd linux-${_fullver} - make all +build(){ + cd ${srcdir}/linux-$_pkgver + + msg "make all" + make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) all + msg "make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1" + make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1 } -_package() { - pkgdesc="The release candidate kernel and modules" - depends=(coreutils kmod initramfs) - optdepends=('wireless-regdb: to set the correct wireless channels of your country' - 'linux-firmware: firmware images needed for some devices') - provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) - replaces=(virtualbox-guest-modules-arch wireguard-arch) +_package(){ + pkgdesc='The Linux kernel and modules - Release Candidate version' + depends=( + coreutils + initramfs + kmod + ) + optdepends=( + 'wireless-regdb: to set the correct wireless channels of your country' + 'linux-firmware: firmware images needed for some devices' + ) + provides=( + KSMBD-MODULE + VIRTUALBOX-GUEST-MODULES + WIREGUARD-MODULE + ) + replaces=( + virtualbox-guest-modules-arch + wireguard-arch + ) + + cd ${srcdir}/linux-$_pkgver - cd linux-${_fullver} local kernver="$(<version)" - local modulesdir="$pkgdir/usr/lib/modules/$kernver" + local modulesdir="${pkgdir}"/usr/lib/modules/${kernver} - echo "Installing boot image..." + msg "Installing boot image..." # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz" @@ -142,23 +236,24 @@ _package() { # Used by mkinitcpio to name the kernel echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase" - echo "Installing modules..." - make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \ - DEPMOD=/doesnt/exist modules_install # Suppress depmod + msg "Installing modules..." + ZSTD_CLEVEL=19 make ARCH=${ARCH} ${BUILD_FLAGS[*]} INSTALL_MOD_PATH="${pkgdir}"/usr INSTALL_MOD_STRIP=1 -j$(nproc) modules_install # remove build and source links - rm "$modulesdir"/{source,build} + msg "Remove build dir and source dir..." + rm -rf "$modulesdir"/{source,build} } -_package-headers() { - pkgdesc="Headers and scripts for building modules for the linux-rc kernel" +_package-headers(){ + pkgdesc="Headers and scripts for building modules for the $pkgbase package" + depends=("${pkgbase}" pahole) + + cd ${srcdir}/linux-$_pkgver - cd linux-${_fullver} - local builddir="$pkgdir/usr/lib/modules/$(<version)/build" + local builddir="$pkgdir"/usr/lib/modules/"$(<version)"/build - echo "Installing build files..." - install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \ - localversion.* version vmlinux + msg "Installing build files..." + install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map *localversion* version vmlinux tools/bpf/bpftool/vmlinux.h install -Dt "$builddir/kernel" -m644 kernel/Makefile install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile cp -t "$builddir" -a scripts @@ -167,9 +262,11 @@ _package-headers() { install -Dt "$builddir/tools/objtool" tools/objtool/objtool # required when DEBUG_INFO_BTF_MODULES is enabled - # install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids + if [ -f tools/bpf/resolve_btfids/resolve_btfids ]; then + install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids + fi - echo "Installing headers..." + msg "Installing headers..." cp -t "$builddir" -a include cp -t "$builddir/arch/x86" -a arch/x86/include install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s @@ -188,30 +285,30 @@ _package-headers() { # https://bugs.archlinux.org/task/71392 install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h - echo "Installing KConfig files..." + msg "Installing KConfig files..." find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \; - echo "Removing unneeded architectures..." + msg "Removing unneeded architectures..." local arch for arch in "$builddir"/arch/*/; do [[ $arch = */x86/ ]] && continue - echo "Removing $(basename "$arch")" + msg2 "Removing $(basename "$arch")" rm -r "$arch" done - echo "Removing documentation..." + msg "Removing documentation..." rm -r "$builddir/Documentation" - echo "Removing broken symlinks..." + msg "Removing broken symlinks..." find -L "$builddir" -type l -printf 'Removing %P\n' -delete - echo "Removing loose objects..." + msg "Removing loose objects..." find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete - echo "Stripping build tools..." + msg "Stripping build tools..." local file while read -rd '' file; do - case "$(file -bi "$file")" in + case "$(file -Sib "$file")" in application/x-sharedlib\;*) # Libraries (.so) strip -v $STRIP_SHARED "$file" ;; application/x-archive\;*) # Libraries (.a) @@ -223,17 +320,19 @@ _package-headers() { esac done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0) - #echo "Stripping vmlinux..." - #strip -v $STRIP_STATIC "$builddir/vmlinux" - # not needed since not building with CONFIG_DEBUG_INFO=y + msg "Stripping vmlinux..." + strip -v $STRIP_STATIC "$builddir/vmlinux" - echo "Adding symlink..." + msg "Adding symlink..." mkdir -p "$pkgdir/usr/src" ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase" - } -pkgname=("$pkgbase" "$pkgbase-headers") +sha256sums=('a0239424e10e45c43252d5decc6978a3fa58e0d4d631d0855db57fa209f53165' + 'c2b00c84c4b543db431e06604d939a62f93107d18369f4d9860dc8062b01ab45' + '416609986399d3046811bcc2344f4ee0833b6c92e305da3925a6e193f810dad2') + +pkgname=($pkgbase $pkgbase-headers) for _p in "${pkgname[@]}"; do eval "package_$_p() { $(declare -f "_package${_p#$pkgbase}") |