-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: ld: B/BL out of range -134840372 (max +/-128MB) from 0x10809F954 #67854
Comments
Hi @cherrymui @randall77 would you help take a look? Thanks! I feel like it's a bug in MacOS linker. We can workaround the issue with -ldflags="-extldflags='-ld64'", however, not sure what the long-term solution is. |
It does not fail for me. What does
The error printed is strange. arm64 has a branch limit of +/- 32MB, not +/- 128MB. Also, the branch is between two locations in the text section, which has presumably already been resolved by the Go linker. The external linker shouldn't have to process any relocations for such a branch. |
Thanks. The link failures were not consistent with low chance to succeed. We could run 'go clean -cache' and reboot the laptop to get a more consistent failure. % /usr/bin/xcodebuild -version % clang --version |
So the failure doesn't happen consistently? That is even more strange. |
Yup, +1 for Go tool consistency. We have different Xcode version though. I wonder if it's using some cached objects or it's a bug in Xcode toolkit instead of Go, but Go triggers it somehow. The behavior is quite consistent if we clean all the cache and reboot the laptop. |
I cannot reproduce this with
It builds successfully for me.
As it works with the old Apple linker, it might be a bug in the new Apple linker. The (ARM64 B/BL instruction branch limit is actually +/- 128MB. It takes 26 bits off offset, adding two 0s at the end, as the an instruction address is always 4-byte aligned.) |
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
I'm also seeing this issue with go 1.22.4 and 1.22.5, xcode 15.3.0.0.1.1708646388, M2
|
@vektah could you share what program you are building? Thanks. |
@d-bytebase Does the issue clear if you rebase your working branch or check out another branch? |
Its when running the test case for an internal service, sorry. |
I encounter this when compiling https://github.com/gravitational/teleport . The behaviour seems a little odd, it'll be fine sometimes but once I've hit the failure, it'll repeat until I reboot. At least a few members of the team here are encountering this. |
Go version
1.22.4
Output of
go env
in your module/workspace:What did you do?
https://github.com/bytebase/bytebase
build command: CGO_ENABLED=1 go build -o ./.air/bytebase ./backend/bin/server/main.go
What did you see happen?
/opt/homebrew/Cellar/go/1.22.4/libexec/pkg/tool/darwin_arm64/link: running cc failed: exit status 1
ld: warning: -bind_at_load is deprecated on macOS
ld: B/BL out of range -134840372 (max +/-128MB) from 0x10809F954 ('_runtime.cmpstring.island' from 'branch-islands-file') to 0x100007920 ('_runtime.cmpstring' from '/private/var/folders/2m/s9rrpxps5rl00_wnvy3b2jd40000gn/T/go-link-1336181017/go.o')
final section layout:
__PAGEZERO addr=0x00000000, size=0x100000000, fileOffset=0x00000000
__TEXT addr=0x100000000, size=0x11640000, fileOffset=0x00000000
__text addr=0x100002ff0, size=0x082b982c, fileOffset=0x00002ff0
__stubs addr=0x1082bc81c, size=0x00000810, fileOffset=0x082bc81c
__rodata addr=0x1082bd040, size=0x0929ddf0, fileOffset=0x082bd040
__cstring addr=0x11155ae30, size=0x000363a7, fileOffset=0x1155ae30
__const addr=0x111591200, size=0x000a71b8, fileOffset=0x11591200
__unwind_info addr=0x1116383b8, size=0x00003d40, fileOffset=0x116383b8
__eh_frame addr=0x11163c0f8, size=0x000000b8, fileOffset=0x1163c0f8
__DATA_CONST addr=0x111640000, size=0x0f640000, fileOffset=0x11640000
__got addr=0x111640000, size=0x00000948, fileOffset=0x11640000
__const addr=0x111640948, size=0x00039678, fileOffset=0x11640948
__cfstring addr=0x111679fc0, size=0x000000e0, fileOffset=0x11679fc0
__rodata addr=0x11167a0a0, size=0x027eb4d0, fileOffset=0x1167a0a0
__typelink addr=0x113e65580, size=0x00050d44, fileOffset=0x13e65580
__itablink addr=0x113eb62e0, size=0x0003a7c8, fileOffset=0x13eb62e0
__gopclntab addr=0x113ef0ac0, size=0x0cd8c250, fileOffset=0x13ef0ac0
__DATA addr=0x120c80000, size=0x011f8000, fileOffset=0x20c80000
__data addr=0x120c80000, size=0x006ad908, fileOffset=0x20c80000
__go_buildinfo addr=0x12132d910, size=0x000069c0, fileOffset=0x2132d910
__noptrdata addr=0x1213342e0, size=0x009145c0, fileOffset=0x213342e0
__thread_vars addr=0x121c488a0, size=0x00000630, fileOffset=0x21c488a0
__thread_ptrs addr=0x121c48ed0, size=0x00000138, fileOffset=0x21c48ed0
__thread_data addr=0x121c49008, size=0x00000108, fileOffset=0x21c49008
__thread_bss addr=0x121c49110, size=0x00000618, fileOffset=0x21c49110
__bss addr=0x121c49740, size=0x0020c74c, fileOffset=0x00000000
__noptrbss addr=0x121e55ea0, size=0x000201b0, fileOffset=0x00000000
__common addr=0x121e76050, size=0x00000070, fileOffset=0x00000000
__LINKEDIT addr=0x121e78000, size=0x0db24000, fileOffset=0x21c4c000
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What did you expect to see?
build success. I think this is MacOS only issue related to linker and starting since 1.22.
related issue: #66993
The text was updated successfully, but these errors were encountered: