Skip to content

Commit 08c544d

Browse files
committed
[release-branch.go1.20] cmd/link: disable DWARF by default in c-shared 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 <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Run-TryBot: Cherry Mui <[email protected]>
1 parent 071f03a commit 08c544d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ func Main(arch *sys.Arch, theArch Arch) {
185185

186186
checkStrictDups = *FlagStrictDups
187187

188+
if ctxt.IsDarwin() && ctxt.BuildMode == BuildModeCShared {
189+
*FlagW = true // default to -w in c-shared mode on darwin, see #61229
190+
}
191+
188192
if !buildcfg.Experiment.RegabiWrappers {
189193
abiInternalVer = 0
190194
}

0 commit comments

Comments
 (0)