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: external linking fails with -s on darwin #10254

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

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

chai2010 opened this issue Mar 26, 2015 · 7 comments
Milestone

Comments

@chai2010
Copy link
Contributor

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
@chai2010
Copy link
Contributor Author

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

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

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

@minux
Copy link
Member

minux commented Mar 27, 2015 via email

@alexbrainman
Copy link
Member

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 kythe/kythe that referenced this issue Jun 4, 2015
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
@rsc
Copy link
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 cmd/ld: external linking fails with -s on windows and darwin cmd/ld: if -s is given, pass to external linker Jun 8, 2015
@rsc rsc changed the title cmd/ld: if -s is given, pass to external linker cmd/link: if -s is given, pass to external linker Jun 8, 2015
@gopherbot
Copy link

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

alexbrainman added a commit that referenced this issue Jun 10, 2015
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 cmd/link: if -s is given, pass to external linker cmd/link: external linking fails with -s on darwin Jun 10, 2015
@gopherbot
Copy link

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

@rsc rsc closed this as completed in 34846ae Jun 29, 2015
@golang golang 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.
Projects
None yet
Development

No branches or pull requests

5 participants