-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: issues with Apple's new linker in Xcode 15 #61229
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
Comments
I also have an ld assertion failure (reported to Apple as FB12550006):
|
@ismail Thanks for the report. The CL stack mentioned above (https://golang.org/cl/505415 and dependencies) also avoids the assertion failure. |
Change https://go.dev/cl/503935 mentions this issue: |
Change https://go.dev/cl/503538 mentions this issue: |
Change https://go.dev/cl/502616 mentions this issue: |
Change https://go.dev/cl/502617 mentions this issue: |
Change https://go.dev/cl/503539 mentions this issue: |
Change https://go.dev/cl/505415 mentions this issue: |
Change https://go.dev/cl/508696 mentions this issue: |
Change https://go.dev/cl/508697 mentions this issue: |
Another failure mode: (AMD64 Mac only, not ARM64) as of Xcode 15 beta 4 (
And the CLs above are not enough to fix it. I'm looking into it. (PIE binaries are fine. Also fine on ARM64 as it is always PIE.) |
I am on # golang.org/x/tools/cmd/goimports
ld: warning: '/private/var/folders/jc/lq1rvy214tq4643flbh887xr0000gn/T/go-link-1689581912/go.o' has malformed LC_DYSYMTAB, expected 75 undefined symbols to start at index 6656, found 84 undefined symbols starting at index 53 |
Change https://go.dev/cl/461697 mentions this issue: |
Change https://go.dev/cl/511355 mentions this issue: |
@piusalfred that is just a warning, not an error. You should still get a binary. Does the binary run? If not, see #61190, and post on that issue if you have any update. Thanks! |
The non-PIE binary crash (#61229 (comment)) is due to ld-prime silently ignores -no_pie flag and generates a PIE binary instead. But that doesn't work because in exe buildmode we assumed the binary is not relocated and so generated non-relocated addresses, which would not be correct if the binary is actually relocated. The CLs above handle it: 1. switch to PIE by default, 2. force ld64 in exe buildmode. (#61190 is not this. Still need to investigate.) |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
I resolved it by disabling cgo.
|
I wouldn't agree it's a different problem. GoLand, or any other app, that sees things on |
@cherrymui is it possible the .set directives now being used https://github.com/llvm/llvm-project/blame/main/compiler-rt/lib/sanitizer_common/sanitizer_redefine_builtins.h#L20-L22 fix the issue? If so, would it be possible to update the syso files race uses? They're two years old at this point so it seems like this isn't really a common operation. Forgive me if I'm misunderstanding how the internal mechanics of utilizing TSAN works. |
I tried that a while ago and it appears that changing to .set doesn't help. The warning is still there. We'll need to think more on what the solution is. |
Then maybe the issue could be re-opened and updated? Started seeing |
Removed "beta." The output binary is not malformed and is correct. |
Yes, it works great for me. It caused some other problems due to 1.24's But – why are those warnings visible at all? Normally, |
Is it still the case for 1.24? |
Yes. Edited to "Go 1.22.x or newer" |
These warnings are from the Apple C linker, not the Go linker. In general it is possible that the C linker warns on some other user C object file, not necessarily the race detector one. I guess it is possible to parse the warning and the object file it warns on and see if it is the race detector one and hide that one if so. Not sure if this is really a good idea. That said, if it doesn't work well with |
No-no, it works fine. It is just that my Thank you so much for your answers! |
FYI: Still occurs while using 1.24.1. |
Seen on |
NOTE -- please read
If you see lines starting with
ld: warning
but not other outputs, they are just warnings, not errors. You should still get a working binary, if there is no other output. Please only report if you see a link error, or a broken binary, or a warning that is not mentioned in the "warnings" section below. Thanks.See #61229 (comment) for more notes about
malformed LC_DYSYMTAB
warning. Thanks.In Xcode 15 beta it comes with Apple's new linker, ld-prime. As of beta 3 it is enabled by default. I did some experiments and found some issues for Go (cgo) with the new Apple linker. Some of the issues are reported in #61190. I'm filing a new issue to track all related faulures.
warnings
Apparently the new linker is more picky. It issues some warnings that the old linker (ld64) doesn't. This includes
These are just warnings and don't affect the correctness of the build. I'm preparing CLs for fix/work around them.
offset/addend being dropped
Mostly for c-archive, c-shared, and plugin build mode, for some relocations it seems the offset/addend being dropped and the relocation is resolved to the beginning of the section. This may cause failures like SIGILL. E.g.
#60694 is the same failure mode.
debug info issues
The new linker doesn't generate stab symbols for our functions, causing debug info being lost. Failure look like
There is also issues with combining DWARF into executable/shared object. Currently it is affecting c-shared build mode. ld-prime rejects the shared object if we add a DWARF segment to it.
non-PIE build doesn't work (Intel Mac only)
The new linker silently ignores the -no_pie flag and generates a PIE binary, which won't work because we assumed some addresses are not relocated. CL https://go.dev/cl/461697 changes the default to PIE and CL https://go.dev/cl/511355 contains a workaround if we are asked to build a non-PIE binary.
fixes/workarounds
CL https://golang.org/cl/505415 and the stack, as well as other CLs linked in this issue, contain tentative fixes and workarounds that address some of the issues. I'll also work with Apple to have them addressed on their side.
I'm hoping o have them addressed before Apple's new linker is finally released.
The text was updated successfully, but these errors were encountered: