-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: full go file paths produced in .a and bin files even with -trimpath #21720
Comments
@mholt was looking at the same thing. |
I think using -trimpath in this manner is unsupported anyway. Currently, we only support setting -trimpath once, and cmd/go already sets it when invoking the compiler and assembler. Moreover, I believe it's supported for the purpose of trimming temporary directories that are generated during the build, so that repeat builds that use different temporary directories will still produce the same output. Your intended use case appears to be to hide your $GOPATH directory. I don't think that's a supported use case currently. /cc @rsc for input on whether this is something we want to support. |
Why did Go 1.8 vs Go 1.9 change? I agree that it's not something I intended to support but I'm curious why it stopped "working". |
I see the same behavior with Go 1.8.3:
|
@wak-google I just tested with Go 1.6, Go 1.7, and Go 1.8.3, and they all appear to behave the same as Go 1.9 with regards to "/tmp/my-go-build" appearing in the compiled .a file. Do you mind double checking this? |
@mdempsky My understanding is that all of the strings in the go1.8 case are coming from the c compiler. I forgot to mention in the initial report that I have CGO_CFLAGS="-fdebug-prefix-map=/tmp/my-go-build=/no-such-path". If you set that environment variable or pass the CFLAGS in some other way all references to my-go-build go away in 1.8. In the 1.9 case you still get
|
@wak-google Thanks, I can repro your issue now. I'll figure out what changed. |
Change https://golang.org/cl/63693 mentions this issue: |
@mdempsky @rsc What version of Go are you using (go version)? Does this issue reproduce with the latest release? What operating system and processor architecture are you using (go env)? What did you do? What did you expect to see? goroutine 1 [running]: I also noticed that go is creating a temp directory for build process and the command used to compile the binary starts with /home/dev/Documents/iox/go/pkg/tool/linux_amd64/compile -o $WORK/ioxclient.a -trimpath $WORK -trimpath=/home/dev/Documents/iox/proj/ Is it failing because trimpath can only be used once to remove $WORK? |
Change https://golang.org/cl/70975 mentions this issue: |
The compiler replaces any path of the form /path/to/goroot/src/net/port.go with GOROOT/src/net/port.go so that the same object file is produced if the GOROOT is moved. It was skipping this transformation for any absolute path into the GOROOT that came from //line directives, such as those generated by cmd/cgo. Fixes #21373 Fixes #21720 Fixes #21825 Change-Id: I2784c701b4391cfb92e23efbcb091a84957d61dd Reviewed-on: https://go-review.googlesource.com/63693 Run-TryBot: David Crawshaw <crawshaw@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-on: https://go-review.googlesource.com/70975 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
What version of Go are you using (
go version
)?go1.9
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
set GOPATH=/tmp/my-go-build/go
set CGO_CFLAGS="-fdebug-prefix-map=/tmp/my-go-build=/no-such-path"
go get -d leb.io/hashland
go build "-asmflags" "-trimpath=/tmp/my-go-build" "-gcflags" "-trimpath=/tmp/my-go-build" -v "leb.io/hashland/keccak"
What did you expect to see?
No references to my-go-build. This is the case on go1.8.3 and older
What did you see instead?
This produces a /tmp/my-go-build/go/pkg/linux_amd64/leb.io/hashland/keccak.a that contains a full path reference to /tmp/my-go-build even when the -trimpath flag was specified.
The text was updated successfully, but these errors were encountered: