Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: vmsize of __DWARF should not be zero on darwin #21647

Closed
hirochachacha opened this issue Aug 27, 2017 · 3 comments
Closed

cmd/link: vmsize of __DWARF should not be zero on darwin #21647

hirochachacha opened this issue Aug 27, 2017 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

Re-enable plugin mode for darwin/amd64.

diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 9a1204866e..705509de27 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -358,6 +358,8 @@ func BuildModeInit() {
 			switch platform {
 			case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x",
 				"android/amd64", "android/arm", "android/arm64", "android/386":
+			case "darwin/amd64":
+				// cfg.BuildLdflags = append(cfg.BuildLdflags, "-w")
 			default:
 				base.Fatalf("-buildmode=plugin not supported on %s\n", platform)
 			}

Then try the trivial example in https://golang.org/pkg/plugin/

What did you expect to see?

success.

What did you see instead?

panic: plugin.Open: dlopen(/Users/hiro/plugin.so, 10): no suitable image found.  Did find:
	/Users/hiro/plugin.so: malformed mach-o image: segment __DWARF has vmsize < filesize
	/Users/hiro/plugin.so: malformed mach-o image: segment __DWARF has vmsize < filesize

goroutine 1 [running]:
main.main()
	/Users/hiro/p.go:8 +0x3a9

Does this issue reproduce with the latest release (go1.9)?

System details

go version devel +b046878018 Sat Aug 26 15:55:04 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build397205854=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version devel +b046878018 Sat Aug 26 15:55:04 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +b046878018 Sat Aug 26 15:55:04 2017 +0000
uname -v: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29
lldb --version: lldb-370.0.42
  Swift-3.1
gdb --version: GNU gdb (GDB) 8.0

I'm going to skip DWARF generation now.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/59372 mentions this issue: cmd/go: re-enable buildmode=plugin on darwin/amd64

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 30, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 30, 2018
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/182959 mentions this issue: cmd/go: remove -w workaround for buildmode=plugin on Darwin

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/206198 mentions this issue: cmd/go: remove -w workaround for -buildmode=plugin on Darwin

gopherbot pushed a commit that referenced this issue Nov 11, 2019
Assorted fixups in the linker needed to enable turning back on
DWARF generation when building plugins for Darwin. Includes:

 - don't suppress import of runtime/cgo in the linker for
   Darwin if we are linking in plugin mode

 - in calcCompUnitRanges handle the case where we encounter
   linker-generated functions that have no associated Unit (and
   also have no DWARF)

 - generalize a guard in relocsym() include so as to avoid
   triggering a spurious error on go.info symbols in plugin mode

Updates #21647.
Updates #27502.

Change-Id: I317fea97bef2f3461e31498e63f9fd6d8b8f4b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/182959
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
@golang golang locked and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants