aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2023-09-12 15:42:29 -0400
committerCherry Mui <cherryyz@google.com>2023-09-21 22:20:27 +0000
commit08c544db98da4292edfc5da7ceca17808fd41168 (patch)
treec11ee3b0c2d4bcfe089c913f4ff577825f444050
parent071f03a8e59fc404a823e547fa566983c60f1f07 (diff)
downloadgo-08c544db98da4292edfc5da7ceca17808fd41168.tar.gz
go-08c544db98da4292edfc5da7ceca17808fd41168.zip
[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 <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
-rw-r--r--src/cmd/link/internal/ld/main.go4
1 files changed, 4 insertions, 0 deletions
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
}