Fix clang package

This commit is contained in:
Wizzard 2023-10-11 13:04:41 -04:00
parent f51a83dc93
commit f7d584b47c
1 changed files with 22 additions and 39 deletions

View File

@ -1,40 +1,32 @@
# Description # Template file for 'linux6.5-zen'
pkgname=linux6.5-zen pkgname=linux6.5-zen
version=6.5.7 version=6.5.7
revision=2 revision=5
zen=1 zen=1
python_version=3 wrksrc="linux-${version}-zen${zen}"
short_desc="Linux kernel and modules with Zen patches (${version%.*} series) compiled with Clang" short_desc="Linux kernel and modules with Zen patches (${version%.*} series) compiled with Clang"
maintainer="Wizzard <retard@deadzone.lol>" maintainer="Wizzard <retard@deadzone.lol>"
license="GPL-2.0-only" license="GPL-2.0-only"
homepage="https://github.com/zen-kernel/zen-kernel" homepage="http://www.zen-kernel.org/"
distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz" distfiles="https://github.com/zen-kernel/zen-kernel/archive/refs/tags/v${version}-zen${zen}.tar.gz"
# Update checksum once you get the actual one for the Zen version checksum="21b881332c189ce3994bbfa3496daae0fa0890f478814b20c045f3180b4ff12c"
checksum="21b881332c189ce3994bbfa3496daae0fa0890f478814b20c045f3180b4ff12c" # replace with the correct checksum python_version=3
archs="x86_64* i686* ppc* aarch64*"
patch_args="-Np1" patch_args="-Np1"
# Standard kernel template setup nodebug=yes # -dbg package is generated below manually
nodebug=yes
nostrip=yes nostrip=yes
noverifyrdeps=yes noverifyrdeps=yes
noshlibprovides=yes noshlibprovides=yes
preserve=yes preserve=yes
# Set compiler to Clang hostmakedepends="tar xz lz4 bc-gh elfutils-devel flex gmp-devel kmod libmpc-devel
export CC=clang openssl-devel perl uboot-mkimage cpio clang llvm lld pahole python3 which"
export HOSTCC=clang
export CXX=clang++
export HOSTCXX=clang++
# Dependencies
hostmakedepends="tar xz lz4 bc-gh elfutils-devel flex gmp-devel kmod libmpc-devel openssl-devel perl uboot-mkimage cpio pahole python3 clang"
# This denotes the version for various hooks and scripts
_kernver="${version}-zen${zen}_${revision}" _kernver="${version}-zen${zen}_${revision}"
triggers="kernel-hooks" triggers="kernel-hooks"
kernel_hooks_version="${_kernver}" kernel_hooks_version="${_kernver}"
# These files could be modified when an external module is built.
mutable_files=" mutable_files="
/usr/lib/modules/${_kernver}/modules.builtin.bin /usr/lib/modules/${_kernver}/modules.builtin.bin
/usr/lib/modules/${_kernver}/modules.builtin.alias.bin /usr/lib/modules/${_kernver}/modules.builtin.alias.bin
@ -47,6 +39,7 @@ mutable_files="
/usr/lib/modules/${_kernver}/modules.alias.bin /usr/lib/modules/${_kernver}/modules.alias.bin
/usr/lib/modules/${_kernver}/modules.devname" /usr/lib/modules/${_kernver}/modules.devname"
# reproducible build
export KBUILD_BUILD_TIMESTAMP=${SOURCE_DATE_EPOCH:-0} export KBUILD_BUILD_TIMESTAMP=${SOURCE_DATE_EPOCH:-0}
export KBUILD_BUILD_USER=voidlinux export KBUILD_BUILD_USER=voidlinux
export KBUILD_BUILD_HOST=zen export KBUILD_BUILD_HOST=zen
@ -59,18 +52,9 @@ if [ "${_patchver}" ]; then
fi fi
do_configure() { do_configure() {
# Clang specific configurations
echo "CONFIG_CC_IS_CLANG=y" >> .config
echo "CONFIG_CLANG_VERSION=$(clang --version | head -n1 | awk '{print $3}' | sed 's/\..*//')" >> .config
echo "CONFIG_LTO_CLANG=y" >> .config
echo "CONFIG_LTO_THIN=y" >> .config
# If there's a file called <arch>-dotconfig, use it to # If there's a file called <arch>-dotconfig, use it to
# configure the kernel; otherwise use arch defaults and all stuff # configure the kernel; otherwise use arch defaults and all stuff
# as modules (allmodconfig). # as modules (allmodconfig).
local arch subarch local arch subarch
case "$XBPS_TARGET_MACHINE" in case "$XBPS_TARGET_MACHINE" in
@ -87,18 +71,18 @@ do_configure() {
if [ -f ${FILESDIR}/${subarch:-$arch}-dotconfig-custom ]; then if [ -f ${FILESDIR}/${subarch:-$arch}-dotconfig-custom ]; then
msg_normal "Detected a custom .config file for your arch, using it.\n" msg_normal "Detected a custom .config file for your arch, using it.\n"
cp -f ${FILESDIR}/${subarch:-$arch}-dotconfig-custom .config cp -f ${FILESDIR}/${subarch:-$arch}-dotconfig-custom .config
make ${makejobs} ARCH=$arch ${_args} oldconfig make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=$arch ${_args} oldconfig
elif [ -f ${FILESDIR}/${subarch:-$arch}-dotconfig ]; then elif [ -f ${FILESDIR}/${subarch:-$arch}-dotconfig ]; then
msg_normal "Detected a .config file for your arch, using it.\n" msg_normal "Detected a .config file for your arch, using it.\n"
cp -f ${FILESDIR}/${subarch:-$arch}-dotconfig .config cp -f ${FILESDIR}/${subarch:-$arch}-dotconfig .config
make ${makejobs} ARCH=$arch ${_args} oldconfig make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=$arch ${_args} oldconfig
elif [ -f ${FILESDIR}/${XBPS_TARGET_MACHINE%%-musl}-dotconfig ]; then elif [ -f ${FILESDIR}/${XBPS_TARGET_MACHINE%%-musl}-dotconfig ]; then
msg_normal "Detected a .config file for your cpu family, using it.\n" msg_normal "Detected a .config file for your cpu family, using it.\n"
cp -f ${FILESDIR}/${XBPS_TARGET_MACHINE%%-musl}-dotconfig .config cp -f ${FILESDIR}/${XBPS_TARGET_MACHINE%%-musl}-dotconfig .config
make ${makejobs} ARCH=$arch ${_args} oldconfig make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=$arch ${_args} oldconfig
else else
msg_normal "Defaulting to 'allmodconfig'.\n" msg_normal "Defaulting to 'allmodconfig'.\n"
make ${makejobs} ARCH=$arch ${_args} allmodconfig make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=$arch ${_args} allmodconfig
fi fi
# Always use our revision to CONFIG_LOCALVERSION to match our pkg version. # Always use our revision to CONFIG_LOCALVERSION to match our pkg version.
sed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config sed -i -e "s|^\(CONFIG_LOCALVERSION=\).*|\1\"_${revision}\"|" .config
@ -116,8 +100,8 @@ do_build() {
mips*) _args="uImage modules dtbs"; arch=mips;; mips*) _args="uImage modules dtbs"; arch=mips;;
esac esac
export LDFLAGS= export LDFLAGS=
make ${makejobs} CC=clang HOSTCC=clang ARCH=$arch ${_args} ${_version} ${_cross} prepare make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ARCH=$arch ${_version} ${_cross} ${makejobs} prepare
make ${makejobs} CC=clang HOSTCC=clang ARCH=$arch ${_args} ${_version} ${_cross} ${_args} make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ARCH=$arch ${_version} ${_cross} ${makejobs} ${_args}
} }
do_install() { do_install() {
@ -136,7 +120,7 @@ do_install() {
sed -i '2iexit 0' scripts/depmod.sh sed -i '2iexit 0' scripts/depmod.sh
# Install kernel, firmware and modules # Install kernel, firmware and modules
make ${makejobs} ARCH=${subarch:-$arch} INSTALL_MOD_PATH=${DESTDIR} modules_install make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=${subarch:-$arch} INSTALL_MOD_PATH=${DESTDIR} modules_install
hdrdest=${DESTDIR}/usr/src/kernel-headers-${_kernver} hdrdest=${DESTDIR}/usr/src/kernel-headers-${_kernver}
@ -149,11 +133,11 @@ do_install() {
;; ;;
arm) arm)
vinstall arch/arm/boot/zImage 644 boot vinstall arch/arm/boot/zImage 644 boot
make ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install
;; ;;
arm64) arm64)
vinstall arch/arm64/boot/Image 644 boot vmlinux-${_kernver} vinstall arch/arm64/boot/Image 644 boot vmlinux-${_kernver}
make ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install
;; ;;
powerpc) powerpc)
# zImage on powerpc is useless as it won't load initramfs # zImage on powerpc is useless as it won't load initramfs
@ -163,7 +147,7 @@ do_install() {
;; ;;
mips) mips)
vinstall arch/mips/boot/uImage.bin 644 boot uImage-${_kernver} vinstall arch/mips/boot/uImage.bin 644 boot uImage-${_kernver}
make ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=${subarch:-$arch} INSTALL_DTBS_PATH=${DESTDIR}/boot/dtbs/dtbs-${_kernver} dtbs_install
;; ;;
esac esac
@ -207,7 +191,7 @@ do_install() {
# if generated files from the scripts/ directory need to be included, # if generated files from the scripts/ directory need to be included,
# they need to be copied to ${hdrdest} before this step # they need to be copied to ${hdrdest} before this step
if [ "$CROSS_BUILD" ]; then if [ "$CROSS_BUILD" ]; then
make ${makejobs} ARCH=${subarch:-$arch} _mrproper_scripts make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump HOSTCC=clang HOSTLD=ld.lld HOSTAR=llvm-ar ${makejobs} ARCH=${subarch:-$arch} _mrproper_scripts
# remove host specific objects as well # remove host specific objects as well
find scripts -name '*.o' -delete find scripts -name '*.o' -delete
fi fi
@ -314,7 +298,6 @@ do_install() {
# ... and run depmod again. # ... and run depmod again.
depmod -b ${DESTDIR}/usr -F System.map ${_kernver} depmod -b ${DESTDIR}/usr -F System.map ${_kernver}
} }
linux6.5-zen-headers_package() { linux6.5-zen-headers_package() {
preserve=yes preserve=yes
nostrip=yes nostrip=yes