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

Already on GitHub? Sign in to your account

cmd/link: external linking fails with -s on darwin #10254

Closed
chai2010 opened this Issue Mar 26, 2015 · 7 comments

Comments

Projects
None yet
5 participants
Contributor

chai2010 commented Mar 26, 2015

go version
go version devel +2420926 Wed Mar 25 02:55:56 2015 +0000 windows/amd64

go get -ldflags "-s" github.com/chai2010/protoc
# github.com/chai2010/protoc
panic: runtime error: index out of range

goroutine 1 [running]:
cmd/internal/ld.addpesymtable()
        C:/go/gotip/src/cmd/internal/ld/pe.go:1024 +0x46c
cmd/internal/ld.Asmbpe()
        C:/go/gotip/src/cmd/internal/ld/pe.go:1145 +0x167
main.asmb()
        C:/go/gotip/src/cmd/6l/asm.go:840 +0xde2
cmd/internal/ld.Ldmain()
        C:/go/gotip/src/cmd/internal/ld/pobj.go:207 +0x19a9
main.main()
        C:/go/gotip/src/cmd/6l/obj.go:44 +0x27
Contributor

chai2010 commented Mar 26, 2015

go version
go version go1.4.2 darwin/amd64

go build -ldflags "-s"
# github.com/chai2010/protoc
ld: warning: option -s is obsolete and being ignored
ld: internal error: atom not found in symbolIndex(__ZN6google8protobuf10TextFormat6Parser10ParserImpl11ReportErrorEiiRKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/local/go/pkg/tool/darwin_amd64/6l: running clang++ failed: unsuccessful exit status 0x100

@chai2010 chai2010 referenced this issue in chai2010/protoc Mar 26, 2015

Open

go get -ldflags "-s -w" failed #1

@minux minux changed the title from go get -ldflags "-s" failed with cgo app to cmd/ld: external linking fails with -s on windows and darwin Mar 26, 2015

Member

alexbrainman commented Mar 27, 2015

Even our misc/ccgo/test fails:

C:\>cd %GOROOT%\misc\cgo\test

C:\go\root\misc\cgo\test>go test -ldflags "-s"
# testmain
panic: runtime error: index out of range

goroutine 1 [running]:
cmd/internal/ld.addpesymtable()
        C:/go/root/src/cmd/internal/ld/pe.go:1024 +0x38a
cmd/internal/ld.Asmbpe()
        C:/go/root/src/cmd/internal/ld/pe.go:1145 +0x154
main.asmb()
        C:/go/root/src/cmd/8l/asm.go:728 +0xbec
cmd/internal/ld.Ldmain()
        C:/go/root/src/cmd/internal/ld/pobj.go:207 +0x14e0
main.main()
        C:/go/root/src/cmd/8l/obj.go:44 +0x23
FAIL    _/C_/go/root/misc/cgo/test [build failed]

Alex

Member

minux commented Mar 27, 2015

Member

alexbrainman commented Mar 27, 2015

It is Go linker crashing. It is bug that needs to be fixed.

I don't have computer to confirm, but I suspect it is crashing because we ncoffsym++ in initdynimport. Why do we ncoffsym++ if we don't store symbols into coffsym. ncoffsym will get reset to 0 later on anyway in addpesymtable. I think our logic is flawed.

Alex

@rsc rsc added this to the Go1.5 milestone Apr 10, 2015

zrlk added a commit to google/kythe that referenced this issue Jun 4, 2015

OSX fixes: 6l -s, tell asciidoc which Python to use and where dot is at.
Summary:
On OS X, asciidoc fails to find the executable of the
Python interpreter, leading it to try and execute the
empty string. We can fix this by overriding the
autodetected interpreter with an attribute.

The environment Bazel runs builds in does not include
the path for graphviz on OS X. This CL adds logic to
configure this in setup_bazel.sh.

Finally, there's a Go issue on OS X that we're hitting.
(golang/go#10254). Stop hitting it.

Reviewers: shahms, fromberger, schroederc

Reviewed By: schroederc

Differential Revision: https://phabricator-dot-kythe-repo.appspot.com/D319
Contributor

rsc commented Jun 8, 2015

It sounds like if -s is given but we find ourselves in external linking mode, then we need to remember the -s for invoking the external linker and not treat cmd/link as having the -s anymore.

@rsc rsc changed the title from cmd/ld: external linking fails with -s on windows and darwin to cmd/ld: if -s is given, pass to external linker Jun 8, 2015

@rsc rsc changed the title from cmd/ld: if -s is given, pass to external linker to cmd/link: if -s is given, pass to external linker Jun 8, 2015

CL https://golang.org/cl/10835 mentions this issue.

alexbrainman added a commit that referenced this issue Jun 10, 2015

cmd/link: stop linker crashing with -s flag on windows
Update #10254

Change-Id: I3ddd26607813ca629e3ab62abf87dc5ab453e36f
Reviewed-on: https://go-review.googlesource.com/10835
Reviewed-by: Ian Lance Taylor <iant@golang.org>

@alexbrainman alexbrainman changed the title from cmd/link: if -s is given, pass to external linker to cmd/link: external linking fails with -s on darwin Jun 10, 2015

CL https://golang.org/cl/11695 mentions this issue.

@rsc rsc closed this in 34846ae Jun 29, 2015

@gopherbot gopherbot locked and limited conversation to collaborators Jun 28, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.