]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[release-branch.go1.20] cmd/link: disable DWARF by default in c-shared mode on darwin
authorCherry Mui <cherryyz@google.com>
Tue, 12 Sep 2023 19:42:29 +0000 (15:42 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 21 Sep 2023 22:20:27 +0000 (22:20 +0000)
[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 <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

src/cmd/link/internal/ld/main.go

index 0058bd4d3e2e04e3c668c5f4f599738edee5b42d..34411d79110d6cfbc7c397428b9a6bb397f82387 100644 (file)
@@ -185,6 +185,10 @@ func Main(arch *sys.Arch, theArch Arch) {
 
        checkStrictDups = *FlagStrictDups
 
+       if ctxt.IsDarwin() && ctxt.BuildMode == BuildModeCShared {
+               *FlagW = true // default to -w in c-shared mode on darwin, see #61229
+       }
+
        if !buildcfg.Experiment.RegabiWrappers {
                abiInternalVer = 0
        }