]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't modify input slice in gccSupportsFlag
authorIan Lance Taylor <iant@golang.org>
Fri, 29 Sep 2017 18:10:20 +0000 (11:10 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 29 Sep 2017 18:54:12 +0000 (18:54 +0000)
Modifying the input slice broke the new test for whether gccgo
supports -fgo-importcfg, as the test passed a slice of the argument
slice it was in the process of building.

Fixes #22089

Change-Id: I45444a82673223c46be0c8579da3e31a74c32d73
Reviewed-on: https://go-review.googlesource.com/67191
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/internal/work/build.go

index ce5c71ae5a31c5425de3b26c599c593237b61c27..05488400878f6ca1969b501a17dac1d850d142b8 100644 (file)
@@ -3333,7 +3333,8 @@ func (b *Builder) gccSupportsFlag(compiler []string, flag string) bool {
                }
                b.flagCache = make(map[[2]string]bool)
        }
-       cmdArgs := append(compiler, flag, "-c", "trivial.c")
+       cmdArgs := append([]string(nil), compiler...)
+       cmdArgs = append(cmdArgs, flag, "-c", "trivial.c")
        if cfg.BuildN || cfg.BuildX {
                b.Showcmd(b.WorkDir, "%s", joinUnambiguously(cmdArgs))
                if cfg.BuildN {