Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
No option to build gentoo-sources with LTO
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
causality
Apprentice
Apprentice


Joined: 03 Jun 2006
Posts: 246

PostPosted: Sat Feb 22, 2025 11:43 pm    Post subject: No option to build gentoo-sources with LTO Reply with quote

This is concerning gentoo-sources-6.13.4 version. I have enabled the "experimental" USE flag.

I notice that when I run "make menuconfig", there is an entry under "General architecture-dependent options" that is called "Link Time Optimization (LTO)". I can select this to bring up a sub-menu, but the only available option is "None" or "CONFIG_LTO_NONE". I have GCC version 14.2.1_p20241221 and Clang 19.1.7, both of which support LTO and often build packages with it enabled.

Please correct me if I have this wrong, but my understanding is that building the kernel with Clang+LTO has been supported for some time now and GCC+LTO is more recently supported. So, why can't I select these options through standard configuration? Usually, the menuconfig "<HELP>" option will tell you what selects or de-selects a given option, but that information is notably absent.

I keep a few previous kernels around and configured in my bootloader, so there is very little risk for me if an LTO kernel doesn't boot or wants to crash.

Further, I perused https://wiki.gentoo.org/wiki/Kernel/Optimization#Link_Time_Optimization but it appears to be dated. Specifically, that site mentions kernel version 6.6 and I could find nothing more recent on that site. I also tried https://github.com/CachyOS/kernel-patches/ but none of the patches there under 6.13 indicate LTO.

I would rather not use a patch if that's not needed. I would much prefer to figure out why a nice, standard configuration option is unavailable than force the issue by manually trying to add KCFLAGS and such. From what I hear, apparently some other users get to select LTO and then select whether that'll be Clang or GCC. I'm unclear on how they are doing that and recent information on this topic is quite difficult to find (most of it is about 5.12 series kernels), but I would like to try that.

Standard output of "emerge --info":

Code:
# emerge --info
Portage 3.0.66.1 (python 3.12.9-final-0, default/linux/amd64/23.0/desktop/plasma, gcc-14, glibc-2.40-r8, 6.13.2-gentoo x86_64)
=================================================================
System uname: Linux-6.13.2-gentoo-x86_64-Intel-R-_Core-TM-_i5-6500_CPU_@_3.20GHz-with-glibc2.40
KiB Mem:    16354720 total,   9466340 free
KiB Swap:    5392376 total,   4936528 free
Timestamp of repository gentoo: Sat, 22 Feb 2025 13:45:00 +0000
Head commit of repository gentoo: 75d82143fa29cb7a37550333c548292bda6b4687
Timestamp of repository myrvolay: Sun, 16 Feb 2025 18:52:21 +0000
Head commit of repository myrvolay: 527d600806d23f9ac64966559376fa828c3e4b0d

sh bash 5.2_p37
ld GNU ld (Gentoo 2.43 p3) 2.43.1
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.31.5::gentoo
dev-build/libtool:         2.5.4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.6.1::gentoo
dev-lang/perl:             5.40.0-r1::gentoo
dev-lang/python:           3.12.9::gentoo, 3.13.1_p1::gentoo
dev-lang/rust-bin:         1.81.0-r100::gentoo, 1.82.0-r101::gentoo, 1.83.0-r1::gentoo, 1.84.1-r2::gentoo
llvm-core/clang:           18.1.8-r6::gentoo, 19.1.7::gentoo
llvm-core/lld:             18.1.8::gentoo, 19.1.7::gentoo
llvm-core/llvm:            18.1.8-r6::gentoo, 19.1.7::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.55.1::gentoo
sys-apps/sandbox:          2.39::gentoo
sys-devel/binutils:        2.42-r2::gentoo, 2.43-r2::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/gcc:             14.2.1_p20241221::gentoo
sys-devel/gcc-config:      2.12.1::gentoo
sys-kernel/linux-headers:  6.6-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.40-r8::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.us.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts:
    sync-rsync-verify-metamanifest: yes

myrvolay
    location: /var/db/repos/myrvolay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/myrvolay.git
    masters: gentoo
    volatile: False

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="*"
AR="gcc-ar"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -fomit-frame-pointer -fsched-pressure -ftree-loop-distribution -fweb -frename-registers -floop-interchange -ftree-vectorize -fivopts -pipe -flto=auto -fuse-linker-plugin -floop-nest-optimize -fgraphite-identity"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d"
CXXFLAGS="-O2 -march=native -fomit-frame-pointer -fsched-pressure -ftree-loop-distribution -fweb -frename-registers -floop-interchange -ftree-vectorize -fivopts -pipe -flto=auto -fuse-linker-plugin -floop-nest-optimize -fgraphite-identity"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live candy config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.mirror.root.lu/"
LANG="C.UTF8"
LDFLAGS="-Wl,-O2 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--sort-common -Wl,-z,combreloc -Wl,-z,relro -Wl,-z,now -Wl,--strip-debug -O2 -march=native -fomit-frame-pointer -fsched-pressure -ftree-loop-distribution -fweb -frename-registers -floop-interchange -ftree-vectorize -fivopts -pipe -flto=auto -fuse-linker-plugin -floop-nest-optimize -fgraphite-identity -fuse-ld=mold"
LEX="flex"
MAKEOPTS="-j3"
NM="gcc-nm"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RANLIB="gcc-ranlib"
SHELL="/bin/bash"
USE="3dnow 3dnowext X \ a52 aac aalib acl acpi activities alsa amd64 bash-completion branding bzip2 cairo cdda cdr cet crypt cups dbus declarative dri dts dvd dvdr elogind encode exif ffmpeg flac gdbm gif gpm gtk gui iconv icu ipv6 jpeg jpeg2k kde kf6compat kwallet lcms libnotify libtirpc lzma mad mng mp3 mp4 mpeg mplayer multilib mysql ncurses networkmanager nvenc offensive ogg opengl openmp openssl pam pango pcre pdf plasma png policykit ppds python qml qt5 qt6 readline sdl seccomp socks5 sound spell ssl startup-notification svg symlink test-rust tiff truetype udev udisks unicode upower usb verify-sig videos vorbis vulkan wayland widgets wmf wxwidgets x264 xattr xcb xcomposite xft xine xml xscreensaver xv xvid zlib" ABI_X86="64 32" ADA_TARGET="gcc_14" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GRUB_PLATFORMS="pc" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" L10N="en en-US" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="nvidia nv vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23280

PostPosted: Sun Feb 23, 2025 12:27 am    Post subject: Reply with quote

As I read arch/Kconfig, this prompt has 3 options: None (always available), LTO_CLANG_FULL (depends on HAS_LTO_CLANG), and LTO_CLANG_THIN (depends on HAS_LTO_CLANG and ARCH_SUPPORTS_LTO_CLANG_THIN). I then looked above and found the implementation of HAS_LTO_CLANG:
Code:
config HAS_LTO_CLANG
   def_bool y
   depends on CC_IS_CLANG && LD_IS_LLD && AS_IS_LLVM
   depends on $(success,$(NM) --help | head -n 1 | grep -qi llvm)
   depends on $(success,$(AR) --help | head -n 1 | grep -qi llvm)
   depends on ARCH_SUPPORTS_LTO_CLANG
   depends on !FTRACE_MCOUNT_USE_RECORDMCOUNT
   depends on !KASAN || KASAN_HW_TAGS
   depends on !GCOV_KERNEL
Does your build environment satisfy all these dependency checks?
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2248

PostPosted: Sun Feb 23, 2025 2:26 am    Post subject: Reply with quote

kernel.org upstream still doesn't support GCC LTO because they don't want to adapt their asm (or add workarounds, depending on your perspective) to mark them up with attributes.

As for using LTO with Clang, you need to make sure you pass LLVM=1 on all make command lines (including for e.g. menuconfig).
Back to top
View user's profile Send private message
causality
Apprentice
Apprentice


Joined: 03 Jun 2006
Posts: 246

PostPosted: Sun Feb 23, 2025 5:55 pm    Post subject: Reply with quote

Yes, adding "LLVM=1" with each invocation of "make" opened up the appropriate Clang options including Full LTO and ThinLTO. Thank you, that's nice and simple.

The kernel built just fine. Then x11-drivers/nvidia-drivers automatically detected that the kernel was built with Clang and built itself with Clang as well (usually both would be GCC). nvidia-drivers built and installed fine, but I had a suspicion that LTO might be a little too aggressive at removing symbols that an out-of-tree module would need. Sure enough, that's what happened, with both full LTO and thin LTO. The kernel boots fine and functions, except that the nvidia driver fails to load. From kern.log:

Code:
Feb 23 11:24:17 causality kernel: nvidia: loading out-of-tree module taints kernel.
Feb 23 11:24:17 causality kernel: nvidia: module license 'NVIDIA' taints kernel.
Feb 23 11:24:17 causality kernel: Disabling lock debugging due to kernel taint
Feb 23 11:24:17 causality kernel: nvidia: module license taints kernel.
Feb 23 11:24:17 causality kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 244
Feb 23 11:24:17 causality kernel:
Feb 23 11:24:17 causality kernel: nvidia 0000:01:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+m
em
Feb 23 11:24:17 causality kernel: NVRM: loading NVIDIA UNIX x86_64 Kernel Module  550.144.03  Mon Dec 30 17:44:08 UTC 2024
Feb 23 11:24:17 causality kernel: nvidia_modeset: Unknown symbol backlight_device_register (err -2)
Feb 23 11:24:17 causality kernel: nvidia_modeset: Unknown symbol backlight_device_unregister (err -2)
Feb 23 11:24:17 causality kernel: nvidia_modeset: Unknown symbol __acpi_video_get_backlight_type (err -2)


So, no SDDM and no Xorg or Wayland. Good thing i'm comfortable on the console heh. I'm convinced it's that LTO was too aggressive with the kernel because booting a prior kernel that wasn't built with LTO, while changing nothing else (so, a GCC built kernel with no LTO + the Clang-built nvidia-drivers) works fine. In fact, building the kernel with ThinLTO gave these warnings at or around the final link:

Code:
depmod: WARNING: /lib/modules/6.13.4-gentoo/video/nvidia-modeset.ko needs unknown symbol backlight_device_register
depmod: WARNING: /lib/modules/6.13.4-gentoo/video/nvidia-modeset.ko needs unknown symbol backlight_device_unregister
depmod: WARNING: /lib/modules/6.13.4-gentoo/video/nvidia-modeset.ko needs unknown symbol __acpi_video_get_backlight_type
depmod: WARNING: /lib/modules/6.13.4-gentoo/video/nvidia-drm.ko needs unknown symbol drm_fbdev_ttm_driver_fbdev_probe


Is there a way to get this to work, or should I just abandon LTO kernels? Maybe I could enable a kernel setting or module someplace that would cause those symbols to remain in the final link? I'm very comfortable with the command line and system admin type tasks but I'm really not much of a programmer; so, while I have heard of these things, I'm out of my element, here.

Thank all of you for your time, really. The forums are part of what makes Gentoo great.

** EDIT **

It seems the missing symbols were unrelated to LTO. I inadvertently disabled Device Drivers -> Graphics support -> Backlight & LCD device support -> "Lowlevel LCD controls" (CONFIG_LCD_CLASS_DEVICE) and "Lowlevel Backlight controls" (CONFIG_BACKLIGHT_CLASS_DEVICE) as I associated these with laptops, netbooks, and other mobile devices, not a desktop system. Re-enabling those as well as CONFIG_ACPI_VIDEO got rid of all the missing symbol warnings (from depmod), even with ThinLTO re-enabled.

The "drm_fbdev_ttm_driver_fbdev_probe" symbol was because I forgot why I had enabled graphics DRM driver CONFIG_DRM_AMDGPU even though I have no AMD graphics hardware on this system. This was to pull in DRM-related helpers that nvidia-drivers needs to have in the kernel. The nvidia-drivers themselves will abort the build if they detect that this isn't present in the kernel config and explicitly suggest enabling something you won't use to enable this. Gah.

Anyway, the nvidia-drivers package built successfully and I'm hoping a reboot will bring me a fully functional system.
Back to top
View user's profile Send private message
causality
Apprentice
Apprentice


Joined: 03 Jun 2006
Posts: 246

PostPosted: Mon Feb 24, 2025 7:29 am    Post subject: Reply with quote

So, having resolved the issue with symbols, I reboot and the nvidia module loads, only to produce a kernel BUG followed by an OOPS:

Code:
Feb 23 17:13:07 causality kernel: nvidia: loading out-of-tree module taints kernel.
Feb 23 17:13:07 causality kernel: nvidia: module license 'NVIDIA' taints kernel.
Feb 23 17:13:07 causality kernel: Disabling lock debugging due to kernel taint
Feb 23 17:13:07 causality kernel: nvidia: module license taints kernel.
Feb 23 17:13:08 causality kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 245
Feb 23 17:13:08 causality kernel:
Feb 23 17:13:08 causality kernel: nvidia 0000:01:00.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+m
em
Feb 23 17:13:08 causality kernel: NVRM: loading NVIDIA UNIX x86_64 Kernel Module  550.144.03  Mon Dec 30 17:44:08 UTC 2024
Feb 23 17:13:08 causality kernel: BUG: unable to handle page fault for address: ffffffffc3b57ff7
Feb 23 17:13:08 causality kernel: #PF: supervisor read access in kernel mode
Feb 23 17:13:08 causality kernel: #PF: error_code(0x0000) - not-present page
Feb 23 17:13:08 causality kernel: PGD 2e560e067 P4D 2e560e067 PUD 2e5610067 PMD 11608f067 PTE 0
Feb 23 17:13:08 causality kernel: Oops: Oops: 0000 [#1] PREEMPT SMP PTI
Feb 23 17:13:08 causality kernel: CPU: 1 UID: 0 PID: 903 Comm: (udev-worker) Tainted: P           O       6.13.4-gentoo #8
Feb 23 17:13:08 causality kernel: Tainted: [P]=PROPRIETARY_MODULE, [O]=OOT_MODULE
Feb 23 17:13:08 causality kernel: Hardware name: MSI MS-7A12/Z170A GAMING PRO CARBON (MS-7A12), BIOS 1.30 05/12/2016
Feb 23 17:13:08 causality kernel: RIP: 0010:bcmp+0x10/0x70
Feb 23 17:13:08 causality kernel: Code: 02 00 cc cc cc cc cc cc cc cc 90 90 90 90 90 90 90 65 48 c1 3d 60 e8 36 72 05 48 83
fa 08 72 24 66 2e 0f 1f 84 00 00 00 00 00 <48> 8b 07 48 3b 06 75 17 48 83 c7 08 48 83 c6 08 48 83 c2 f8 48 83
Feb 23 17:13:08 causality kernel: RSP: 0018:ffff9849c13138a8 EFLAGS: 00010202
Feb 23 17:13:08 causality kernel: RAX: 0000000000000000 RBX: ffffffffc3b57ff7 RCX: 0000000000000000
Feb 23 17:13:08 causality kernel: RDX: 0000000000000009 RSI: ffff9849c13138c0 RDI: ffffffffc3b57ff7
Feb 23 17:13:08 causality kernel: RBP: ffff9849c1313a00 R08: 0000000000000000 R09: 0000000000000000
Feb 23 17:13:08 causality kernel: R10: 0000000000000000 R11: 0000000000000000 R12: ffff9849c13138c0
Feb 23 17:13:08 causality kernel: R13: 0000000000000009 R14: 0000000000000009 R15: ffffffffc3b58000
Feb 23 17:13:08 causality kernel: FS:  00007fec344a3e40(0000) GS:ffff8f219ec80000(0000) knlGS:0000000000000000
Feb 23 17:13:08 causality kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Feb 23 17:13:08 causality kernel: CR2: ffffffffc3b57ff7 CR3: 00000001056ca004 CR4: 00000000003706f0
Feb 23 17:13:08 causality kernel: DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Feb 23 17:13:08 causality kernel: DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Feb 23 17:13:08 causality kernel: Call Trace:
Feb 23 17:13:08 causality kernel:  <TASK>
Feb 23 17:13:08 causality kernel:  ? __die_body+0x61/0xc0
Feb 23 17:13:08 causality kernel:  ? page_fault_oops+0x369/0x400
Feb 23 17:13:08 causality kernel:  ? exc_page_fault+0x6f/0x80
Feb 23 17:13:08 causality kernel:  ? asm_exc_page_fault+0x22/0x30
Feb 23 17:13:08 causality kernel:  ? bcmp+0x10/0x70
Feb 23 17:13:08 causality kernel:  patch_dest+0xa5/0x160
Feb 23 17:13:08 causality kernel:  patch_call+0x230/0x2d0
Feb 23 17:13:08 causality kernel:  callthunks_patch_module_calls+0x8e/0x140
Feb 23 17:13:08 causality kernel:  module_finalize+0x222/0x290
Feb 23 17:13:08 causality kernel:  post_relocation+0xb1/0x2c0
Feb 23 17:13:08 causality kernel:  load_module+0x11ac/0x1570
Feb 23 17:13:08 causality kernel:  __se_sys_finit_module+0x319/0x420
Feb 23 17:13:08 causality kernel:  do_syscall_64+0x6e/0xf0
Feb 23 17:13:08 causality kernel:  ? __se_sys_newfstatat+0xb0/0x300
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x4e/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x48/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x42/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x3c/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x36/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x30/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x2a/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x24/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x1e/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x18/0x90
Feb 23 17:13:08 causality kernel:  ? call_depth_return_thunk+0x12/0x90
Feb 23 17:13:08 causality kernel:  ? __x64_sys_openat+0x78/0xa0
Feb 23 17:13:08 causality kernel:  ? syscall_exit_to_user_mode+0x71/0x90
Feb 23 17:13:08 causality kernel:  ? do_syscall_64+0x7a/0xf0
Feb 23 17:13:08 causality kernel:  ? syscall_exit_to_user_mode+0x71/0x90
Feb 23 17:13:08 causality kernel:  ? do_syscall_64+0x7a/0xf0
Feb 23 17:13:08 causality kernel:  ? exc_page_fault+0x53/0x80
Feb 23 17:13:08 causality kernel:  ? irqentry_exit_to_user_mode+0x67/0x90
Feb 23 17:13:08 causality kernel:  entry_SYSCALL_64_after_hwframe+0x5f/0x67
Feb 23 17:13:08 causality kernel: RIP: 0033:0x7fec3472a22d
Feb 23 17:13:08 causality kernel: Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d cb bb 0c 00 f7 d8 64 89 01 48
Feb 23 17:13:08 causality kernel: RSP: 002b:00007ffce6da0a68 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
Feb 23 17:13:08 causality kernel: RAX: ffffffffffffffda RBX: 0000555aa9d903c0 RCX: 00007fec3472a22d
Feb 23 17:13:08 causality kernel: RDX: 0000000000000000 RSI: 00007fec34c58070 RDI: 000000000000001a
Feb 23 17:13:08 causality kernel: RBP: 00007fec34c58070 R08: 0000000000000040 R09: fffffffffffffe78
Feb 23 17:13:08 causality kernel: R10: 00007fec347f6b20 R11: 0000000000000246 R12: 0000000000020000
Feb 23 17:13:08 causality kernel: R13: 0000555aa9d94600 R14: 0000000000000000 R15: 0000555aa9d94f30
Feb 23 17:13:08 causality kernel:  </TASK>
Feb 23 17:13:08 causality kernel: Modules linked in: nvidia(PO) drm_ttm_helper ttm video
Feb 23 17:13:08 causality kernel: CR2: ffffffffc3b57ff7
Feb 23 17:13:08 causality kernel: ---[ end trace 0000000000000000 ]---
Feb 23 17:13:08 causality kernel: RIP: 0010:bcmp+0x10/0x70
Feb 23 17:13:08 causality kernel: Code: 02 00 cc cc cc cc cc cc cc cc 90 90 90 90 90 90 90 65 48 c1 3d 60 e8 36 72 05 48 83 fa 08 72 24 66 2e 0f 1f 84 00 00 00 00 00 <48> 8b 07 48 3b 06 75 17 48 83 c7 08 48 83 c6 08 48 83 c2 f8 48 83
Feb 23 17:13:08 causality kernel: RSP: 0018:ffff9849c13138a8 EFLAGS: 00010202
Feb 23 17:13:08 causality kernel: RAX: 0000000000000000 RBX: ffffffffc3b57ff7 RCX: 0000000000000000
Feb 23 17:13:08 causality kernel: RDX: 0000000000000009 RSI: ffff9849c13138c0 RDI: ffffffffc3b57ff7
Feb 23 17:13:08 causality kernel: RBP: ffff9849c1313a00 R08: 0000000000000000 R09: 0000000000000000
Feb 23 17:13:08 causality kernel: R10: 0000000000000000 R11: 0000000000000000 R12: ffff9849c13138c0
Feb 23 17:13:08 causality kernel: R13: 0000000000000009 R14: 0000000000000009 R15: ffffffffc3b58000
Feb 23 17:13:08 causality kernel: FS:  00007fec344a3e40(0000) GS:ffff8f219ec80000(0000) knlGS:0000000000000000
Feb 23 17:13:08 causality kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Feb 23 17:13:08 causality kernel: CR2: ffffffffc3b57ff7 CR3: 00000001056ca004 CR4: 00000000003706f0
Feb 23 17:13:08 causality kernel: DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Feb 23 17:13:08 causality kernel: DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


From this and the nearly complete lack of relevant searches, it seems like I'm the first in years to try an LTO kernel with out-of-tree drivers. If anyone else has tried it, they haven't written much of anything about it that shows up in search engines that I could find. I wound up disabling LTO and building both this new kernel and nvidia-drivers with GCC. No more errors. It was a nice experiment, though.
Back to top
View user's profile Send private message
Juippisi
Developer
Developer


Joined: 30 Sep 2005
Posts: 762
Location: /home

PostPosted: Tue Feb 25, 2025 6:12 am    Post subject: Reply with quote

Quote:

From this and the nearly complete lack of relevant searches, it seems like I'm the first in years to try an LTO kernel with out-of-tree drivers.


Using clang and "-flto=thin" to build everything system-wide, kernel and nvidia drivers work fine here and has worked for years.

Code:

# zgrep -i lto /proc/config.gz
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_CLANG_FULL is not set
CONFIG_LTO_CLANG_THIN=y


Code:

# cat /var/db/pkg/x11-drivers/nvidia-drivers-550.144.03/CFLAGS
-march=native -O3 -pipe -flto=thin
Back to top
View user's profile Send private message
zhahir zulkufli
n00b
n00b


Joined: 26 Mar 2025
Posts: 1

PostPosted: Thu Mar 27, 2025 6:06 am    Post subject: NVIDIA Kernel Oops with Linux Kernel 6.12.16 Reply with quote

Using Kernel 6.12.16 (Profile [39] llvm) produce same result:
Code:

gentoo ~ # cat /var/db/pkg/sys-kernel/gentoo-sources-6.12.16/CFLAGS
-march=znver3 -O2 -pipe -Wno-unused-command-line-argument -flto=thin


Nvidia Version: 535.230.02 and 550.144.03:
Code:
gentoo ~ # cat /var/db/pkg/x11-drivers/nvidia-drivers-535.230.02/CFLAGS
-march=znver3 -O2 -pipe -Wno-unused-command-line-argument -flto=thin


dmesg output:
Code:

[    9.203811] nvidia: loading out-of-tree module taints kernel.
[    9.290017] BUG: kernel NULL pointer dereference, address: 0000000000000008
[    9.290311] #PF: supervisor instruction fetch in kernel mode
[    9.290562] #PF: error_code(0x0010) - not-present page
[    9.290800] PGD 0 P4D 0
[    9.291041] Oops: Oops: 0010 [#1] PREEMPT SMP NOPTI
[    9.291263] CPU: 7 UID: 0 PID: 1239 Comm: (udev-worker) Tainted: G           O       6.12.16-gentoo-Clang-ThinLTO #7
[    9.291487] Tainted: [O]=OOT_MODULE


Need some guidance, please..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum