1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:44:46 -07:00

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
This commit is contained in:
Andrew Wilkins 2014-04-17 13:40:42 -07:00 committed by Robert Griesemer
parent 4843aaee02
commit f8200537d8

View File

@ -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
}