ClangBuiltLinux / linux

Linux kernel source tree
Other
241 stars 14 forks source link

"relocation R_LARCH_B26 out of range" when building LoongArch allyesconfig with KCOV #1895

Open nathanchance opened 1 year ago

nathanchance commented 1 year ago

After https://git.kernel.org/chenhuacai/linux-loongson/c/54b9a87ddcc9102826437d3c26ed6c4ab2ad3677, I see the following errors when building ARCH=loongarch allyesconfig with the known broken configurations disabled:

$ make -skj"$(nproc)" ARCH=loongarch KCONFIG_ALLCONFIG=<(echo 'CONFIG_MODULES=n
CONFIG_CRASH_DUMP=n
CONFIG_RELOCATABLE=n
CONFIG_WERROR=n') LLVM=1 mrproper allyesconfig vmlinux
...
ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_lockspace_exit: .text+0x28): relocation R_LARCH_B26 out of range: 167866808 is not in [-134217728, 134217727]; references 'kset_unregister'
>>> referenced by lockspace.c
>>> defined in lib/lib.a(kobject.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_global: .text+0x6c): relocation R_LARCH_B26 out of range: 168323444 is not in [-134217728, 134217727]; references '_raw_spin_lock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_global: .text+0xc8): relocation R_LARCH_B26 out of range: 168324056 is not in [-134217728, 134217727]; references '_raw_spin_unlock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_local: .text+0x12c): relocation R_LARCH_B26 out of range: 168323252 is not in [-134217728, 134217727]; references '_raw_spin_lock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_local: .text+0x188): relocation R_LARCH_B26 out of range: 168323864 is not in [-134217728, 134217727]; references '_raw_spin_unlock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_device: .text+0x1ec): relocation R_LARCH_B26 out of range: 168323060 is not in [-134217728, 134217727]; references '_raw_spin_lock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function dlm_find_lockspace_device: .text+0x248): relocation R_LARCH_B26 out of range: 168323672 is not in [-134217728, 134217727]; references '_raw_spin_unlock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/btrfs/file.o):(function btrfs_dirty_pages: .text+0x22c): relocation R_LARCH_B26 out of range: 155483484 is not in [-134217728, 134217727]; references '_printk'
>>> referenced by file.c
>>> defined in vmlinux.a(kernel/printk/printk.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0x438): relocation R_LARCH_B26 out of range: 168288072 is not in [-134217728, 134217727]; references 'mutex_lock_nested'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/mutex.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0x4dc): relocation R_LARCH_B26 out of range: 168036516 is not in [-134217728, 134217727]; references 'strlen'
>>> referenced by lockspace.c
>>> defined in lib/lib.a(string.o)

ld.lld: error: vmlinux.a(fs/btrfs/file.o):(function btrfs_drop_extents: .text+0x1740): relocation R_LARCH_B26 out of range: 155480080 is not in [-134217728, 134217727]; references 'abort_should_print_stack'
>>> referenced by file.c
>>> defined in vmlinux.a(fs/btrfs/ctree.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0x5ac): relocation R_LARCH_B26 out of range: 168037044 is not in [-134217728, 134217727]; references 'strncmp'
>>> referenced by lockspace.c
>>> defined in lib/lib.a(string.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0x6d4): relocation R_LARCH_B26 out of range: 168322508 is not in [-134217728, 134217727]; references '_raw_spin_unlock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: vmlinux.a(fs/btrfs/file.o):(function btrfs_drop_extents: .text+0x19f0): relocation R_LARCH_B26 out of range: 155479392 is not in [-134217728, 134217727]; references 'abort_should_print_stack'
>>> referenced by file.c
>>> defined in vmlinux.a(fs/btrfs/ctree.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0x84c): relocation R_LARCH_B26 out of range: 168285556 is not in [-134217728, 134217727]; references 'mutex_unlock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/mutex.o)

ld.lld: error: vmlinux.a(fs/dlm/lockspace.o):(function __dlm_new_lockspace: .text+0xde8): relocation R_LARCH_B26 out of range: 168319992 is not in [-134217728, 134217727]; references '_raw_spin_lock'
>>> referenced by lockspace.c
>>> defined in vmlinux.a(kernel/locking/spinlock.o)

ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)

Turning off CONFIG_KCOV avoids the issue. I assume that KCOV instrumentation is blowing up the size of the kernel and ld.lld is not able to cope with that? I would not even bother building allyesconfig normally but it is a better target than allmodconfig at the moment :)

cc @xen0n

xen0n commented 1 year ago

The LoongArch psABI can be pretty strict about the code model selection and access pattern at times, because support for range extension thunks isn't currently implemented nor mandated, so a symbol access in one of the smaller code model's way would naturally fall short in this case.

I'd investigate whether it's KCOV or lld that needs adaptation. thanks for the quick report!

nathanchance commented 9 months ago

For what it's worth, I think this is low priority now that CONFIG_MODULES works (#1884), as we can use allmodconfig for testing, which has a much smaller final image size.