Skip to content

[LLD] Crash in Machine Block Frequency Analysis when linking AMD GPU drivers with LTO #152883

@svan71

Description

@svan71

Bug Description

LLD crashes with segfault when linking Linux kernel with LTO enabled, specifically when processing AMD GPU driver code.

Environment

  • LLVM Version: [run ld.lld --version]
  • Target: x86_64-unknown-linux-gnu
  • Kernel Version: 6.16
  • GPU: AMD RX 6950 XT (Navi 21)
  • Distribution: CachyOS

Crash Details

Stack dump:
0. Program arguments: ld.lld -m elf_x86_64 -mllvm -import-instr-limit=5 -z noexecstack -r -o drivers/gpu/drm/amd/amdgpu/amdgpu.o @drivers/gpu/drm/amd/amdgpu/amdgpu.mod

Running pass 'Function Pass Manager' on module 'ld-temp.o'.
Running pass 'Machine Block Frequency Analysis' on function '@gfx_v9_0_update_coarse_grain_clock_gating' #0 0x00007fe1734ea01d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM.so.20.1+0x8ea01d) #1 0x00007fe1734e7647 (/usr/lib/libLLVM.so.20.1+0x8e7647) #2 0x00007fe17243e540 (/usr/lib/libc.so.6+0x3e540) #3 0x00007ffc5a2b6110 make[6]: *** [scripts/Makefile.build:502: drivers/gpu/drm/amd/amdgpu/amdgpu.o] Error 139## Reproduction Steps

  1. Clone CachyOS kernel: git clone https://github.com/CachyOS/linux-cachyos.git
  2. Enable LTO in PKGBUILD: _use_llvm_lto=full or _use_llvm_lto=thin
  3. Run makepkg to build kernel
  4. Crash occurs during AMD GPU driver linking

Workaround

Using GNU linker (export LLVM=0) instead of LLD avoids the crash.

Additional Info

  • Crash is deterministic and always occurs at same function
  • Only affects builds with LTO enabled
  • AMD GPU drivers load successfully in current running kernel

Metadata

Metadata

Assignees

No one assigned

    Labels

    LTOLink time optimization (regular/full LTO or ThinLTO)crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions