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/compile: link fails when function containing linknamed symbol is inlined (-l=4) #18167

Closed
davidlazar opened this issue Dec 2, 2016 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@davidlazar
Copy link
Member

The net/http tests fail with -l=4:

$ go version
go version devel +5c9035a Fri Dec 2 19:19:03 2016 +0000 linux/amd64

$ cd $GOROOT/src/net/http
$ go test -a -gcflags '-l=4' -v .                         
# testmain
net/http.(*http2Transport).RoundTripOpt: relocation target net.byteIndex not defined
net/http.(*http2Transport).RoundTripOpt: relocation target net.byteIndex not defined
net/http.(*http2ClientConn).encodeHeaders: relocation target net.byteIndex not defined
net/http.(*http2ClientConn).encodeHeaders: relocation target net.byteIndex not defined
net/http.cleanHost: relocation target net.byteIndex not defined
net/http.cleanHost: relocation target net.byteIndex not defined
...
net/http.cleanHost: undefined: "net.byteIndex"
/home/david/go/pkg/tool/linux_amd64/link: too many errors
FAIL	net/http [build failed]

Let's look at the cleanHost function in net/http/request.go to understand what's happening. The cleanHost function calls net.JoinHostPort, which is inlined by the compiler. The body of net.JoinHostPort has a call to net.byteIndex which is linknamed in net/parse.go:

//go:linkname byteIndex strings.IndexByte
func byteIndex(s string, c byte) int

The export data used to inline net.JoinHostPort does not include linknames, so the compiler can't find net.byteIndex when it appears in the body of cleanHost after inlining.

One solution is to include linknames in export data.

@davidlazar davidlazar self-assigned this Dec 2, 2016
@gopherbot
Copy link

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

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 6, 2016
@quentinmit quentinmit added this to the Go1.9 milestone Dec 6, 2016
@quentinmit
Copy link
Contributor

This is too late for Go 1.8.

@golang golang locked and limited conversation to collaborators Feb 8, 2018
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