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 build flag has no effect in gccgo #32162

Open
cespare opened this issue May 21, 2019 · 2 comments

Comments

Projects
None yet
4 participants
@cespare
Copy link
Contributor

commented May 21, 2019

Go 1.13 is adding a new -trimpath flag (see 7469564).

The documentation says

        -trimpath
                remove all file system paths from the resulting executable.
                Instead of absolute file system paths, the recorded file names
                will begin with either "go" (for the standard library),
                or a module path@version (when using modules),
                or a plain import path (when using GOPATH).

This works with gc, but the flag has no effect in gccgo. Demo:

$ mkdir /tmp/xyz123
$ cd /tmp/xyz123/
$ cat > hello.go
package main
func main() { println("hello") }
$ out=gc.out && gotip clean -cache && gotip build -o $out hello.go && strings $out | grep xyz123 | head -3
/tmp/xyz123/hello.go
$ out=gc.trimpath.out && gotip clean -cache && gotip build -trimpath -o $out hello.go && strings $out | grep xyz123 | head -3
$ out=gccgo.out && gotip clean -cache && gotip build -compiler gccgo -o $out hello.go && strings $out | grep xyz123 | head -3
/tmp/xyz123
/tmp/xyz123/hello.go
GNU Go 8.3.0 -m64 -mtune=generic -march=x86-64 -g -fgo-relative-import-path=_/tmp/xyz123
$ out=gccgo.trimpath.out && gotip clean -cache && gotip build -trimpath -compiler gccgo -o $out hello.go && strings $out | grep xyz123 | head -3
/tmp/xyz123
/tmp/xyz123/hello.go
GNU Go 8.3.0 -m64 -mtune=generic -march=x86-64 -g -fgo-relative-import-path=_/tmp/xyz123
$ diff gccgo.out gccgo.trimpath.out

(This came up in CL 176112.)

Here are some things we could do to improve the situation:

  • Hook up -trimpath to the appropriate gcc flags so that the option works as advertised (if that's possible).
  • Reject -trimpath if it's being used with a compiler where that isn't implemented.
  • Document that -trimpath only works with gc.

Marking for 1.13 since this is a new feature and we should at least document the interaction.

@cespare cespare added this to the Go1.13 milestone May 21, 2019

@cespare

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2019

The GCC/LLVM option to use to implement -trimpath is -ffile-prefix-map, which implies -fdebug-prefix-map and -fmacro-prefix-map. See https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html. This was added to LLVM in mid-2018 (https://reviews.llvm.org/D49466).

@bcmills bcmills added the NeedsFix label Jun 4, 2019

@gopherbot gopherbot removed the NeedsDecision label Jun 4, 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.