aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2023-09-12 15:27:23 -0400
committerCherry Mui <cherryyz@google.com>2023-09-21 22:21:24 +0000
commit9bec49cf52a6f729ec1f9cfb4aca53eb4ff30833 (patch)
tree47ac3d693bb1aeb35dff02b42ef3372ee5aca966
parent3ef4f939c3b24cddcb917c2d8a3ea7a588deecab (diff)
downloadgo-9bec49cf52a6f729ec1f9cfb4aca53eb4ff30833.tar.gz
go-9bec49cf52a6f729ec1f9cfb4aca53eb4ff30833.zip
[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 <thanm@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-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 7743562909..bedc15a847 100644
--- a/src/cmd/link/internal/ld/main.go
+++ b/src/cmd/link/internal/ld/main.go
@@ -197,6 +197,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
}