summaryrefslogtreecommitdiff
path: root/libgo/go/cmd
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-03-15 16:56:24 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-03-15 16:56:24 +0000
commit8bb2726d08ae3dd89c7085a7972b5a144ccea270 (patch)
tree48dcbd03a1b072bb15acc6ce494b1c54c6964754 /libgo/go/cmd
parente0c079cba4a2069e4e1337d610542c9fec81f9be (diff)
cmd/go: force LANG=C when looking for compiler version
Tested by installing the gcc-locales package and running LANG=de_DE.utf8 go build hello.go Without this change, that fails, as described at https://gcc.gnu.org/PR84765. Reviewed-on: https://go-review.googlesource.com/100737 From-SVN: r258565
Diffstat (limited to 'libgo/go/cmd')
-rw-r--r--libgo/go/cmd/go/internal/work/buildid.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/libgo/go/cmd/go/internal/work/buildid.go b/libgo/go/cmd/go/internal/work/buildid.go
index e2ae85083d8..a08de26c823 100644
--- a/libgo/go/cmd/go/internal/work/buildid.go
+++ b/libgo/go/cmd/go/internal/work/buildid.go
@@ -234,7 +234,18 @@ func (b *Builder) gccgoToolID(name, language string) (string, error) {
// compile an empty file on standard input.
cmdline := str.StringList(cfg.BuildToolexec, name, "-###", "-x", language, "-c", "-")
cmd := exec.Command(cmdline[0], cmdline[1:]...)
- cmd.Env = base.EnvForDir(cmd.Dir, os.Environ())
+
+ // Strip any LANG or LC_ environment variables, and force
+ // LANG=C, so that we get the untranslated output.
+ var env []string
+ for _, e := range os.Environ() {
+ if !strings.HasPrefix(e, "LANG=") && !strings.HasPrefix(e, "LC_") {
+ env = append(env, e)
+ }
+ }
+ env = append(env, "LANG=C")
+
+ cmd.Env = base.EnvForDir(cmd.Dir, env)
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("%s: %v; output: %q", name, err, out)