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: trimpath gcflag not trimming anything #30696

Closed
xibz opened this issue Mar 8, 2019 · 5 comments

Comments

Projects
None yet
5 participants
@xibz
Copy link

commented Mar 8, 2019

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

v1.12.0

$ go version

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="/home/xibz/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xibz/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="/home/xibz/firectl/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build920574943=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go build -a -o foo -gcflags=-trimpath=/home/xibz -asmflags=-trimpath=/home/xibz
$ strings foo | grep xibz
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/fold.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/extension.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/encode.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/scanner.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/decode.go

What did you expect to see?

$ strings foo | grep xibz

What did you see instead?

$ strings foo | grep xibz
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/fold.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/extension.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/encode.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/scanner.go
/home/xibz/go/pkg/mod/github.com/globalsign/mgo@v0.0.0-20180905125535-1ca0a4f7cbcb/internal/json/decode.go

@andybons andybons changed the title trimpath not trimming anything go/build: trimpath gcflag not trimming anything Mar 9, 2019

@andybons andybons added this to the Unplanned milestone Mar 9, 2019

@andybons

This comment has been minimized.

Copy link
Member

commented Mar 9, 2019

@ianlancetaylor ianlancetaylor changed the title go/build: trimpath gcflag not trimming anything cmd/go: trimpath gcflag not trimming anything Mar 9, 2019

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 9, 2019

Is there a way that we can recreate what you are seeing?

When I try simple test cases it works as expected for me.

Thanks.

@xibz

This comment has been minimized.

Copy link
Author

commented Mar 9, 2019

@ianlancetaylor - What simple cases are you checking against? I can reproduce this with this code. This occurs when there are dependencies. Otherwise it behaves correctly, unless Im not understanding the flag correctly.

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
)

func main() {
	fmt.Println(aws.String("Hello world!"))
}

I then build it like so
go build -a -o main -gcflags=-trimpath=/home/xibz -asmflags=-trimpath=/home/xibz main.go

/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/errors.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/endpoints/endpoints.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/internal/ini/ini_parser.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/internal/ini/empty_token.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/internal/ini/literal_tokens.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/internal/ini/ini_lexer.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/internal/ini/ast.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/awserr/types.go
/home/xibz/go/src/github.com/aws/aws-sdk-go/aws/awserr/error.go
@AlexRouSg

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

Try go build -a -o main -gcflags=all=-trimpath=/home/xibz -asmflags=all=-trimpath=/home/xibz main.go

@xibz

This comment has been minimized.

Copy link
Author

commented Mar 10, 2019

@AlexRouSg - That did it! Thanks :). Closing

@xibz xibz closed this Mar 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.