Commit 45a8fae9 authored by Rémy Oudompheng's avatar Rémy Oudompheng Committed by Russ Cox

go: introduce support for "go build" with gccgo.

The use of gccgo is triggered by GC=gccgo in environment. It
still needs the standard distribution to behave properly, but
allows using the test, build, run, install subcommands with
gccgo.

R=rsc, iant, fullung
CC=golang-dev, remy
https://golang.org/cl/5562045
parent c4303aa5
This diff is collapsed.
......@@ -270,6 +270,16 @@ func scanPackage(ctxt *build.Context, t *build.Tree, arg, importPath, dir string
p.target = filepath.Join(t.PkgDir(), filepath.FromSlash(importPath)+".a")
}
// For gccgo, rewrite p.target with the expected library name. We won't do
// that for the standard library for the moment.
if !p.Standard {
dir := t.PkgDir()
if _, ok := buildToolchain.(gccgoToolchain); ok {
dir = filepath.Join(filepath.Dir(dir), "gccgo", filepath.Base(dir))
}
p.target = buildToolchain.pkgpath(dir, p)
}
var built time.Time
if fi, err := os.Stat(p.target); err == nil {
built = fi.ModTime()
......
......@@ -330,8 +330,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
// We write the external test package archive to
// $WORK/unicode/utf8/_test/unicode/utf8_test.a.
testDir := filepath.Join(b.work, filepath.FromSlash(p.ImportPath+"/_test"))
ptestObj := filepath.Join(testDir, filepath.FromSlash(p.ImportPath+".a"))
pxtestObj := filepath.Join(testDir, filepath.FromSlash(p.ImportPath+"_test.a"))
ptestObj := buildToolchain.pkgpath(testDir, p)
// Create the directory for the .a files.
ptestDir, _ := filepath.Split(ptestObj)
......@@ -380,8 +379,8 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
pxtest.imports = append(pxtest.imports, ptest)
a := b.action(modeBuild, modeBuild, pxtest)
a.objdir = testDir + string(filepath.Separator)
a.objpkg = pxtestObj
a.target = pxtestObj
a.objpkg = buildToolchain.pkgpath(testDir, pxtest)
a.target = a.objpkg
}
// Action for building test.out.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment