From a46ea907053d6ad116e49f76f58b69633c6039d3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Thu, 14 Jul 2016 14:07:18 -0700 Subject: [PATCH] go/build: don't alter InstallSuffix for default compile options Fixes #16378. Change-Id: I99a064f1afec78fb63cb3719061d20be0f21d45d Reviewed-on: https://go-review.googlesource.com/24930 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- misc/cgo/testshared/shared_test.go | 4 ++-- src/cmd/go/build.go | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go index e91af9d8c576c..bb84ef8cabe2a 100644 --- a/misc/cgo/testshared/shared_test.go +++ b/misc/cgo/testshared/shared_test.go @@ -43,7 +43,7 @@ func run(t *testing.T, msg string, args ...string) { } // goCmd invokes the go tool with the installsuffix set up by TestMain. It calls -// t.Errorf if the command fails. +// t.Fatalf if the command fails. func goCmd(t *testing.T, args ...string) { newargs := []string{args[0], "-installsuffix=" + suffix} if testing.Verbose() { @@ -63,7 +63,7 @@ func goCmd(t *testing.T, args ...string) { } if err != nil { if t != nil { - t.Errorf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, output) + t.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, output) } else { log.Fatalf("executing %s failed %v:\n%s", strings.Join(c.Args, " "), err, output) } diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index 75eaec21dad15..088164ba68616 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -431,10 +431,13 @@ func buildModeInit() { buildAsmflags = append(buildAsmflags, codegenArg) buildGcflags = append(buildGcflags, codegenArg) } - if buildContext.InstallSuffix != "" { - buildContext.InstallSuffix += "_" + // Don't alter InstallSuffix when modifying default codegen args. + if buildBuildmode != "default" || buildLinkshared { + if buildContext.InstallSuffix != "" { + buildContext.InstallSuffix += "_" + } + buildContext.InstallSuffix += codegenArg[1:] } - buildContext.InstallSuffix += codegenArg[1:] } }