From 08c544db98da4292edfc5da7ceca17808fd41168 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 12 Sep 2023 15:42:29 -0400 Subject: [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 Reviewed-by: Than McIntosh Run-TryBot: Cherry Mui --- src/cmd/link/internal/ld/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index 0058bd4d3e..34411d7911 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -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 } -- cgit v1.2.3-54-g00ecf