ClangBuiltLinux/linux

Update Fedora kernel config in CI

Closed this issue · 6 comments

Here is an updated Fedora kernel config to use in CI. This comes directly from the built RPMs, so it should be exactly what is used to build the Fedora kernel with clang.

CC @nathanchance

Thanks for that. It won't stay up to date with the changes in rpms/kernel though, right? I worry that we would be missing out on coverage (or run into build issues) if these configurations don't stay up to date. I am trying to read kernel.spec to understand how that .config is ultimately generated to see if it would be feasible for us to dynamically generate them and pass them on to TuxSuite in our CI directly.

It won't stay up-to-date, that's correct. There should be a way to dynamically generate it using rpmbuild, I will try to come up with a script for this.

Below is a docker file that will generate the latest configs and put then in /root/configs/.

FROM registry.fedoraproject.org/fedora:rawhide

RUN mkdir /root/configs/

# Explicitly install clang and lld, because I'm not sure these will
# get intalled by builddeps since they are guarded by conditionals
# in the spec file.
RUN dnf install -y koji rpm-build dnf-plugins-core clang lld

RUN source /etc/os-release && \
    koji download-build --latestfrom=f$VERSION_ID --arch=src kernel

RUN dnf builddep -y *.src.rpm

RUN rpmbuild --with toolchain_clang --with clang_lto -rp *.src.rpm

RUN for f in `find /root/rpmbuild/BUILD -iname 'kernel-*.config'`; do \
        cp $f /root/configs/; \
    done

Here is the full list of configs it generates:

kernel-6.9.0-aarch64-16k-debug.config
kernel-6.9.0-aarch64-16k.config
kernel-6.9.0-aarch64-debug.config
kernel-6.9.0-aarch64.config
kernel-6.9.0-ppc64le-debug.config
kernel-6.9.0-ppc64le.config
kernel-6.9.0-s390x-debug.config
kernel-6.9.0-s390x.config
kernel-6.9.0-x86_64-debug.config
kernel-6.9.0-x86_64.config

I ran that Dockerfile to generate the official configurations then I pulled the kernel-<arch>-fedora.config files from rpms/kernel directly and ran them through olddefconfig, which mimics what we do in CI, and aside from LTO for aarch64 and x86_64, there do not appear to be any real meaningful differences:

aarch64 diff
diff --git a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-aarch64.config b/mnt/nvme/tmp/build/linux/aarch64/.config
index 5e51be5e9b00..6db722d6229e 100644
--- a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-aarch64.config
+++ b/mnt/nvme/tmp/build/linux/aarch64/.config
@@ -1,9 +1,8 @@
-# arm64
 #
 # Automatically generated file; DO NOT EDIT.
 # Linux/arm64 6.9.0-rc1 Kernel Configuration
 #
-CONFIG_CC_VERSION_TEXT="clang version 18.1.2 (Fedora 18.1.2-1.fc41)"
+CONFIG_CC_VERSION_TEXT="ClangBuiltLinux clang version 18.1.2 (https://github.com/llvm/llvm-project.git 26a1d6601d727a96f4301d0d8647b5a42760ae0c)"
 CONFIG_GCC_VERSION=0
 CONFIG_CC_IS_CLANG=y
 CONFIG_CLANG_VERSION=180102
@@ -14,6 +13,7 @@ CONFIG_LD_IS_LLD=y
 CONFIG_LLD_VERSION=180102
 CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
 CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
+CONFIG_TOOLS_SUPPORT_RELR=y
 CONFIG_CC_HAS_ASM_INLINE=y
 CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
 CONFIG_PAHOLE_VERSION=126
@@ -832,14 +832,12 @@ CONFIG_STACKPROTECTOR=y
 CONFIG_STACKPROTECTOR_STRONG=y
 CONFIG_ARCH_SUPPORTS_SHADOW_CALL_STACK=y
 # CONFIG_SHADOW_CALL_STACK is not set
-CONFIG_LTO=y
-CONFIG_LTO_CLANG=y
 CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
 CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
 CONFIG_HAS_LTO_CLANG=y
-# CONFIG_LTO_NONE is not set
+CONFIG_LTO_NONE=y
 # CONFIG_LTO_CLANG_FULL is not set
-CONFIG_LTO_CLANG_THIN=y
+# CONFIG_LTO_CLANG_THIN is not set
 CONFIG_ARCH_SUPPORTS_CFI_CLANG=y
 # CONFIG_CFI_CLANG is not set
 CONFIG_HAVE_CONTEXT_TRACKING_USER=y
@@ -885,6 +883,7 @@ CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y
 CONFIG_ARCH_USE_MEMREMAP_PROT=y
 # CONFIG_LOCK_EVENT_COUNTS is not set
 CONFIG_ARCH_HAS_RELR=y
+# CONFIG_RELR is not set
 CONFIG_HAVE_PREEMPT_DYNAMIC=y
 CONFIG_HAVE_PREEMPT_DYNAMIC_KEY=y
 CONFIG_ARCH_WANT_LD_ORPHAN_WARN=y
@@ -11643,7 +11642,6 @@ CONFIG_SECURITY_YAMA=y
 # CONFIG_SECURITY_SAFESETID is not set
 CONFIG_SECURITY_LOCKDOWN_LSM=y
 CONFIG_SECURITY_LOCKDOWN_LSM_EARLY=y
-# CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT is not set
 CONFIG_LOCK_DOWN_KERNEL_FORCE_NONE=y
 # CONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITY is not set
 # CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY is not set
@@ -12288,6 +12286,7 @@ CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 # CONFIG_DEBUG_INFO_REDUCED is not set
 CONFIG_DEBUG_INFO_COMPRESSED_NONE=y
 # CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set
+# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set
 # CONFIG_DEBUG_INFO_SPLIT is not set
 CONFIG_DEBUG_INFO_BTF=y
 CONFIG_PAHOLE_HAS_SPLIT_BTF=y
@@ -12679,9 +12678,3 @@ CONFIG_MEMTEST=y
 #
 # end of Rust hacking
 # end of Kernel hacking
-
-#
-# Red Hat options
-#
-# CONFIG_RHEL_DIFFERENCES is not set
-# end of Red Hat options
ppc64le diff
diff --git a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-ppc64le.config b/mnt/nvme/tmp/build/linux/ppc64le/.config
index f6132d518acf..1919f639c019 100644
--- a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-ppc64le.config
+++ b/mnt/nvme/tmp/build/linux/ppc64le/.config
@@ -1,9 +1,8 @@
-# powerpc
 #
 # Automatically generated file; DO NOT EDIT.
 # Linux/powerpc 6.9.0-rc1 Kernel Configuration
 #
-CONFIG_CC_VERSION_TEXT="clang version 18.1.2 (Fedora 18.1.2-1.fc41)"
+CONFIG_CC_VERSION_TEXT="ClangBuiltLinux clang version 18.1.2 (https://github.com/llvm/llvm-project.git 26a1d6601d727a96f4301d0d8647b5a42760ae0c)"
 CONFIG_GCC_VERSION=0
 CONFIG_CC_IS_CLANG=y
 CONFIG_CLANG_VERSION=180102
@@ -14,6 +13,7 @@ CONFIG_LD_IS_LLD=y
 CONFIG_LLD_VERSION=180102
 CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
 CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
+CONFIG_TOOLS_SUPPORT_RELR=y
 CONFIG_CC_HAS_ASM_INLINE=y
 CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
 CONFIG_PAHOLE_VERSION=126
@@ -8952,6 +8952,7 @@ CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 # CONFIG_DEBUG_INFO_REDUCED is not set
 CONFIG_DEBUG_INFO_COMPRESSED_NONE=y
 # CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set
+# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set
 # CONFIG_DEBUG_INFO_SPLIT is not set
 CONFIG_DEBUG_INFO_BTF=y
 CONFIG_PAHOLE_HAS_SPLIT_BTF=y
@@ -9324,9 +9325,3 @@ CONFIG_MEMTEST=y
 #
 # end of Rust hacking
 # end of Kernel hacking
-
-#
-# Red Hat options
-#
-# CONFIG_RHEL_DIFFERENCES is not set
-# end of Red Hat options
s390x diff
diff --git a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-s390x.config b/mnt/nvme/tmp/build/linux/s390x/.config
index 8f6b64534d99..94f74fb2efdb 100644
--- a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-s390x.config
+++ b/mnt/nvme/tmp/build/linux/s390x/.config
@@ -1,9 +1,8 @@
-# s390
 #
 # Automatically generated file; DO NOT EDIT.
 # Linux/s390 6.9.0-rc1 Kernel Configuration
 #
-CONFIG_CC_VERSION_TEXT="clang version 18.1.2 (Fedora 18.1.2-1.fc41)"
+CONFIG_CC_VERSION_TEXT="ClangBuiltLinux clang version 18.1.2 (https://github.com/llvm/llvm-project.git 26a1d6601d727a96f4301d0d8647b5a42760ae0c)"
 CONFIG_GCC_VERSION=0
 CONFIG_CC_IS_CLANG=y
 CONFIG_CLANG_VERSION=180102
@@ -14,6 +13,7 @@ CONFIG_LD_IS_LLD=y
 CONFIG_LLD_VERSION=180102
 CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
 CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
+CONFIG_TOOLS_SUPPORT_RELR=y
 CONFIG_CC_HAS_ASM_INLINE=y
 CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
 CONFIG_PAHOLE_VERSION=126
@@ -4721,6 +4721,7 @@ CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 # CONFIG_DEBUG_INFO_REDUCED is not set
 CONFIG_DEBUG_INFO_COMPRESSED_NONE=y
 # CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set
+# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set
 # CONFIG_DEBUG_INFO_SPLIT is not set
 CONFIG_DEBUG_INFO_BTF=y
 CONFIG_PAHOLE_HAS_SPLIT_BTF=y
@@ -5072,9 +5073,3 @@ CONFIG_SIPHASH_KUNIT_TEST=m
 #
 # end of Rust hacking
 # end of Kernel hacking
-
-#
-# Red Hat options
-#
-# CONFIG_RHEL_DIFFERENCES is not set
-# end of Red Hat options
x86_64 diff
diff --git a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-x86_64.config b/mnt/nvme/tmp/build/linux/x86_64/.config
index 33331bba7df2..b1ce7749aea5 100644
--- a/mnt/nvme/vm/x86_64/arch/shared/configs/kernel-6.9.0-x86_64.config
+++ b/mnt/nvme/tmp/build/linux/x86_64/.config
@@ -1,9 +1,8 @@
-# x86_64
 #
 # Automatically generated file; DO NOT EDIT.
 # Linux/x86_64 6.9.0-rc1 Kernel Configuration
 #
-CONFIG_CC_VERSION_TEXT="clang version 18.1.2 (Fedora 18.1.2-1.fc41)"
+CONFIG_CC_VERSION_TEXT="ClangBuiltLinux clang version 18.1.2 (https://github.com/llvm/llvm-project.git 26a1d6601d727a96f4301d0d8647b5a42760ae0c)"
 CONFIG_GCC_VERSION=0
 CONFIG_CC_IS_CLANG=y
 CONFIG_CLANG_VERSION=180102
@@ -16,6 +15,7 @@ CONFIG_CC_CAN_LINK=y
 CONFIG_CC_CAN_LINK_STATIC=y
 CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
 CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
+CONFIG_TOOLS_SUPPORT_RELR=y
 CONFIG_CC_HAS_ASM_INLINE=y
 CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
 CONFIG_PAHOLE_VERSION=126
@@ -873,14 +873,12 @@ CONFIG_HAVE_ARCH_STACKLEAK=y
 CONFIG_HAVE_STACKPROTECTOR=y
 CONFIG_STACKPROTECTOR=y
 CONFIG_STACKPROTECTOR_STRONG=y
-CONFIG_LTO=y
-CONFIG_LTO_CLANG=y
 CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
 CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
 CONFIG_HAS_LTO_CLANG=y
-# CONFIG_LTO_NONE is not set
+CONFIG_LTO_NONE=y
 # CONFIG_LTO_CLANG_FULL is not set
-CONFIG_LTO_CLANG_THIN=y
+# CONFIG_LTO_CLANG_THIN is not set
 CONFIG_ARCH_SUPPORTS_CFI_CLANG=y
 # CONFIG_CFI_CLANG is not set
 CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES=y
@@ -10312,7 +10310,6 @@ CONFIG_SECURITY_YAMA=y
 # CONFIG_SECURITY_SAFESETID is not set
 CONFIG_SECURITY_LOCKDOWN_LSM=y
 CONFIG_SECURITY_LOCKDOWN_LSM_EARLY=y
-CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT=y
 CONFIG_LOCK_DOWN_KERNEL_FORCE_NONE=y
 # CONFIG_LOCK_DOWN_KERNEL_FORCE_INTEGRITY is not set
 # CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY is not set
@@ -10894,6 +10891,7 @@ CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
 # CONFIG_DEBUG_INFO_REDUCED is not set
 CONFIG_DEBUG_INFO_COMPRESSED_NONE=y
 # CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set
+# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set
 # CONFIG_DEBUG_INFO_SPLIT is not set
 CONFIG_DEBUG_INFO_BTF=y
 CONFIG_PAHOLE_HAS_SPLIT_BTF=y
@@ -11308,9 +11306,3 @@ CONFIG_MEMTEST=y
 #
 # end of Rust hacking
 # end of Kernel hacking
-
-#
-# Red Hat options
-#
-# CONFIG_RHEL_DIFFERENCES is not set
-# end of Red Hat options

I think we could just do something like this in CI then enable these builds where the existing Fedora ones are:

diff --git a/generator/yml/0007-configs.yml b/generator/yml/0007-configs.yml
index 9611b18..fd5b89c 100644
--- a/generator/yml/0007-configs.yml
+++ b/generator/yml/0007-configs.yml
@@ -39,6 +39,7 @@ configs:
   - &arm64_allyes      {config: allyesconfig,                                                                                               ARCH: *arm64-arch,      << : *default}
   - &arm64_alpine      {config: *arm64-alpine-config-url,                                                                                   ARCH: *arm64-arch,      << : *kernel}
   - &arm64_fedora      {config: *arm64-fedora-config-url,                                                                                   ARCH: *arm64-arch,      << : *kernel}
+  - &arm64_fedora_lto  {config: [*arm64-fedora-config-url, CONFIG_LTO_CLANG_THIN=y],                                                        ARCH: *arm64-arch,      << : *kernel}
   # CONFIG_BPF_PRELOAD disabled for pre-5.18 cross compiled Fedora configs: https://github.com/ClangBuiltLinux/linux/issues/1433
   - &arm64_fedora_bpf  {config: [*arm64-fedora-config-url, CONFIG_BPF_PRELOAD=n],                                                           ARCH: *arm64-arch,      << : *kernel}
   # CONFIG_DEBUG_INFO_BTF disabled for certain SUSE configs due to pahole issue: https://lore.kernel.org/r/20210506205622.3663956-1-kafai@fb.com/
@@ -103,4 +104,5 @@ configs:
   - &x86_64_alpine     {config: *x86_64-alpine-config-url,                                                                                                          << : *kernel}
   - &x86_64_arch       {config: *x86_64-arch-config-url,                                                                                                            << : *kernel}
   - &x86_64_fedora     {config: *x86_64-fedora-config-url,                                                                                                          << : *kernel}
+  - &x86_64_fedora_lto {config: [*x86_64-fedora-config-url, CONFIG_LTO_CLANG_THIN=y],                                                                               << : *kernel}
   - &x86_64_suse       {config: *x86_64-suse-config-url,                                                                                                            << : *kernel}

I think having side by side builds of LTO with no LTO helps catch issues related to LTO sooner.

+CONFIG_TOOLS_SUPPORT_RELR=y

Why is that different? Is something wrong with the kconfig check for RELR relocation format support?

+CONFIG_TOOLS_SUPPORT_RELR=y

Why is that different? Is something wrong with the kconfig check for RELR relocation format support?

No, I think the Kconfig check is fine. Fedora currently specifies the individual make variables for the build tools instead of just using LLVM=1, so they miss out on OBJCOPY=llvm-objcopy, which scripts/tools-support-relr.sh requires. I think Tom had mentioned they were looking into switching over to LLVM=1 now that s390 supports it but it seems like that has just not been done yet.