allmodconfig link failure on -next (relocation R_HEX_B22_PCREL out of range)
Hi Brian,
With next-20241112 (and some prior versions) and tip of tree LLVM, I am seeing a link failure, possibly because the kernel image has gotten too large? A simple reproducer (KCONFIG_ALLCONFIG is needed to workaround other tangential warnings/issues):
$ make -skj"$(nproc)" \
ARCH=hexagon \
KCONFIG_ALLCONFIG=<(printf 'CONFIG_%s=n\n' {DRM_,WERROR} GPIB_NI_PCI_ISA) \
LLVM=1 \
mrproper allmodconfig vmlinux
...
ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160): relocation R_HEX_B22_PCREL out of range: 2098032 is not in [-2097152, 2097151]; references 'memset'Quoted 1 line
Quoted 1 line
Quoted 1 line
defined in
vmlinux.a(arch/hexagon/lib/memset.o)
I did notice that this error was not reproducible with LLVM 19 so I did a bisect of LLVM and it seems like commit 6b11573b8c5e ("Recommit "[FunctionAttrs] deduce attr cold on functions if all CG paths call a cold function"") in main introduces this, so maybe it is that .text.unlikely grows enough to make .init.text be too far away from memset() in .text?
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
Cheers,
Nathan
Quoted 16 lines
-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Tuesday, November 12, 2024 10:13 PM
To: Brian Cain <[email protected]>
Cc: [email protected]; [email protected]
Subject: allmodconfig link failure on -next (relocationR_HEX_B22_PCRELout of range)Hi Brian,
With next-20241112 (and some prior versions) and tip of tree LLVM, I am seeing a link failure, possibly because the kernel image has gotten too large? A simple reproducer (
KCONFIG_ALLCONFIGis needed to workaround other tangential warnings/issues):
Quoted 11 lines
$ make -skj"$(nproc)" \ ARCH=hexagon \ KCONFIG_ALLCONFIG=<(printf 'CONFIG_%s=n\n' {DRM_,WERROR} GPIB_NI_PCI_ISA) \ LLVM=1 \ mrproper allmodconfig vmlinux ... ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160): relocation R_HEX_B22_PCREL out of range: 2098032 is not in [-2097152, 2097151]; references 'memset'Quoted 1 line
Quoted 1 line
Quoted 1 line
defined in
vmlinux.a(arch/hexagon/lib/memset.o)
This error seems to be due to an incorrect range calculation for this and other relocations. Alexey has a PR for lld under review https://github.com/llvm/llvm-project/pull/115925
In addition, since our initial hexagon port landed, lld has added support for range thunks. And Alexey and I have a PR for that too https://github.com/llvm/llvm-project/pull/111217 - this should make us generally more robust in the case of larger executable images.
Quoted 6 lines
I did notice that this error was not reproducible with LLVM 19 so I did a bisect of LLVM and it seems like commit
6b11573b8c5e("Recommit "[FunctionAttrs] deduce attrcoldon functions if all CG paths call acoldfunction"") in main introduces this, so maybe it is that .text.unlikely grows enough to make .init.text be too far away frommemset()in .text?
Yes, that seems to be an accurate analysis.
Quoted 4 lines
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
We don't do enough testing of the toolchain changes with regard to the kernel. I think we have room to improve there. I'd like to incorporate more testing into our workflow for landing changes in upstream LLVM.
-Brian
Quoted 9 lines · Brian Cain
Quoted 9 lines
-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Tuesday, November 12, 2024 10:13 PM
To: Brian Cain <[email protected]>
Cc: [email protected]; [email protected]
Subject: allmodconfig link failure on -next (relocationR_HEX_B22_PCRELout of range)
Quoted 7 lines
Quoted 4 lines
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
We don't do enough testing of the toolchain changes with regard to the kernel. I think we have room to improve there. I'd like to incorporate more testing into our workflow for landing changes in upstream LLVM.
Build testing a few "blessed configs" would be a good place to start. We spoke briefly a few weeks ago about upstreaming qemu system support; that would allow us to start boot testing (though, we're using buildroot to create small userspace images; we'd probably need to look into hexagon support in buildroot then, too). We're happy to hop on a call to discuss some of these topics if you or the team have questions.
Also, thanks Alexey for the quick fix to LLD!
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 30 lines
-----Original Message-----
From: Nick Desaulniers <[email protected]>
Sent: Wednesday, November 13, 2024 10:43 AM
To: Brian Cain <[email protected]>
Cc: Nathan Chancellor <[email protected]>; [email protected]; [email protected]; Alexey Karyakin <[email protected]>; Sid Manning <[email protected]>; Sundeep Kushwaha <[email protected]>; Shankar Kalpathi Easwaran <[email protected]>
Subject: Re: allmodconfig link failure on -next (relocationR_HEX_B22_PCRELout of range)CAUTION: This email originated from a known Qualcomm vendor. Please exercise caution with any unexpected requests, links, or attachments.
Quoted 7 lines · Brian Cain
Quoted 7 lines
-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Tuesday, November 12, 2024 10:13 PM
To: Brian Cain <[email protected]>
Cc: [email protected]; [email protected]
Subject: allmodconfig link failure on -next (relocationR_HEX_B22_PCRELout of
Quoted 7 lines
Quoted 6 lines
range)
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
Quoted 6 lines
Quoted 1 line
We don't do enough testing of the toolchain changes with regard to the
kernel. I think we have room to improve there. I'd like to incorporate more testing into our workflow for landing changes in upstream LLVM.
Quoted 1 line
Build testing a few "blessed configs" would be a good place to start.
Yeah - I'd like to add some buildbot or some other infrastructure that would help developers find these issues sooner, including kernel and/or buildroot and/or llvm-test-suite. I'll discuss with the team how we could accomplish this.
Quoted 2 lines
We spoke briefly a few weeks ago about upstreaming qemu system support; that would allow us to start boot testing (though, we're
Using qemu system is ~months away, unfortunately. But very high priority for us and in progress right now. A big dependency is a working hypervisor and that activity is ongoing in https://github.com/quic/hexagonMVM
Quoted 2 lines
using buildroot to create small userspace images; we'd probably need to look into hexagon support in buildroot then, too). We're happy to
Good news! It's underway too:
https://lists.buildroot.org/pipermail/buildroot/2024-October/765882.html
https://github.com/quic/buildroot/tree/bcain/to-upstream
Quoted 4 lines
hop on a call to discuss some of these topics if you or the team have questions.
Also, thanks Alexey for the quick fix to LLD!
It's a bit of a lucky coincidence. I've seen occasional "out of range" link errors with user programs (via buildroot et al), so I started down the path of adding thunks to lld. While reviewing the thunk changes to lld, Alexey found the relocation size bug. So it was underway before this was reported.
-Brian
Quoted 8 lines · Brian Cain
Quoted 4 lines
ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160):
relocationR_HEX_B22_PCRELout of range: 2098032 is not in [-2097152, 2097151]; references 'memset'Quoted 1 line
Quoted 1 line
Quoted 1 line
defined in
vmlinux.a(arch/hexagon/lib/memset.o)This error seems to be due to an incorrect range calculation for this and other relocations. Alexey has a PR for lld under review
https://github.com/llvm/llvm-project/pull/115925
Thanks! This does appear to resolve this particular problem for me. Will that need to be backported?
Quoted 4 lines
In addition, since our initial hexagon port landed, lld has added support for range thunks. And Alexey and I have a PR for that too
https://github.com/llvm/llvm-project/pull/111217 - this should make us generally more robust in the case of larger executable images.
Good to hear!
Quoted 9 lines
Quoted 4 lines
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
We don't do enough testing of the toolchain changes with regard to the kernel. I think we have room to improve there. I'd like to incorporate more testing into our workflow for landing changes in upstream LLVM.
I see you made some comments on this downstream but if you want any input or help, I am happy to provide it.
Cheers,
Nathan
Quoted 20 lines
-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Wednesday, November 13, 2024 12:25 PM
To: Brian Cain <[email protected]>
Cc: [email protected]; [email protected]; Alexey Karyakin <[email protected]>; Sid Manning <[email protected]>; Sundeep Kushwaha <[email protected]>; Shankar Kalpathi Easwaran <[email protected]>
Subject: Re: allmodconfig link failure on -next (relocationR_HEX_B22_PCRELout of range)WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.
Quoted 5 lines · Brian Cain
Quoted 4 lines
ld.lld: error: vmlinux.a(arch/hexagon/kernel/head.o):(.init.text+0x160):
relocationR_HEX_B22_PCRELout of range: 2098032 is not in [-2097152, 2097151]; references 'memset'Quoted 1 line
Quoted 1 line
Quoted 1 line
defined in
vmlinux.a(arch/hexagon/lib/memset.o)
Quoted 6 lines
Quoted 3 lines
This error seems to be due to an incorrect range calculation for this and other relocations. Alexey has a PR for lld under review
https://github.com/llvm/llvm-project/pull/115925Thanks! This does appear to resolve this particular problem for me. Will that need to be backported?
I was hoping/planning to request it to be cherry-picked to 19.1.x once it lands on main - are you asking for branches older than that too? This linker problem has been there "forever" but I suppose the compiler only recently made a change that makes it more apparent.
Sid and I have discussed whether it makes sense to change these calls in the kernel to be extended. That might be a good idea, but it's not without drawbacks.
Quoted 12 lines
Quoted 4 lines
In addition, since our initial hexagon port landed, lld has added support for range thunks. And Alexey and I have a PR for that too
https://github.com/llvm/llvm-project/pull/111217 - this should make us generally more robust in the case of larger executable images.Good to hear!
Quoted 5 lines
Quoted 4 lines
As an aside, do you folks working on Hexagon do any sort of validation of the kernel and toolchain? I feel like I have run into a decent number of Hexagon-specific issues this year and I am curious if any of these things have been caught by any testing that you might be doing.
Quoted 7 lines
Quoted 4 lines
We don't do enough testing of the toolchain changes with regard to the kernel. I think we have room to improve there. I'd like to incorporate more testing into our workflow for landing changes in upstream LLVM.
I see you made some comments on this downstream but if you want any input or help, I am happy to provide it.
Thanks, Nathan! I will include you on our discussions/progress here.
-Brian
Quoted 8 lines · Brian Cain
Quoted 6 lines
Quoted 3 lines
This error seems to be due to an incorrect range calculation for this and other relocations. Alexey has a PR for lld under review
https://github.com/llvm/llvm-project/pull/115925Thanks! This does appear to resolve this particular problem for me. Will that need to be backported?
I was hoping/planning to request it to be cherry-picked to 19.1.x once
Sounds good!
Quoted 1 line
it lands on main - are you asking for branches older than that too?
No, I am aware that the older branches are not supported, so we will just take what we can get :)
Quoted 2 lines
This linker problem has been there "forever" but I suppose the compiler only recently made a change that makes it more apparent.
Right, if this becomes more prevalent, then we will just stop building allmodconfig with older versions of LLVM. For now, I think ensuring the fix lands in main and gets backported to 19.1.x should be enough to avoid any issues.
Cheers,
Nathan