Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fedora Rawhide kernel builds fails with unkown symbol errors. #2006

Closed
tstellar opened this issue Mar 7, 2024 · 6 comments
Closed

Fedora Rawhide kernel builds fails with unkown symbol errors. #2006

tstellar opened this issue Mar 7, 2024 · 6 comments
Labels
[FIXED][LLVM] 18 This bug was fixed in LLVM 18.0 [FIXED][LLVM] 19 This bug was fixed in LLVM 19.0 [Regression] llvm This was previously working, but the toolchain has regressed. [TOOL] lld The issue is relevant to LLD linker

Comments

@tstellar
Copy link

tstellar commented Mar 7, 2024

After upgrading from clang-17 to clang-18, the Fedora Rawhide kernel builds started to fail with many errors like:

nfsv4.ko needs unknown symbol __pcpu_unique_nfs4_callback_count1

Full build log is here

@tstellar
Copy link
Author

tstellar commented Mar 7, 2024

@nathanchance Here is the config file we were using for the last successful build with clang-17: config.txt

@nikic
Copy link

nikic commented Mar 12, 2024

I suspect that the key part of the config is CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y.

@nikic
Copy link

nikic commented Mar 12, 2024

test.c:

__attribute__((__section__(".discard"))) __attribute__((unused)) char __pcpu_unique_foo;

module.lds:

SECTIONS {
 /DISCARD/ : {
  *(.discard)
  *(.discard.*)
 }
}

Then:

build/bin/clang test.c -c
build/bin/ld.lld -r -T module.lds test.o -o test
objdump -t test

Produces:

0000000000000000       O *UND*	0000000000000000 __pcpu_unique_foo

With old ld.lld and ld.bfd, the undefined symbol was not present.

@nikic
Copy link

nikic commented Mar 12, 2024

This regressed in llvm/llvm-project@1981b1b, cc @MaskRay

@nickdesaulniers nickdesaulniers added the [TOOL] lld The issue is relevant to LLD linker label Mar 12, 2024
@nikic
Copy link

nikic commented Mar 13, 2024

Filed an upstream issue: llvm/llvm-project#85048

MaskRay added a commit to MaskRay/llvm-project that referenced this issue Mar 14, 2024
 llvm#69295 demoted Defined symbols relative to discarded sections.
If such a symbol is unreferenced, the desired behavior is to
eliminate it from .symtab just like --gc-sections discarded
definitions.
Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects
that the unreferenced `unused` is not emitted to .symtab
(ClangBuiltLinux/linux#2006).

For relocations referencing demoted symbols, the symbol index restores
to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`).

Fix llvm#85048
MaskRay added a commit to llvm/llvm-project that referenced this issue Mar 14, 2024
…85167)

#69295 demoted Defined symbols relative to discarded sections.
If such a symbol is unreferenced, the desired behavior is to
eliminate it from .symtab just like --gc-sections discarded
definitions.
Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects
that the unreferenced `unused` is not emitted to .symtab
(ClangBuiltLinux/linux#2006).

For relocations referencing demoted symbols, the symbol index restores
to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`).

Fix #85048
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Mar 14, 2024
…lvm#85167)

llvm#69295 demoted Defined symbols relative to discarded sections.
If such a symbol is unreferenced, the desired behavior is to
eliminate it from .symtab just like --gc-sections discarded
definitions.
Linux kernel's CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y configuration expects
that the unreferenced `unused` is not emitted to .symtab
(ClangBuiltLinux/linux#2006).

For relocations referencing demoted symbols, the symbol index restores
to 0 like older lld (`R_X86_64_64 0` in `discard-section.s`).

Fix llvm#85048

(cherry picked from commit 8fe3e70)
@nikic
Copy link

nikic commented Mar 15, 2024

Issue has been fixed and backported to the 18.x branch, so this can be closed.

@nathanchance nathanchance added [Regression] llvm This was previously working, but the toolchain has regressed. [FIXED][LLVM] 18 This bug was fixed in LLVM 18.0 [FIXED][LLVM] 19 This bug was fixed in LLVM 19.0 labels Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[FIXED][LLVM] 18 This bug was fixed in LLVM 18.0 [FIXED][LLVM] 19 This bug was fixed in LLVM 19.0 [Regression] llvm This was previously working, but the toolchain has regressed. [TOOL] lld The issue is relevant to LLD linker
Projects
None yet
Development

No branches or pull requests

4 participants