Skip to content

Commit c1fe637

Browse files
jokemanfirematloob
jokemanfire
authored andcommitted
cmd/go: set environment LANG=C when getting compiler version
Compiler's version will not work well if gcc output have different language. Like 'gcc -v', it may not output: 'gcc version xx.xx.x' Fixes #69221 Change-Id: I4adcea79dfaaf5853dfb6e718468f8530c67da6a GitHub-Last-Rev: 069787c GitHub-Pull-Request: #69223 Reviewed-on: https://go-review.googlesource.com/c/go/+/610215 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: DING HU <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 30f3931 commit c1fe637

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cmd/go/internal/work/init.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ func compilerVersion() (version, error) {
357357
compiler.err = func() error {
358358
compiler.name = "unknown"
359359
cc := os.Getenv("CC")
360-
out, err := exec.Command(cc, "--version").Output()
360+
cmd := exec.Command(cc, "--version")
361+
cmd.Env = append(cmd.Environ(), "LANG=C")
362+
out, err := cmd.Output()
361363
if err != nil {
362364
// Compiler does not support "--version" flag: not Clang or GCC.
363365
return err
@@ -366,7 +368,9 @@ func compilerVersion() (version, error) {
366368
var match [][]byte
367369
if bytes.HasPrefix(out, []byte("gcc")) {
368370
compiler.name = "gcc"
369-
out, err := exec.Command(cc, "-v").CombinedOutput()
371+
cmd := exec.Command(cc, "-v")
372+
cmd.Env = append(cmd.Environ(), "LANG=C")
373+
out, err := cmd.CombinedOutput()
370374
if err != nil {
371375
// gcc, but does not support gcc's "-v" flag?!
372376
return err

0 commit comments

Comments
 (0)