Skip to content
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: issues with Apple's new linker in Xcode 15 beta [1.21 backport] #62598

Closed
gopherbot opened this issue Sep 12, 2023 · 7 comments
Closed
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@gopherbot
Copy link

@cherrymui requested issue #61229 to be considered for backport to the next 1.21 minor release.

@gopherbot please backport this to Go 1.20 and 1.21 releases. I'll fill in the details in the corresponding issues. Thanks.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Sep 12, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 12, 2023
@gopherbot gopherbot added this to the Go1.21.2 milestone Sep 12, 2023
@cherrymui
Copy link
Member

cherrymui commented Sep 12, 2023

Xcode 15 (to be released some time soon) will include Apple's new linker, enabled by default. Go 1.21 already includes some fixes/workarounds, so it mostly runs okay with new Apple linker. But it is not complete. There are a few more fixes/workarounds included in tip but not in Go 1.21. A major failure is plugin mode doesn't work. There are two options to fix plugin:

  1. backport workaround CLs, which include CL https://go.dev/cl/503538 , https://go.dev/cl/503935 (both are required for correctness)
  2. force the old Apple linker in plugin mode

I prefer option 2, which is safer and simpler. It is very likely that the old Apple linker will be around for long enough time to cover the lifetime of Go 1.21. If it turns out not true, we can include other fixes/workarounds later.

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 also want to backport CL https://go.dev/cl/508696, which suppresses a warning.

Specifically, CLs to be included in Go 1.21 branch:

@gopherbot
Copy link
Author

Change https://go.dev/cl/527816 mentions this issue: [release-branch.go1.21] cmd/link: disable DWARF by default in c-shared mode on darwin

@gopherbot
Copy link
Author

Change https://go.dev/cl/527815 mentions this issue: [release-branch.go1.21] cmd/link: force old Apple linker in plugin mode

@gopherbot
Copy link
Author

Change https://go.dev/cl/527817 mentions this issue: [release-branch.go1.21] cmd/link: suppress -bind_at_load deprecation warning for ld-prime

@joedian joedian added the CherryPickApproved Used during the release process for point releases label Sep 20, 2023
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Sep 20, 2023
gopherbot pushed a commit that referenced this issue Sep 21, 2023
There are some bugs in Apple's new linker that causes plugins to
be built incorrectly. And the bugs probably will not be fixed when
Xcode 15 is released (some time soon). Force old Apple linker to
work around.

Updates #61229.
For #62598.

Change-Id: I01ba5caadec6dc14f8c85dd02f78c1ed2e8b7d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527815
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
gopherbot pushed a commit that referenced this issue Sep 21, 2023
…d mode on darwin

[This is a (manual) backport of CL 527415 to Go 1.21.]

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 #62598.

Change-Id: I525987b7fe1a4e64571327cb4696f98cc7b419a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/527816
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@gopherbot
Copy link
Author

Closed by merging 9bec49c to release-branch.go1.21.

@gopherbot
Copy link
Author

Closed by merging fc57cc3 to release-branch.go1.21.

@gopherbot
Copy link
Author

Closed by merging 3ef4f93 to release-branch.go1.21.

gopherbot pushed a commit that referenced this issue Sep 21, 2023
…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 #62598.

Change-Id: I4b8a6f864a460c40dc38adbb533f664f7fd5343c
Reviewed-on: https://go-review.googlesource.com/c/go/+/508696
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 040dbf9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/527817
bradfitz pushed a commit to tailscale/go that referenced this issue Sep 25, 2023
There are some bugs in Apple's new linker that causes plugins to
be built incorrectly. And the bugs probably will not be fixed when
Xcode 15 is released (some time soon). Force old Apple linker to
work around.

Updates golang#61229.
For golang#62598.

Change-Id: I01ba5caadec6dc14f8c85dd02f78c1ed2e8b7d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527815
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
bradfitz pushed a commit to tailscale/go that referenced this issue Sep 25, 2023
…d mode on darwin

[This is a (manual) backport of CL 527415 to Go 1.21.]

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 golang#62577). For now, disable DWARF by default in c-shared mode
on darwin.

Updates golang#61229.
For golang#62598.

Change-Id: I525987b7fe1a4e64571327cb4696f98cc7b419a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/527816
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
bradfitz pushed a commit to tailscale/go that referenced this issue Sep 25, 2023
…warning for ld-prime

ld-prime emits a deprecation warning for -bind_at_load. The flag
is needed for plugins to not deadlock (golang#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 golang#61229.
For golang#62598.

Change-Id: I4b8a6f864a460c40dc38adbb533f664f7fd5343c
Reviewed-on: https://go-review.googlesource.com/c/go/+/508696
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 040dbf9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/527817
awly pushed a commit to tailscale/go that referenced this issue Feb 7, 2024
There are some bugs in Apple's new linker that causes plugins to
be built incorrectly. And the bugs probably will not be fixed when
Xcode 15 is released (some time soon). Force old Apple linker to
work around.

Updates golang#61229.
For golang#62598.

Change-Id: I01ba5caadec6dc14f8c85dd02f78c1ed2e8b7d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527815
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
JanDeDobbeleer pushed a commit to JanDeDobbeleer/go that referenced this issue Feb 12, 2024
There are some bugs in Apple's new linker that causes plugins to
be built incorrectly. And the bugs probably will not be fixed when
Xcode 15 is released (some time soon). Force old Apple linker to
work around.

Updates golang#61229.
For golang#62598.

Change-Id: I01ba5caadec6dc14f8c85dd02f78c1ed2e8b7d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527815
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

4 participants
@gopherbot @cherrymui @joedian and others