Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: full go file paths produced in .a and bin files even with -trimpath #21720
What version of Go are you using (
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.
I see the same behavior with Go 1.8.3:
@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
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?
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 <email@example.com> Reviewed-by: Matthew Dempsky <firstname.lastname@example.org> Reviewed-on: https://go-review.googlesource.com/70975 Run-TryBot: Russ Cox <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>