Skip to content

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

Closed
@rittneje

Description

@rittneje

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions