build: Add -trimpath compiler option (#6904)

Quoting the manual:

    -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).

That is, when we panic, instead of:

    goroutine 1 [running]:
    main.main()
        /Users/jb/dev/syncthing/syncthing/cmd/syncthing/main.go:272 +0x116

we get:

    goroutine 1 [running]:
    main.main()
        github.com/syncthing/syncthing@/cmd/syncthing/main.go:272 +0x116

(Module path and file path within module.)
This commit is contained in:
Jakob Borg 2020-08-19 09:40:21 +02:00 committed by GitHub
parent 086d1f8f6a
commit 96e35aa7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,7 +465,7 @@ func install(target target, tags []string) {
defer shouldCleanupSyso(sysoPath)
}
args := []string{"install", "-v"}
args := []string{"install", "-v", "-trimpath"}
args = appendParameters(args, tags, target.buildPkgs...)
runPrint(goCmd, args...)
}
@ -493,7 +493,7 @@ func build(target target, tags []string) {
defer shouldCleanupSyso(sysoPath)
}
args := []string{"build", "-v"}
args := []string{"build", "-v", "-trimpath"}
args = appendParameters(args, tags, target.buildPkgs...)
runPrint(goCmd, args...)
}