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

Closed
cespare opened this issue May 21, 2019 · 5 comments
Closed

cmd/go: -trimpath build flag has no effect in gccgo #32162

cespare opened this issue May 21, 2019 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cespare
Copy link
Contributor

cespare 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
Copy link
Contributor Author

cespare commented May 21, 2019

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels May 21, 2019
@bcmills bcmills added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label May 29, 2019
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 29, 2019
@rsc
Copy link
Contributor

rsc 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 The path to resolution is known, but the work has not been done. label Jun 4, 2019
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jun 4, 2019
@bcmills bcmills self-assigned this Jun 28, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 16, 2019
@cespare
Copy link
Contributor Author

cespare commented Jul 31, 2019

@bcmills should we document that -trimpath only works with gc for 1.13?

@ianlancetaylor
Copy link
Contributor

https://golang.org/cl/187824, which is out for review for 1.13, will affect this.

@gopherbot
Copy link

Change https://golang.org/cl/196023 mentions this issue: cmd/go: support -trimpath with gccgo

@golang golang locked and limited conversation to collaborators Sep 17, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants