From a2c6f8927eb8da129804163bd7fb92a355eada15 Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Jun 18 2025 13:48:55 +0000 Subject: packaging: Add support for suse-kabi-tools The current workflow to check kABI stability during the RPM build of SUSE kernels consists of the following steps: * The downstream script rpm/modversions unpacks the consolidated kABI symtypes reference data from kabi//symtypes- and creates individual symref files. * The build performs a regular kernel make. During this operation, genksyms is invoked for each source file. The tool determines type signatures of all exports within the file, reports any differences compared to the associated symref reference, calculates symbol CRCs from the signatures and writes new type data into a symtypes file. * The script rpm/modversions is invoked again, this time it packs all new symtypes files to a consolidated kABI file. * The downstream script rpm/kabi.pl checks symbol CRCs in the new build and compares them to a reference from kabi//symvers-, taking kabi/severities into account. suse-kabi-tools is a new set of tools to improve the kABI checking process. The suite includes two tools, ksymtypes and ksymvers, which replace the existing scripts rpm/modversions and rpm/kabi.pl, as well as the comparison functionality previously provided by genksyms. The tools have their own source repository and package. The tools provide faster operation and more detailed, unified output. In addition, they allow the use of the new upstream tool gendwarfksyms, which lacks any built-in comparison functionality. The updated workflow is as follows: * The build performs a regular kernel make. During this operation, genksyms (gendwarfksyms) is invoked as usual, determinining signatures and CRCs of all exports and writing the type data to symtypes files. However, genksyms no longer performs any comparison. * 'ksymtypes consolidate' packs all new symtypes files to a consolidated kABI file. * 'ksymvers compare' checks symbol CRCs in the new build and compares them to a reference from kabi//symvers-, taking kabi/severities into account. The tool writes its result in a human-readable form on standard output and also writes a list of all changed exports (not ignored by kabi/severities) to the changed-exports file. * 'ksymtypes compare' takes the changed-exports file, the consolidated kABI symtypes reference data from kabi//symtypes- and the new consolidated data. Based on this data, it produces a detailed report explaining why the symbols changed. The patch enables the use of suse-kabi-tools via rpm/config.sh, providing explicit control to each branch. To enable the support, set USE_SUSE_KABI_TOOLS=Yes in the config file. --- diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 7b53ae4..059a98d 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -31,6 +31,7 @@ %define supported_modules_check @SUPPORTED_MODULES_CHECK@ %define build_flavor @FLAVOR@ %define generate_compile_commands @GENERATE_COMPILE_COMMANDS@ +%define use_suse_kabi_tools @USE_SUSE_KABI_TOOLS@ %define gcc_package @GCC_PACKAGE@ %define gcc_compiler @GCC_COMPILER@ @@ -83,6 +84,9 @@ BuildRequires: elfutils %ifarch %arm BuildRequires: u-boot-tools %endif +%if %use_suse_kabi_tools +BuildRequires: suse-kabi-tools +%endif # Do not install p-b and dracut for the install check, the %post script is # able to handle this #!BuildIgnore: perl-Bootloader dracut distribution-release suse-kernel-rpm-scriptlets @@ -968,10 +972,12 @@ find . ! -type d ! -name 'Module.base' ! -name 'Module.*-kmp' ! -name 'Module.op cd %kernel_build_dir source .kernel-binary.spec.buildenv -# create *.symref files in the tree -if test -e %my_builddir/kabi/%cpu_arch/symtypes-%build_flavor; then - %_sourcedir/modversions --unpack . < $_ -fi +%if !%use_suse_kabi_tools + # create *.symref files in the tree + if test -e %my_builddir/kabi/%cpu_arch/symtypes-%build_flavor; then + %_sourcedir/modversions --unpack . < $_ + fi +%endif %if "%CONFIG_KMSG_IDS" == "y" chmod +x ../scripts/kmsg-doc @@ -1205,11 +1211,15 @@ if [ %CONFIG_MODULES = y ]; then %endif # Table of types used in exported symbols (for modversion debugging). - %_sourcedir/modversions --pack . > %buildroot/boot/symtypes-%kernelrelease-%build_flavor - if [ -s %buildroot/boot/symtypes-%kernelrelease-%build_flavor ]; then - gzip -n -9 %buildroot/boot/symtypes-%kernelrelease-%build_flavor - else - rm -f %buildroot/boot/symtypes-%kernelrelease-%build_flavor + %if %use_suse_kabi_tools + ksymtypes consolidate %{?_smp_mflags} \ + --output=%my_builddir/symtypes-%build_flavor . + %else + %_sourcedir/modversions --pack . > %my_builddir/symtypes-%build_flavor + %endif + if [ -s %my_builddir/symtypes-%build_flavor ]; then + gzip -n -9 -c %my_builddir/symtypes-%build_flavor \ + > %buildroot/boot/symtypes-%kernelrelease-%build_flavor.gz fi # Some architecture's $(uname -m) output is different from the ARCH @@ -1260,11 +1270,25 @@ if [ %CONFIG_MODULES = y ]; then res=0 if test -e %my_builddir/kabi/%cpu_arch/symvers-%build_flavor; then # check for kabi changes - %_sourcedir/kabi.pl --rules %my_builddir/kabi/severities \ - %my_builddir/kabi/%cpu_arch/symvers-%build_flavor \ - Module.symvers || res=$? + %if %use_suse_kabi_tools + ksymvers compare --rules=%my_builddir/kabi/severities \ + --format=symbols:%my_builddir/changed-exports \ + %my_builddir/kabi/%cpu_arch/symvers-%build_flavor \ + Module.symvers || res=$? + %else + %_sourcedir/kabi.pl --rules %my_builddir/kabi/severities \ + %my_builddir/kabi/%cpu_arch/symvers-%build_flavor \ + Module.symvers || res=$? + %endif fi if [ $res -ne 0 ]; then + %if %use_suse_kabi_tools + ksymtypes compare %{?_smp_mflags} \ + --filter-symbol-list=%my_builddir/changed-exports \ + %my_builddir/kabi/%cpu_arch/symtypes-%build_flavor \ + %my_builddir/symtypes-%build_flavor + %endif + # %ignore_kabi_badness is defined in the Kernel:* projects in the # OBS to be able to build the KOTD in spite of kabi errors if [ 0%{?ignore_kabi_badness} -eq 0 -a \ diff --git a/rpm/mkspec b/rpm/mkspec index 19b9d44..0077107 100755 --- a/rpm/mkspec +++ b/rpm/mkspec @@ -72,6 +72,7 @@ my $supported_modules_check = to_bool $vars{'SUPPORTED_MODULES_CHECK'}; my $build_pdf = to_bool $vars{'BUILD_PDF'}; my $build_html = to_bool $vars{'BUILD_HTML'}; my $generate_compile_commands = to_bool $vars{'GENERATE_COMPILE_COMMANDS'}; +my $use_suse_kabi_tools = to_bool $vars{'USE_SUSE_KABI_TOOLS'}; if (!defined ($rpmrelease)) { $rpmrelease = $vars{'RELEASE'} || 0; @@ -149,6 +150,7 @@ my %macros = ( COMPRESS_MODULES => $compress_modules, COMPRESS_VMLINUX => $compress_vmlinux, GENERATE_COMPILE_COMMANDS => $generate_compile_commands, + USE_SUSE_KABI_TOOLS => $use_suse_kabi_tools, GCC_PACKAGE => $gcc_package, GCC_COMPILER => $gcc_compiler, );