From cadedeb26b0b033cb0c9af19c6daa0818a1e7e67 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 23 Feb 2017 11:59:32 +0100 Subject: [PATCH] trim gopath for cleaner stack trace --- tools/build/go.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/build/go.go b/tools/build/go.go index 9722a15b..b45f401d 100644 --- a/tools/build/go.go +++ b/tools/build/go.go @@ -8,13 +8,22 @@ import ( ) func buildV2Ray(targetFile string, version string, goOS GoOS, goArch GoArch) error { + goPath := os.Getenv("GOPATH") ldFlags := "-s" if version != "custom" { year, month, day := time.Now().UTC().Date() today := fmt.Sprintf("%04d%02d%02d", year, int(month), day) ldFlags = ldFlags + " -X v2ray.com/core.version=" + version + " -X v2ray.com/core.build=" + today } - cmd := exec.Command("go", "build", "-tags", "json", "-o", targetFile, "-compiler", "gc", "-ldflags", ldFlags, "v2ray.com/core/main") + cmd := exec.Command( + "go", "build", + "-tags", "json", + "-o", targetFile, + "-compiler", "gc", + "-ldflags", ldFlags, + "-gcflags", "-trimpath="+goPath, + "-asmflags", "-trimpath="+goPath, + "v2ray.com/core/main") cmd.Env = append(cmd.Env, "GOOS="+string(goOS), "GOARCH="+string(goArch), "CGO_ENABLED=0") cmd.Env = append(cmd.Env, os.Environ()...) output, err := cmd.CombinedOutput()