From f8200537d87d50be8cbd97d0018541bbe3717c19 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Thu, 17 Apr 2014 13:40:42 -0700 Subject: [PATCH] go.tools/go/gccgoimporter: use gccgo -dumpversion GccgoInstallation.InitFromDriver currently parses the output of gccgo -### to get the gcc version, target triple, and library paths. At least with Ubuntu's stock libgo5 package, the search path for .gox files derived from the version is incorrect. gccgo uses the DEFAULT_TARGET_VERSION macro when constructing the search path; this value can be retrieved from gccgo via the "-dumpversion" flag. Fixes golang/go#7772. LGTM=iant, gri R=golang-codereviews, iant, gri CC=golang-codereviews https://golang.org/cl/88150043 --- go/gccgoimporter/gccgoinstallation.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/go/gccgoimporter/gccgoinstallation.go b/go/gccgoimporter/gccgoinstallation.go index 6e09237783c..6e3f7ffbd60 100644 --- a/go/gccgoimporter/gccgoinstallation.go +++ b/go/gccgoimporter/gccgoinstallation.go @@ -46,9 +46,6 @@ func (inst *GccgoInstallation) InitFromDriver(gccgoPath string) (err error) { case strings.HasPrefix(line, "Target: "): inst.TargetTriple = line[8:] - case strings.HasPrefix(line, "gcc version "): - inst.GccVersion = strings.SplitN(line[12:], " ", 2)[0] - case line[0] == ' ': args := strings.Fields(line) for _, arg := range args[1:] { @@ -59,6 +56,12 @@ func (inst *GccgoInstallation) InitFromDriver(gccgoPath string) (err error) { } } + stdout, err := exec.Command(gccgoPath, "-dumpversion").Output() + if err != nil { + return + } + inst.GccVersion = strings.TrimSpace(string(stdout)) + return }