Unable to Compile Kernel
dslm4515 opened this issue · comments
Kernel 6.3 fails to compile with LLVM ( LLVM=1 LLVM_IAS=1 make
):
make[3]: 'install_headers' is up to date.
LD [M] arch/x86/events/amd/amd-uncore.o
ld.lld: error: arch/x86/events/amd/uncore.o: invalid symbol index
make[4]: *** [scripts/Makefile.build:452: arch/x86/events/amd/amd-uncore.o] Error 1
make[3]: *** [scripts/Makefile.build:494: arch/x86/events/amd] Error 2
make[2]: *** [scripts/Makefile.build:494: arch/x86/events] Error 2
make[1]: *** [scripts/Makefile.build:494: arch/x86] Error 2
make: *** [Makefile:2025: .] Error 2
Let's try GCC & binutils (installed in /opt/gnu):
make[3]: 'install_headers' is up to date.
LD [M] arch/x86/events/amd/amd-uncore.o
ld: arch/x86/events/amd/uncore.o: bad reloc symbol index (0x6d >= 0x6d) for offset 0x3 in section `.text'
ld: arch/x86/events/amd/uncore.o: bad reloc symbol index (0x6d >= 0x6d) for offset 0x3 in section `.text'
ld: failed to set dynamic section sizes: bad value
make[4]: *** [scripts/Makefile.build:452: arch/x86/events/amd/amd-uncore.o] Error 1
make[3]: *** [scripts/Makefile.build:494: arch/x86/events/amd] Error 2
make[2]: *** [scripts/Makefile.build:494: arch/x86/events] Error 2
make[1]: *** [scripts/Makefile.build:494: arch/x86] Error 2
make: *** [Makefile:2025: .] Error 2
Or LLVM+elftoolschain? (LLVM=1 make
)
make[3]: 'install_headers' is up to date.
LD [M] arch/x86/events/amd/amd-uncore.o
ld.lld: error: arch/x86/events/amd/uncore.o: invalid symbol index
make[4]: *** [scripts/Makefile.build:452: arch/x86/events/amd/amd-uncore.o] Error 1
make[3]: *** [scripts/Makefile.build:494: arch/x86/events/amd] Error 2
make[2]: *** [scripts/Makefile.build:494: arch/x86/events] Error 2
make[1]: *** [scripts/Makefile.build:494: arch/x86] Error 2
make: *** [Makefile:2025: .] Error 2
Maybe a typo or bug in kernel 6.3? Same errors for kernel 6.3.2
BUT kernel 6.1.8 compiles fine (LLVM=1 LLVM_IAS=1 make
).
Let's disable CONFIG_PERF_EVENTS_AMD_UNCORE
in the kernel config...
Compile goes a bit further but another error found:
make[3]: 'install_headers' is up to date.
AR arch/x86/built-in.a
LD [M] arch/x86/kvm/kvm.o
ld.lld: error: arch/x86/kvm/x86.o: invalid symbol index
make[3]: *** [scripts/Makefile.build:452: arch/x86/kvm/kvm.o] Error 1
make[2]: *** [scripts/Makefile.build:494: arch/x86/kvm] Error 2
make[1]: *** [scripts/Makefile.build:494: arch/x86] Error 2
make: *** [Makefile:2025: .] Error 2
Let's disable virtualization, CONFIG_VIRTUALIZATION
...
so far no errors...
... another obstacle:
make[3]: 'install_headers' is up to date.
LD [M] crypto/ecdh_generic.o
ld.lld: error: crypto/ecdh.o: invalid symbol index
make[2]: *** [scripts/Makefile.build:452: crypto/ecdh_generic.o] Error 1
make[1]: *** [scripts/Makefile.build:494: crypto] Error 2
make[1]: *** Waiting for unfinished jobs....
LD [M] fs/isofs/isofs.o
LD [M] fs/squashfs/squashfs.o
ld.lld: error: fs/isofs/inode.o: invalid symbol index
make[3]: *** [scripts/Makefile.build:452: fs/isofs/isofs.o] Error 1
make[2]: *** [scripts/Makefile.build:494: fs/isofs] Error 2
make[2]: *** Waiting for unfinished jobs....
ld.lld: error: fs/squashfs/cache.o: invalid symbol index
make[3]: *** [scripts/Makefile.build:452: fs/squashfs/squashfs.o] Error 1
make[2]: *** [scripts/Makefile.build:494: fs/squashfs] Error 2
make[1]: *** [scripts/Makefile.build:494: fs] Error 2
make: *** [Makefile:2025: .] Error 2
So far ...
6.1.8 -> No errors. Success
6.1.29 -> No errors. Success
6.2.9 -> fail
6.3.0 -> fail
6.3.2 -> fail
6.3.3 -> Fail
6.4-r2 -> Fail
Used the same kernel config for each kernel version. I made sure to run LLVM=1 make oldconfig
to make sure kernel config was compatible with the source tree.
Looks like starting with kernel version 6.2.x, the same errors pop up
I haven't played around with LLVM in a while, but what about using Clang/Clang++ with GNU Binutils? I know it's not the ideal, but it would be a workaround while the LLVM and elftoolchain folks doesn't fix this bug.
Funny enough, Linux v6.1.8 compiles fine, per what you've said, so we could also just go with it instead of insisting in other versions.
By the way, what about v5.15.103? Does it also compile fine?
That's true. I have tried other combinations but not yet LLVM+Binutils. That will be my next test
Same issue with LLVM+Binutils, "invalid symbol index"
is it an issue with the linker?
is it an issue with the linker?
If kernel version 6.1.29 compiles fine, I would like to say no... unless something in the kernel source changed starting with 6.2.x and later.
Kernel updates are usually big, so maybe something did. Lets first try a diff linker (eg. mold), and if that doesnt work, follow alpine linux
update: mold requires a SSL library for libcrypto, and that doesnt need to be in a toolchain. probably compile libreSSL and clang, and then compile mold, then proceed with the rest of stage2
Wow. Never heard of mold... Ha, I guess I might consider replacing LLD with mold.
Let's just say I'm not a fan of rust, so I'm impressed mold is coded in c++
Mold might not be the reason this is happening. There are some patches on chimera linux for the latest kernel, so lets try those
Wow. Never heard of mold... Ha, I guess I might consider replacing LLD with mold.
Let's just say I'm not a fan of rust, so I'm impressed mold is coded in c++
I'd also propose that we just use GNU Binutils' ld
(1) instead of LLVM's lld
(1), like https://github.com/ClangBuiltLinux/tc-build does.
Mold might not be the reason this is happening. There are some patches on chimera linux for the latest kernel, so lets try those
Yeah, checking for Chimera patches might also be a good idea.
Looks like mold isn't supported by the kernel source:
mold: unknown linker
scripts/Kconfig.include:56: Sorry, this linker is not supported.
Per kisslinux.org:
It can not be used to link the Linux
kernel (due to lack of linker script support)
I only see kernel 6.1.38 for Chimera's linux-lts
kernel and 6.1.32 for the linux-rpi
kernel ... in the github repo
I only see kernel 6.1.38 for Chimera's
linux-lts
kernel and 6.1.32 for thelinux-rpi
kernel ... in the github repo
Well, what linker are they using?
I've suggested to use clang and later link using GNU's ld.bfd, unless 6.1.38 already supports LLVM's ld natively 👀 .
By the way, how the progress on using BSD's elftoolchain is going? I've read 'bout it on Musl-LFS's enhancement issues.
I've already tried LLD and ld.bfd... same problem. In fact, I cannot compile the latest kernel (starting with 6.2.x) with both GCC and clang. My GCC is installed in /opt/gnu
but compiles other packages just fine (so it's not broken?).
I have yet to try a 6.2.x+ kernel build on an older MLFS system.
Last I checked, Chimera Linux still used LLD.
Looks like Chimera Linux uses 6.4.x for their kernel-stable... not sure how I missed it. I was only seeing their build for kernel-LTS. There are lots of patches used for the 6.4.x kernel source
Successfully compile kernel-6.4.16 with just a single patch from Chimera Linux:
0001-fix-gelf_update_symshndx-with-elftoolchain.patch
Although, I wonder if patch really helped or did something change again, starting with kernel 6.4.x
Going to compile 6.5.4 with out patching ....
Looks like that chimera-linux patch fixed those warnings when compiling:
warning: objtool: gelf_update_symshndx: Invalid argument
Kernel 6.5.4 compiled without errors, using no patches from Chimera Linux.
I am closing this unless someone needs to use kernels 6.2.x and 6.3.x