Skip to content

Commit

Permalink
PKGBUILD: Make LTO a hard dependency when building with clang
Browse files Browse the repository at this point in the history
In hindsight, there's not much to be gained by compiling clang without LTO. Faster compile times can be achieved
but the additional time it takes using LTO hardly matters on modern computers.

Forcing this on also makes it simple for the build script we use because the clang-specific features aren't
available on GCC (obviously).

Also refactored the pkgsuffix conditions to use _is_lto_kernel instead to make it cleaner.

Suggested-by: Vasiliy Stelmachenok <[email protected]>
Signed-off-by: Eric Naim <[email protected]>
  • Loading branch information
1Naim committed Dec 6, 2024
1 parent bc598bd commit 973a174
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
10 changes: 5 additions & 5 deletions linux-cachyos-bmq/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-gcc"
else
_pkgsuffix="cachyos-${_cpusched}"
Expand Down Expand Up @@ -199,7 +199,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-bore/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-gcc"
else
_pkgsuffix="cachyos-${_cpusched}"
Expand Down Expand Up @@ -199,7 +199,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-deckify/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-deckify-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-deckify-gcc"
else
_pkgsuffix="cachyos-deckify"
Expand Down Expand Up @@ -201,7 +201,7 @@ source=(
"${_patchsource}/misc/0001-handheld.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-eevdf/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-gcc"
else
_pkgsuffix="cachyos-${_cpusched}"
Expand Down Expand Up @@ -199,7 +199,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-rc/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ _autofdo_profile_name=${_autofdo_profile_name-}


# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ] || [ -n "$_autofdo" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-rc-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-rc-gcc"
else
_pkgsuffix="cachyos-rc"
Expand Down Expand Up @@ -212,7 +212,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-rt-bore/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-${_cpusched}-gcc"
else
_pkgsuffix="cachyos-${_cpusched}"
Expand Down Expand Up @@ -199,7 +199,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos-server/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ _build_nvidia_open=${_build_nvidia_open-}
_build_debug=${_build_debug-}

# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix="cachyos-server-lto"
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix="cachyos-server-gcc"
else
_pkgsuffix="cachyos-server"
Expand Down Expand Up @@ -199,7 +199,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down
10 changes: 5 additions & 5 deletions linux-cachyos/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ _autofdo_profile_name=${_autofdo_profile_name-}


# ATTENTION: Do not modify after this line
_is_clang_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] || [ -n "$_use_kcfi" ] || [ -n "$_autofdo" ]
_is_lto_kernel() {
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]]
return $?
}

if [[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" ]] && [ "$_use_lto_suffix" = "y" ]; then
if _is_lto_kernel && [ "$_use_lto_suffix" = "y" ]; then
_pkgsuffix=cachyos-lto
elif [ "$_use_llvm_lto" = "none" ] && [ -z "$_use_kcfi" ] && [ "$_use_gcc_suffix" = "y" ]; then
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "y" ]; then
_pkgsuffix=cachyos-gcc
else
_pkgsuffix=cachyos
Expand Down Expand Up @@ -212,7 +212,7 @@ source=(
"${_patchsource}/all/0001-cachyos-base-all.patch")

# LLVM makedepends
if _is_clang_kernel; then
if _is_lto_kernel; then
makedepends+=(clang llvm lld)
source+=("${_patchsource}/misc/dkms-clang.patch")
BUILD_FLAGS=(
Expand Down

0 comments on commit 973a174

Please sign in to comment.