From 795a54ebd2ee20ed5f7a2b4c11a1ade947486de8 Mon Sep 17 00:00:00 2001 From: Yaraslau Furman Date: Sat, 4 Jan 2025 18:15:43 +0200 Subject: [PATCH 1/4] Revert "PKGBUILD: apply extra uarches patch even when defconfig is copied" This reverts commit 6da003f2206ad8849c19865df144777d52faa7ad. --- PKGBUILD | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 7c46b93..744ae3e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -201,11 +201,6 @@ apply_patches() { patch -Np1 -i "${srcdir}/cl-linux/${i}" || true done - - # Patch with kernel_compiler_patch patches. - # Do this before any defconfig invocations so we - # have all of the extra selectable uarches ready and selectable - patch -Np1 -i "$srcdir/kernel_compiler_patch-$_kernelcompilerpatch/more-ISA-levels-and-uarches-for-kernel-6.1.79+.patch" } # Allows user to modify the kernel config @@ -323,6 +318,11 @@ update_defconfig() { # Run olddefconfig make ${BUILD_FLAGS[*]} olddefconfig diff -u $srcdir/cl-linux/config .config || : + + # Patch with kernel_compiler_patch patches + # This must be executed after olddefconfig + # to allow for the next section to run. + patch -Np1 -i "$srcdir/kernel_compiler_patch-$_kernelcompilerpatch/more-ISA-levels-and-uarches-for-kernel-6.1.79+.patch" # Set subarch automatically if [ -n "${_subarch}" ]; then From d0fecf90fe59700f2d25ca1b122363f31ca9696c Mon Sep 17 00:00:00 2001 From: Yaraslau Furman Date: Sat, 4 Jan 2025 19:08:22 +0200 Subject: [PATCH 2/4] PKGBUILD: V2: apply extra uarches patch even when defconfig is copied Otherwise MK8 or MCORE2 is selected which results in a misoptimization. Also ensure that Processor family choice menu is always brought up by breaking the config a little bit. Code formatting pass was applied, CRLF was replaced with LF --- PKGBUILD | 95 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 744ae3e..ebfe237 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,7 +5,7 @@ # - JeremyStarTM # - yarost12 # - Josip Ponjavic -# +# # For a list of maintainers see MAINTAINERS.md ### BUILD OPTIONS @@ -14,17 +14,17 @@ # env _makemenuconfig=y _copyfinalconfig=y _subarch=30 makepkg # Tweak kernel options prior to a build via menuconfig. -# +# # Set to anything but null to activate. : "${_makemenuconfig:=""}" # Tweak kernel options prior to a build via nconfig. -# +# # Set to anything but null to activate. : "${_makenconfig:=""}" # Tweak kernel options prior to a build via xconfig. -# +# # Set to anything but null to activate. : "${_makexconfig:=""}" @@ -52,16 +52,16 @@ # Determines whether the kernel configuration should be # copied into the source tree before compilation starts. -# +# # Set to anything but null to activate. : "${_copyfinalconfig:=""}" # Only compile active modules to VASTLY reduce the number # of modules built and the build time. -# +# # To keep track of which modules are needed for your specific system/hardware, # give modprobed-db a try: https://aur.archlinux.org/packages/modprobed-db -# +# # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db # Set to anything but null to activate. : "${_localmodcfg:=""}" @@ -119,7 +119,7 @@ # This value is only used by the GENERIC_CPU # subarchitecture and is required. # Can be either '1', '2', '3' or '4' -# +# # Set to '1' by default # # For more information see: @@ -130,7 +130,7 @@ # Enable compilation with LLVM # Be warned, this is largely untested by me (JeremyStarTM). It *should* work, # but if it doesn't, write a comment and I'll fix it. -# +# # Set to anything but null to activate. : "${_use_llvm_lto:=""}" @@ -139,7 +139,7 @@ # Set to 'y' to force enable, 'n' to force disable or '' to ignore debug options. # Leaving the setting empty will use the kernel configuration setting to determine # if debug options shall be enabled/disabled. -# +# # Set to anything but null to activate. : "${_debug:=""}" @@ -186,11 +186,11 @@ export "KBUILD_BUILD_TIMESTAMP=$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EP apply_patches() { # Patch with kernel version patches patch -Np1 -i ../patch-${_kernel_major}.${_kernel_minor} || true - + # Set version echo "-${pkgrel}" > localversion.10-pkgrel echo "${pkgbase#linux}" > localversion.20-pkgname - + # Patch with Clear Linux patches for i in $(grep '^Patch' "${srcdir}"/cl-linux/linux.spec|grep -Ev '^Patch0132|^Patch0109|^Patch0118|^Patch0113|^Patch0138|^Patch0139|^Patch0147' | sed -n 's/.*: //p'); do if [ -n "${_use_llvm_lto}" ]; then @@ -198,9 +198,14 @@ apply_patches() { continue fi fi - + patch -Np1 -i "${srcdir}/cl-linux/${i}" || true done + + # Patch with kernel_compiler_patch patches. + # Do this before any defconfig invocations so we + # have all of the extra selectable uarches ready and selectable + patch -Np1 -i "$srcdir/kernel_compiler_patch-$_kernelcompilerpatch/more-ISA-levels-and-uarches-for-kernel-6.1.79+.patch" } # Allows user to modify the kernel config @@ -240,7 +245,7 @@ update_defconfig() { echo ":: Using configuration file \"${srcdir}/${pkgbase}/config\"" cp -Tf $srcdir/cl-linux/config ./.config fi - + # Extra configuration # General setup scripts/config --set-str DEFAULT_HOSTNAME archlinux \ @@ -292,7 +297,7 @@ update_defconfig() { scripts/config -e SECURITY_LANDLOCK # Library routines scripts/config -k -e FONT_TER16x32 - + # Enable LLVM compilation [[ -n "${_use_llvm_lto}" ]] && scripts/config -d LTO_NONE \ -e LTO \ @@ -302,7 +307,7 @@ update_defconfig() { -e HAS_LTO_CLANG \ -e LTO_CLANG_THIN \ -e HAVE_GCC_PLUGINS - + # Enable or disable debug settings [[ "${_debug}" == "y" ]] && scripts/config -e DEBUG_INFO \ -e DEBUG_INFO_BTF \ @@ -314,16 +319,18 @@ update_defconfig() { -d DEBUG_INFO_DWARF4 \ -d PAHOLE_HAS_SPLIT_BTF \ -d DEBUG_INFO_BTF_MODULES - + # Run olddefconfig make ${BUILD_FLAGS[*]} olddefconfig diff -u $srcdir/cl-linux/config .config || : - # Patch with kernel_compiler_patch patches - # This must be executed after olddefconfig - # to allow for the next section to run. - patch -Np1 -i "$srcdir/kernel_compiler_patch-$_kernelcompilerpatch/more-ISA-levels-and-uarches-for-kernel-6.1.79+.patch" - + # Here we slightly break the config by removing one of the + # members of the 'Processor family' selection. + # This causes oldconfig to invoke that selection always. + sed -i '/CONFIG_GENERIC_CPU/d' .config || : + # For a slim chance that someone is building X86_32 + sed -i '/CONFIG_M686/d' .config || : + # Set subarch automatically if [ -n "${_subarch}" ]; then if [ "${_subarch}" == "41" ]; then @@ -381,22 +388,22 @@ _package() { "linux-firmware: firmware images needed for some devices") provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE) install=linux.install - + cd "${_src_linux}" || exit 1 local "modulesdir=${pkgdir}/usr/lib/modules/$( Date: Sat, 4 Jan 2025 20:16:32 +0200 Subject: [PATCH 3/4] PKGBUILD: allow passing the subarch value as the Kconfig name It'll be easier to maintain for the users instead of using fixed numbers. The doc was also updated. --- PKGBUILD | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index ebfe237..fbeb080 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -66,9 +66,10 @@ # Set to anything but null to activate. : "${_localmodcfg:=""}" -# Optionally select a sub architecture by number or -# leave blank, which will require user interaction during the build. -# Note that the default option is 41. +# Optionally select a sub architecture by number or its Kconfig name, +# for example MCORE2 or MZEN4. +# Leaving it blank will require user interaction during the build. +# Note that the default option is empty. # # 1. AMD Opteron/Athlon64/Hammer/K8 (MK8) # 2. AMD Opteron/Athlon64/Hammer/K8 with SSE3 (MK8SSE3) @@ -326,18 +327,27 @@ update_defconfig() { # Here we slightly break the config by removing one of the # members of the 'Processor family' selection. - # This causes oldconfig to invoke that selection always. + # This causes oldconfig to always invoke that selection. sed -i '/CONFIG_GENERIC_CPU/d' .config || : # For a slim chance that someone is building X86_32 sed -i '/CONFIG_M686/d' .config || : - # Set subarch automatically if [ -n "${_subarch}" ]; then - if [ "${_subarch}" == "41" ]; then - yes "${_subarch} + # check if subarch is a number + if [[ ${_subarch} =~ ^[0-9]+$ ]] && ((_subarch>=1)); then + if [ "${_subarch}" == "41" ]; then + yes "${_subarch} ${_subarch_microarch}" | make ${BUILD_FLAGS[*]} oldconfig + else + yes "${_subarch}" | make ${BUILD_FLAGS[*]} oldconfig + fi + # check that this option is present in the .config + elif [[ $(grep -c "${_subarch}" .config) -eq 1 ]]; then + scripts/config -e "${_subarch}" + make ${BUILD_FLAGS[*]} olddefconfig else - yes "${_subarch}" | make ${BUILD_FLAGS[*]} oldconfig + warning "Unrecognized subarch value: ${_subarch}" + exit 1 fi else # Ask for subarch From 3dd576accac86a02c155c443455781e9402b56b1 Mon Sep 17 00:00:00 2001 From: Yaraslau Furman Date: Sat, 4 Jan 2025 20:19:21 +0200 Subject: [PATCH 4/4] PKGBUILD: fix and simplify major kernel version check after Jeremy's attempted fix Ree the double quote is meant to go after the equation sign! --- PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index fbeb080..4fad658 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -221,7 +221,7 @@ modify_defconfig() { # Copies the kernel config copy_defconfig() { - local "_cur_major_ver=$(zcat /proc/config.gz | grep Linux | grep -o '[0-9]*[0-9]\.[0-9]*[0-9]')" + local _cur_major_ver="$(uname -r | grep -o '[0-9]*[0-9]\.[0-9]*[0-9]')" [[ "${_cur_major_ver}" != "${_kernel_major}" ]] && warning "Major version was updated, you should regen the defconfig"