Skip to content

Commit

Permalink
linux-cachyos: Default to ThinLTO
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Naim <[email protected]>
  • Loading branch information
1Naim committed Oct 1, 2024
1 parent 56aa9e5 commit 6615efd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
10 changes: 9 additions & 1 deletion linux-cachyos/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = linux-cachyos
pkgdesc = Linux SCHED-EXT + BORE + Cachy Sauce Kernel by CachyOS with other patches and improvements
pkgver = 6.11.1
pkgrel = 1
pkgrel = 2
url = https://github.com/CachyOS/linux-cachyos
arch = x86_64
license = GPL-2.0-only
Expand All @@ -15,13 +15,17 @@ pkgbase = linux-cachyos
makedepends = tar
makedepends = xz
makedepends = zstd
makedepends = clang
makedepends = llvm
makedepends = lld
options = !strip
options = !debug
options = !lto
source = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.1.tar.xz
source = config
source = auto-cpu-optimization.sh
source = https://raw.githubusercontent.com/cachyos/kernel-patches/master/6.11/all/0001-cachyos-base-all.patch
source = https://raw.githubusercontent.com/cachyos/kernel-patches/master/6.11/misc/dkms-clang.patch
source = https://raw.githubusercontent.com/cachyos/kernel-patches/master/6.11/sched/0001-sched-ext.patch
source = https://raw.githubusercontent.com/cachyos/kernel-patches/master/6.11/sched/0001-bore-cachy-ext.patch
b2sums = ac9927d74542a2d244b9d683920363ec2dbbe851ae0e069b278f1a0ba82c58b00f0f0312104b46f1b8c06585c2e6acb7eb1e63bd28499891f629c00f9a32f6b5
Expand All @@ -45,8 +49,12 @@ pkgname = linux-cachyos
provides = WIREGUARD-MODULE
provides = KSMBD-MODULE
provides = UKSMD-BUILTIN
provides = linux-cachyos-lto=6.11.1-2
replaces = linux-cachyos-lto=6.11.1-2

pkgname = linux-cachyos-headers
pkgdesc = Headers and scripts for building modules for the Linux SCHED-EXT + BORE + Cachy Sauce Kernel by CachyOS with other patches and improvements kernel
depends = pahole
depends = linux-cachyos
provides = linux-cachyos-lto-headers=6.11.1-2
replaces = linux-cachyos-lto-headers=6.11.1-2
44 changes: 40 additions & 4 deletions linux-cachyos/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ _use_auto_optimization=${_use_auto_optimization-y}
# "full: uses 1 thread for Linking, slow and uses more memory, theoretically with the highest performance gains."
# "thin: uses multiple threads, faster and uses less memory, may have a lower runtime performance than Full."
# "none: disable LTO
_use_llvm_lto=${_use_llvm_lto-none}
_use_llvm_lto=${_use_llvm_lto-thin}

# Use suffix -lto only when requested by the user
# Enabled by default.
Expand Down Expand Up @@ -143,11 +143,11 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix=cachyos-lto
_pkgsuffix=cachyos
pkgbase="linux-$_pkgsuffix"

elif [ -n "$_use_llvm_lto" ] || [[ "$_use_lto_suffix" = "n" ]]; then
_pkgsuffix=cachyos
_pkgsuffix=cachyos-gcc
pkgbase="linux-$_pkgsuffix"
fi
_major=6.11
Expand All @@ -161,7 +161,7 @@ _stable=${_major}.${_minor}
_srcname=linux-${_stable}
#_srcname=linux-${_major}
pkgdesc='Linux SCHED-EXT + BORE + Cachy Sauce Kernel by CachyOS with other patches and improvements'
pkgrel=1
pkgrel=2
_kernver="$pkgver-$pkgrel"
_kernuname="${pkgver}-${_pkgsuffix}"
arch=('x86_64')
Expand Down Expand Up @@ -595,6 +595,12 @@ _package() {
'uksmd: Userspace KSM helper daemon')
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE UKSMD-BUILTIN)

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto=$_kernver)
replaces=(linux-cachyos-lto=$_kernver)
fi

cd "$_srcname"

local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
Expand All @@ -619,6 +625,12 @@ _package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=('pahole' "${pkgbase}")

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto-headers=$_kernver)
replaces=(linux-cachyos-lto-headers=$_kernver)
fi

cd "${_srcname}"
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"

Expand Down Expand Up @@ -704,6 +716,12 @@ _package-dbg(){
pkgdesc="Non-stripped vmlinux file for the $pkgdesc kernel"
depends=("${pkgbase}-headers")

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto-dbg=$_kernver)
replaces=(linux-cachyos-lto-dbg=$_kernver)
fi

cd "${_srcname}"
mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
Expand All @@ -715,6 +733,12 @@ _package-zfs(){
provides=('ZFS-MODULE')
license=('CDDL')

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto-zfs=$_kernver)
replaces=(linux-cachyos-lto-zfs=$_kernver)
fi

cd "$_srcname"
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"

Expand All @@ -732,6 +756,12 @@ _package-nvidia(){
conflicts=("$pkgbase-nvidia-open")
license=('custom')

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto-nvidia=$_kernver)
replaces=(linux-cachyos-lto-nvidia=$_kernver)
fi

cd "$_srcname"
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"

Expand All @@ -749,6 +779,12 @@ _package-nvidia-open(){
conflicts=("$pkgbase-nvidia")
license=('MIT AND GPL-2.0-only')

# Replace LTO kernel with the default kernel
if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]; then
provides+=(linux-cachyos-lto-nvidia-open=$_kernver)
replaces=(linux-cachyos-lto-nvidia-open=$_kernver)
fi

cd "$_srcname"
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"

Expand Down
4 changes: 3 additions & 1 deletion script-v3-v4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_use_auto_optimization-y/_use_auto_optimization-/" {}
## Enable ZFS
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_build_zfs-/_build_zfs-y/" {}
## Enable Generic v3
## Enable Generic v3
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_processor_opt-/_processor_opt-GENERIC_V3/" {}
## Enable NVIDIA module
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_build_nvidia-/_build_nvidia-y/" {}
## Enable Open NVIDIA module
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_build_nvidia_open-/_build_nvidia_open-y/" {}
## Disable clang-LTO
find . -name "PKGBUILD" | xargs -I {} sed -i "s/_use_llvm_lto-thin/_use_llvm_lto-none/" {}

## GCC v3 Kernel

Expand Down

0 comments on commit 6615efd

Please sign in to comment.