cmd/link: issues with Apple's new linker in Xcode 15 beta [1.20 backport] #62597
Xcode 15 (to be released some time soon) will include Apple's new linker, enabled by default. There are a number of issues with running Go 1.20 with the new Apple linker, from linker warnings to program fail to run. There are a number of fixes/workarounds included in Go 1.21 and tip, but I think they are too many to backport. So for 1.20, I propose we force to use the old Apple linker. I'm pretty sure the old Apple linker will be around for long enough time to cover the lifetime of Go 1.20.
We also want to backport CL https://go.dev/cl/527415, to disable DWARF by default for c-shared mode (otherwise the new Apple linker doesn't accept the c-shared object). We need this because the user may link the c-shared object with C code without going through the Go toolchain, so can't force old linker for this.
We also want to backport CL https://go.dev/cl/508696, which suppresses a warning. Apparently, although the old linker doesn't emit the warning and we pass a flag to force the old linker, it still emits the warning, probably because the new linker parses flags before exec'ing the old linker.
Specifically, CLs to be included in Go 1.20 branch:
There are some bugs in Apple's new linker that probably will not be fixed when Xcode 15 is released (some time soon). We fix/work around them but it is too much to backport them all. Force old Apple linker to work around. Updates #61229. For #62597. Change-Id: Ia5941918e882b22b4dbc41c74764d19d413d0b56 Reviewed-on: https://go-review.googlesource.com/c/go/+/527818 Run-TryBot: Cherry Mui <email@example.com> TryBot-Result: Gopher Robot <firstname.lastname@example.org> Reviewed-by: Than McIntosh <email@example.com>
…d mode on darwin [This is a (manual) backport of CL 527415 to Go 1.20.] Currently, linking a Go c-shared object with C code using Apple's new linker, it fails with % cc a.c go.so ld: segment '__DWARF' filesize exceeds vmsize in 'go.so' Apple's new linker has more checks for unmapped segments. It is very hard to make it accept a Mach-O shared object with an additional DWARF segment. We may want to stop combinding DWARF into the shared object (see also #62577). For now, disable DWARF by default in c-shared mode on darwin. Updates #61229. For #62597. Change-Id: I313349f71296d6d7025db28469593825ce9f1866 Reviewed-on: https://go-review.googlesource.com/c/go/+/527819 TryBot-Result: Gopher Robot <firstname.lastname@example.org> Reviewed-by: Than McIntosh <email@example.com> Run-TryBot: Cherry Mui <firstname.lastname@example.org>
…warning for ld-prime ld-prime emits a deprecation warning for -bind_at_load. The flag is needed for plugins to not deadlock (#38824) when linking with older darwin linker. It is supposedly not needed with newer linker when chained fixups are used. For now, we always pass it, and suppress the warning. Updates #61229. For #62597. Change-Id: I4b8a6f864a460c40dc38adbb533f664f7fd5343c Reviewed-on: https://go-review.googlesource.com/c/go/+/508696 Reviewed-by: Than McIntosh <email@example.com> TryBot-Result: Gopher Robot <firstname.lastname@example.org> Run-TryBot: Cherry Mui <email@example.com> (cherry picked from commit 040dbf9) Reviewed-on: https://go-review.googlesource.com/c/go/+/527798
The next Go 1.20.9 release will likely be available next week.
In the mean time, you can build Go from source using the