Skip to content

Commit 9bec49c

Browse files
committed
[release-branch.go1.21] cmd/link: disable DWARF by default in c-shared 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 <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 3ef4f93 commit 9bec49c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ func Main(arch *sys.Arch, theArch Arch) {
197197

198198
checkStrictDups = *FlagStrictDups
199199

200+
if ctxt.IsDarwin() && ctxt.BuildMode == BuildModeCShared {
201+
*FlagW = true // default to -w in c-shared mode on darwin, see #61229
202+
}
203+
200204
if !buildcfg.Experiment.RegabiWrappers {
201205
abiInternalVer = 0
202206
}

0 commit comments

Comments
 (0)