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
cmd/link: relocation truncated to fit: R_ARM_CALL against `runtime.duffcopy' #58425
Comments
Copying from kubernetes/kubernetes#115605 (comment) Reproducer with a Dockerfile, on kubernetes/kubernetes@b7ad179: FROM debian:latest
RUN apt-get update && \
apt-get install -y \
gcc-arm-linux-gnueabihf \
wget
RUN wget https://go.dev/dl/go1.20.linux-amd64.tar.gz && \
tar xf *.tar.gz && \
mv go /usr/local
ENV PATH=$PATH:/usr/local/go/bin
ENV GOARCH=arm
ENV CGO_ENABLED=1
ENV CC=arm-linux-gnueabihf-gcc
COPY . /work
WORKDIR /work
RUN go test -o e2e_node.test k8s.io/kubernetes/test/e2e_node
|
We're also having this issue when cross-compiling the Grafana Agent on ARMv6/ARMv7. I've posted some details on #58428 |
@golang/compiler |
I'll take a look. |
I bisected to 833367e:
Notes:
Reproducer: # checkout of https://github.com/golang/go
pushd go
git checkout 833367e98af838a2511ee7e4e19dc8f1da7b8ed7
git cherry-pick 00bee6d9a4c3ed6168350fc6551043ff7a1895f2
pushd src
./make.bash
popd
popd
export GOROOT=$PWD/go
export GOPATH=$PWD/emptydir
export PATH=$PWD/go/bin:$PATH
# checkout of https://github.com/kubernetes/kubernetes/
pushd kubernetes
git checkout b7ad17978eaba508c560f81bab2fb9d0b256e469
GOARCH=arm CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc go test -c k8s.io/kubernetes/test/e2e_node
popd Output is:
That commit defaulted |
Building go1.19.5 with |
cc @mdempsky |
until this issue is fixed, I was able to build with |
@liggitt thanks for the bisect. In this case my guess would be that the bug is not actually due to the introduction of unified IR, but rather that the switch to unified IR makes the binary in question a bit bigger, which triggers the need for trampoline insertion. I am testing a CL with a fix, I'll post it shortly. |
Change https://go.dev/cl/467715 mentions this issue: |
@liggitt if you are able to test with my CL to see if the tests run cleanly on ARM that would be great. I verified that with the CL I can link the |
I don't actually have an arm test machine, all I could do was reproduce / verify the cross-compile/link worked. I'll see if I can track down an env to run the resulting binary. I'd be curious if the CL also resolves #58428 ... the reporters of that issue might have an env to exercise their resulting binary as well |
OK thanks. Yes, I verified that the fix also takes care of #58428. I am planning on duping that bug against this one. I'll on that issue about testing. |
This reverts commit 8a7ed5c.
👋 We've tested your CL against the resulting binary for #58428 and verified that everything still works. Thank you! |
Thanks for the quick turnaround. Could this be backported to 1.20, since it resolves a compiler issue that doesn't have a workaround (#58428)? |
I will indeed look into backports. |
Hmm, |
We can still apply the previous fix. Sometimes the C linker just doesn't like the large text sections, even if we got the trampolines set up already. So splitting the text section may still be a good thing to do. |
I spent a little while debugging this using grafana-agent, e.g.
The error I get is a little different from the one reported in 58425#issuecomment-1464832903; I get:
Target of the relocation is not a I looked at the relocation in question, and from my calculations the calculated displacement is exactly at the lower limit of the relocation in question (e.g. the minimum value represented by a signed 24-bit quantity, or -0x800000). Source of the relocation (this is from objdump -dr):
and target of the relocation is at 0x0007bc74 with offset of 1740, so this computation here yields exactly -0x800000. Bottom line is that this is a disagreement between the Go linker's calculation of what will reach and the external linker's calculation. For this line here in the Go linker
if I change So although the symptom is the same, this looks like a slightly different bug. |
Also tried the "t <= -0x800000" change and that seems to fix the problem with the Gold linker as well. I will send a CL. |
Change https://go.dev/cl/475957 mentions this issue: |
32-bit ARM builds are broken again (see CI for grafana#3259). This commit temporarily removes support for 32-bit ARM builds so we can keep iterating while we wait for a new Go patch (golang/go#58425) and bring them back. Ideally 32-bit ARM builds are restored prior to releasing v0.33.0.
32-bit ARM builds are broken again (see CI for #3259). This commit temporarily removes support for 32-bit ARM builds so we can keep iterating while we wait for a new Go patch (golang/go#58425) and bring them back. Ideally 32-bit ARM builds are restored prior to releasing v0.33.0.
…ation Tweak the code in trampoline generation that determines if a given call branch will reach, changing the lower limit guard from "x < -0x800000" to "x <= -0x800000". This is to resolve linking failures when the computed displacement is exactly -0x800000, which results in errors of the form .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079 when using the Gold linker, and ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt' when using the bfd linker. Fixes #59034. Updates #58425. Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf Reviewed-on: https://go-review.googlesource.com/c/go/+/475957 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
thanks, can that fix be taken back to 1.19 / 1.20? |
Yes, I've kicked off the process to back-port the second fix (issue to follow is #59034). |
Change https://go.dev/cl/476935 mentions this issue: |
Change https://go.dev/cl/476936 mentions this issue: |
…line reachability computation Tweak the code in trampoline generation that determines if a given call branch will reach, changing the lower limit guard from "x < -0x800000" to "x <= -0x800000". This is to resolve linking failures when the computed displacement is exactly -0x800000, which results in errors of the form .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079 when using the Gold linker, and ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt' when using the bfd linker. Fixes #59059. Updates #59034. Updates #58425. Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf Reviewed-on: https://go-review.googlesource.com/c/go/+/475957 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit f26bf20) Reviewed-on: https://go-review.googlesource.com/c/go/+/476936
…line reachability computation Tweak the code in trampoline generation that determines if a given call branch will reach, changing the lower limit guard from "x < -0x800000" to "x <= -0x800000". This is to resolve linking failures when the computed displacement is exactly -0x800000, which results in errors of the form .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079 when using the Gold linker, and ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt' when using the bfd linker. Fixes #59058. Updates #59034. Updates #58425. Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf Reviewed-on: https://go-review.googlesource.com/c/go/+/475957 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit f26bf20) Reviewed-on: https://go-review.googlesource.com/c/go/+/476935
We just updated to go1.20.3, and our 32-bit ARM builds seem to be working again 🎉 Thanks @thanm! |
@thanm Unfortunately I spoke too soon. grafana/agent#3485 just ran into the issue again after removing some code, with two different errors for two different commands (both ARMv6):
This can be validated by checking out |
Thanks for the update. This bug seems to be the "gift that keeps giving", apparently. I will take another look. |
Hey @thanm, doing a sweep of the Go 1.21 milestone. Any updates here? Should this go to Backlog? Thanks. |
Should still be in 1.21 I think (just got a bit lost in the sauce). I will take another look. |
This strangely started showing up in Grafana. We bisected to a seemingly benign commit, though it is consistently failing in a function in a specific dependency. Based on what I'm seeing in this thread, the dependency is unrelated. We are seeing this on
|
This failure is very sensitive to binary size and and code layout. A seemingly unrelated change may change the code layout just slightly to go over or under the limit. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, by cross compiling kubernetes/kubernetes@b7ad179 to the
linux/arm
platform.What operating system and processor architecture are you using (
go env
)?We build in a custom container image registry.k8s.io/build-image/kube-cross
go env
OutputWhat did you do?
Running
make release
in the root of the Kubernetes repository. Everything gets built successfully, except thek8s.io/kubernetes/test/e2e_node.test
, which fails with:A small patch can be applied to make it fail faster for reproduction:
Setting
CGO_CFLAGS=-mlong-calls
does not help, disabling CGO does provide a workaround.Source code changes seem to have impact on the issue, because the build works with the next commit kubernetes/kubernetes@b0171f7
Ref: kubernetes/kubernetes#115613, kubernetes/kubernetes#115605
What did you expect to see?
That the test binary compiles correctly with CGO enabled.
What did you see instead?
The link failure.
The text was updated successfully, but these errors were encountered: