From 071f03a8e59fc404a823e547fa566983c60f1f07 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 12 Sep 2023 15:40:09 -0400 Subject: [release-branch.go1.20] cmd/link: force old Apple linker in plugin mode 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 TryBot-Result: Gopher Robot Reviewed-by: Than McIntosh --- src/cmd/link/internal/ld/lib.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 03b9f11608..c44983144d 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1367,6 +1367,10 @@ func (ctxt *Link) hostlink() { switch ctxt.HeadType { case objabi.Hdarwin: + if linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,-ld_classic") { + // Force old linker to work around bugs in Apple's new linker. + argv = append(argv, "-Wl,-ld_classic") + } if combineDwarf { // Leave room for DWARF combining. // -headerpad is incompatible with -fembed-bitcode. -- cgit v1.2.3-54-g00ecf