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/go: asmflags/gcflags trimpath ignored for standard library #29066

Closed
rittneje opened this issue Dec 2, 2018 · 1 comment
Closed

cmd/go: asmflags/gcflags trimpath ignored for standard library #29066

rittneje opened this issue Dec 2, 2018 · 1 comment

Comments

@rittneje
Copy link

rittneje commented Dec 2, 2018

What version of Go are you using (go version)?

$ go version
go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build591071936=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I recompiled the standard library with the intention of stripping out GOROOT from the paths.

go install -a -asmflags="all=-trimpath=$GOROOT/src" -gcflags="all=-trimpath=$GOROOT/src" std

I then built a sample binary (just a simple "hello world" program) against this new standard library, and ran strings on the resulting binary.

What did you expect to see?

I expected to see the trimmed version of all standard library paths (e.g., "fmt/print.go" instead of "/usr/local/go/src/fmt/print.go").

What did you see instead?

I see the untrimmed paths. This is a regression from 1.8, where doing the following results in a properly trimmed binary.

go install -a -asmflags="-trimpath=$GOROOT/src" -gcflags="-trimpath=$GOROOT/src" std

Curiously, this only appears to be an issue for the standard library. Trimming $GOPATH/src from my packages works as expected. I'm not sure where these strings are coming from, as everything in $GOROOT/pkg appears to be properly trimmed.

@bcmills
Copy link
Contributor

bcmills commented Dec 19, 2018

Per #22382 (comment):

Users should not be using -trimpath. The general problem here is #16860.

As such, closing as a duplicate of #16860.

@bcmills bcmills closed this as completed Dec 19, 2018
@golang golang locked and limited conversation to collaborators Dec 19, 2019
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

3 participants