From: Cherry Mui Date: Tue, 12 Sep 2023 19:15:12 +0000 (-0400) Subject: [release-branch.go1.21] cmd/link: force old Apple linker in plugin mode X-Git-Tag: go1.21.2~8 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ef4f939c3b24cddcb917c2d8a3ea7a588deecab;p=gostls13.git [release-branch.go1.21] cmd/link: force old Apple linker in plugin mode 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 TryBot-Result: Gopher Robot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index d9e5774b60..918d4f5f58 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1418,6 +1418,10 @@ func (ctxt *Link) hostlink() { // resolving a lazy binding. See issue 38824. // Force eager resolution to work around. argv = append(argv, "-Wl,-flat_namespace", "-Wl,-bind_at_load") + if linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,-ld_classic") { + // Force old linker to work around a bug in Apple's new linker. + argv = append(argv, "-Wl,-ld_classic") + } } if !combineDwarf { argv = append(argv, "-Wl,-S") // suppress STAB (symbolic debugging) symbols