From 96e35aa7f565fcb099981f3237a77b392f50c75c Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 19 Aug 2020 09:40:21 +0200 Subject: [PATCH] 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.) --- build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.go b/build.go index 36a848e92..49f229827 100644 --- a/build.go +++ b/build.go @@ -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...) }