Bug 215862

Summary: clang-15 fails ppc64 BE kernel build - ld.lld: error: undefined symbol: .early_setup
Product: Platform Specific/Hardware Reporter: Erhard F. (erhard_f)
Component: PPC-64Assignee: platform_ppc-64
Status: RESOLVED OBSOLETE    
Severity: normal CC: christophe.leroy
Priority: P1    
Hardware: PPC-64   
OS: Linux   
URL: https://github.com/ClangBuiltLinux/linux/issues/1761
Kernel Version: 5.18-rc3 Subsystem:
Regression: No Bisected commit-id:
Attachments: kernel .config (kernel 5.18-rc3, Talos II)
kernel .config (6.1-rc5, PowerMac G5 11,2)
attachment-29432-0.html

Description Erhard F. 2022-04-18 14:12:39 UTC
Created attachment 300776 [details]
kernel .config (kernel 5.18-rc3, Talos II)

# make LLVM=1
[...]
  AR      usr/built-in.a
  CC      arch/powerpc/kernel/ptrace/ptrace.o
  CC      arch/powerpc/kernel/ptrace/ptrace-view.o
  CC      arch/powerpc/kernel/ptrace/ptrace-fpu.o
  CC      arch/powerpc/kernel/ptrace/ptrace32.o
  CC      arch/powerpc/kernel/ptrace/ptrace-vsx.o
  CC      arch/powerpc/kernel/ptrace/ptrace-altivec.o
  CC      arch/powerpc/kernel/ptrace/ptrace-tm.o
  CC      arch/powerpc/kernel/ptrace/ptrace-noadv.o
  AR      arch/powerpc/kernel/ptrace/built-in.a
  AR      arch/powerpc/kernel/trace/built-in.a
  AS      arch/powerpc/kernel/head_64.o
<unknown>:0: error: expected relocatable expression
make[2]: *** [scripts/Makefile.build:389: arch/powerpc/kernel/head_64.o] Fehler 1
make[1]: *** [scripts/Makefile.build:550: arch/powerpc/kernel] Fehler 2
make: *** [Makefile:1834: arch/powerpc] Fehler 2

Toolchain used was llvm/clang/lld-14.0.1. Same kernel builds fine with gcc-11.2, binutils-2.37.
Comment 1 Erhard F. 2022-11-15 18:48:52 UTC
Reinvestigated with clang 15 on my PowerMac G5 11,2.

Got further on as kernel + modules are built now. But I get an error at the linking stage:

 # LLVM=1 LLVM_IAS=1 make
  CALL    scripts/checksyscalls.sh
  UPD     include/generated/utsversion.h
  CC      init/version-timestamp.o
  LD      .tmp_vmlinux.kallsyms1
ld.lld: error: undefined symbol: .early_setup
>>> referenced by head_64.S:973
>>> (/usr/src/linux-stable/arch/powerpc/kernel/head_64.S:973)
>>>               arch/powerpc/kernel/head_64.o:(.ref.text+0xBE) in archive
>>>               vmlinux.a
>>> referenced by head_64.S:973
>>> (/usr/src/linux-stable/arch/powerpc/kernel/head_64.S:973)
>>>               arch/powerpc/kernel/head_64.o:(.ref.text+0xC2) in archive
>>>               vmlinux.a
>>> did you mean: early_setup
>>> defined in: vmlinux.a(arch/powerpc/kernel/setup_64.o)
make[1]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
make: *** [Makefile:1236: vmlinux] Error 2

Toolchain used was llvm/clang/lld-15.0.3. Same kernel builds fine with gcc-12.2, binutils-2.39.
Comment 2 Erhard F. 2022-11-15 18:49:57 UTC
Created attachment 303185 [details]
kernel .config (6.1-rc5, PowerMac G5 11,2)
Comment 3 Christophe Leroy 2022-11-15 20:08:57 UTC
If not already done, can you report the problem at https://github.com/ClangBuiltLinux/linux/issues
Comment 4 Erhard F. 2022-11-15 23:11:50 UTC
(In reply to Christophe Leroy from comment #3)
> If not already done, can you report the problem at
> https://github.com/ClangBuiltLinux/linux/issues
I was not aware of this issue tracker. Thanks for the hint!

Filed now unter https://github.com/ClangBuiltLinux/linux/issues/1761
Comment 5 Erhard F. 2023-07-31 10:22:58 UTC
Fixed in kernel v6.4.x series.

Closing.
Comment 6 Christophe Leroy 2023-07-31 10:23:09 UTC
Created attachment 304741 [details]
attachment-29432-0.html

I'm out of office until August 1st.