Commit 91cb3489 authored by Rob Pike's avatar Rob Pike

go: move compilers into the go-tool directory

Also delete gotest, since it's messy to fix and slated for deletion anyway.
A couple of things outside src can't be tested any more. "go test" will be
fixed and these tests will be re-enabled. They're noisy for now.

Fixes #284.

R=rsc
CC=golang-dev
https://golang.org/cl/5598049
parent be7a0494
......@@ -43,3 +43,6 @@ $(CHKSTK):
endif
include ../../../src/Make.pkg
test:
echo cgo: tests disabled. gotest is gone. TODO
\ No newline at end of file
......@@ -31,20 +31,3 @@ CLEANFILES+=$(TARG) _test _testmain.go test.out build.out
nuke: clean
rm -f $(TARGDIR)/$(TARG)
# for gotest
testpackage: _test/main.a
testpackage-clean:
rm -f _test/main.a _gotest_.$O
_test/main.a: _gotest_.$O
@mkdir -p _test
rm -f $@
"$(GOROOT)/bin/go-tool/pack" grc $@ _gotest_.$O
_gotest_.$O: $(GOFILES) $(GOTESTFILES)
$(GC) $(GCFLAGS) $(GCIMPORTS) -o $@ $(GOFILES) $(GOTESTFILES)
importpath:
echo main
......@@ -98,10 +98,10 @@ GOBIN=$(QUOTED_GOROOT)/bin
endif
QUOTED_GOBIN=$(subst $(space),\ ,$(GOBIN))
AS=${O}a
CC=${O}c
GC=${O}g
LD=${O}l
AS=$(QUOTED_GOROOT)/bin/go-tool/$(O)a
CC=$(QUOTED_GOROOT)/bin/go-tool/$(O)c
GC=$(QUOTED_GOROOT)/bin/go-tool/$(O)g
LD=$(QUOTED_GOROOT)/bin/go-tool/$(O)l
OS=568vq
CFLAGS=-FVw
......
......@@ -56,19 +56,19 @@ endif
PREREQ+=$(patsubst %,%.make,$(DEPS))
coverage:
gotest
go test
6cov -g $(shell pwd) $O.out | grep -v '_test\.go:'
CLEANFILES+=*.so _obj _test _testmain.go *.exe _cgo* test.out build.out
test:
gotest
go test
testshort:
gotest -test.short -test.timeout=2m
go test -test.short -test.timeout=2m
bench:
gotest -test.bench=. -test.run="Do not run tests"
go test -test.bench=. -test.run="Do not run tests"
nuke: clean
rm -f $(TARGDIR)/$(TARG).a
......@@ -93,11 +93,6 @@ _obj/$(TARG).a: _go_.$O $(OFILES)
rm -f _obj/$(TARG).a
"$(GOROOT)/bin/go-tool/pack" grc $@ _go_.$O $(OFILES)
_test/$(TARG).a: _gotest_.$O $(OFILES)
@mkdir -p _test/$(dir)
rm -f _test/$(TARG).a
"$(GOROOT)/bin/go-tool/pack" grc $@ _gotest_.$O $(OFILES)
importpath:
@echo $(TARG)
......
......@@ -30,20 +30,3 @@ CLEANFILES+=$(TARG) _test _testmain.go test.out build.out
nuke: clean
rm -f $(TOOLDIR)/$(TARG)
# for gotest
testpackage: _test/main.a
testpackage-clean:
rm -f _test/main.a _gotest_.$O
_test/main.a: _gotest_.$O
@mkdir -p _test
rm -f $@
"$(GOROOT)/bin/go-tool/pack" grc $@ _gotest_.$O
_gotest_.$O: $(GOFILES) $(GOTESTFILES)
$(GC) $(GCFLAGS) $(GCIMPORTS) -o $@ $(GOFILES) $(GOTESTFILES)
importpath:
echo main
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -20,6 +20,6 @@ OFILES=\
YFILES=\
a.y\
include ../../Make.ccmd
include ../../Make.ctool
lex.$O: ../cc/macbody ../cc/lexbody
......@@ -28,7 +28,7 @@ OFILES=\
LIB=\
../cc/cc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../cc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../cc/$*.c
......@@ -30,7 +30,7 @@ OFILES=\
LIB=\
../gc/gc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../gc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../gc/$*.c
......@@ -32,7 +32,7 @@ HFILES=\
5.out.h\
../ld/elf.h\
include ../../Make.ccmd
include ../../Make.ctool
enam.c: 5.out.h
sh mkenam
......
......@@ -20,6 +20,6 @@ OFILES=\
YFILES=\
a.y\
include ../../Make.ccmd
include ../../Make.ctool
lex.$O: ../cc/macbody ../cc/lexbody
......@@ -30,7 +30,7 @@ OFILES=\
LIB=\
../cc/cc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../cc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../cc/$*.c
......@@ -29,7 +29,7 @@ OFILES=\
LIB=\
../gc/gc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../gc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../gc/$*.c
......@@ -37,7 +37,7 @@ HFILES=\
../ld/dwarf.h\
../ld/pe.h\
include ../../Make.ccmd
include ../../Make.ctool
enam.c: 6.out.h
sh mkenam
......
......@@ -20,6 +20,6 @@ OFILES=\
YFILES=\
a.y\
include ../../Make.ccmd
include ../../Make.ctool
lex.$O: ../cc/macbody ../cc/lexbody
......@@ -31,7 +31,7 @@ OFILES=\
LIB=\
../cc/cc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../cc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../cc/$*.c
......@@ -30,7 +30,7 @@ OFILES=\
LIB=\
../gc/gc.a\
include ../../Make.ccmd
include ../../Make.ctool
%.$O: ../gc/%.c
$(HOST_CC) $(HOST_CFLAGS) -c -I. -o $@ ../gc/$*.c
......@@ -37,7 +37,7 @@ HFILES=\
../ld/macho.h\
../ld/pe.h\
include ../../Make.ccmd
include ../../Make.ctool
enam.c: 8.out.h
sh mkenam
......
......@@ -40,7 +40,6 @@ CLEANDIRS=\
godoc\
fix\
gofmt\
gotest\
vet\
yacc\
......
......@@ -976,7 +976,8 @@ func (goToolchain) gc(b *builder, p *Package, obj string, importArgs []string, g
gcargs = append(gcargs, "-+")
}
args := stringList(b.arch+"g", "-o", ofile, b.gcflags, gcargs, importArgs)
binary := filepath.Join(b.goroot, "bin/go-tool/", b.arch+"g")
args := stringList(binary, "-o", ofile, b.gcflags, gcargs, importArgs)
for _, f := range gofiles {
args = append(args, mkAbs(p.Dir, f))
}
......@@ -985,7 +986,8 @@ func (goToolchain) gc(b *builder, p *Package, obj string, importArgs []string, g
func (goToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error {
sfile = mkAbs(p.Dir, sfile)
return b.run(p.Dir, p.ImportPath, b.arch+"a", "-I", obj, "-o", ofile, "-DGOOS_"+b.goos, "-DGOARCH_"+b.goarch, sfile)
binary := filepath.Join(b.goroot, "bin/go-tool/", b.arch+"a")
return b.run(p.Dir, p.ImportPath, binary, "-I", obj, "-o", ofile, "-DGOOS_"+b.goos, "-DGOARCH_"+b.goarch, sfile)
}
func (goToolchain) pkgpath(basedir string, p *Package) string {
......@@ -1002,13 +1004,15 @@ func (goToolchain) pack(b *builder, p *Package, objDir, afile string, ofiles []s
func (goToolchain) ld(b *builder, p *Package, out string, allactions []*action, mainpkg string, ofiles []string) error {
importArgs := b.includeArgs("-L", allactions)
return b.run(p.Dir, p.ImportPath, b.arch+"l", "-o", out, importArgs, mainpkg)
binary := filepath.Join(b.goroot, "bin/go-tool/", b.arch+"l")
return b.run(p.Dir, p.ImportPath, binary, "-o", out, importArgs, mainpkg)
}
func (goToolchain) cc(b *builder, p *Package, objdir, ofile, cfile string) error {
inc := filepath.Join(b.goroot, "pkg", fmt.Sprintf("%s_%s", b.goos, b.goarch))
cfile = mkAbs(p.Dir, cfile)
return b.run(p.Dir, p.ImportPath, b.arch+"c", "-FVw",
binary := filepath.Join(b.goroot, "bin/go-tool/", b.arch+"c")
return b.run(p.Dir, p.ImportPath, binary, "-FVw",
"-I", objdir, "-I", inc, "-o", ofile,
"-DGOOS_"+b.goos, "-DGOARCH_"+b.goarch, cfile)
}
......
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
The gomake command runs GNU make with an appropriate environment
for using the conventional Go makefiles. If $GOROOT is already
set in the environment, running gomake is exactly the same
as running make (or, on BSD systems, running gmake).
Usage: gomake [ target ... ]
Common targets are:
all (default)
build the package or command, but do not install it.
install
build and install the package or command
test
run the tests (packages only)
bench
run benchmarks (packages only)
clean
remove object files from the current directory
nuke
make clean and remove the installed package or command
See http://golang.org/doc/code.html for information about
writing makefiles.
*/
package documentation
# Copyright 2010 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
include ../../Make.inc
TARG=gotest
GOFILES=\
flag.go\
gotest.go\
include ../../Make.cmd
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,9 +3,9 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Set to false if something breaks, to revert back to Makefiles.
# TODO: This variable will go away when the Makefiles do.
USE_GO_TOOL=${USE_GO_TOOL:-true}
# Disable use of makefiles during build.
# TODO: Remove this and the makefiles.
USE_GO_TOOL=true
# If set to a Windows-style path convert to an MSYS-Unix
# one using the built-in shell commands.
......
......@@ -158,7 +158,6 @@ DIRS=\
../cmd/godoc\
../cmd/fix\
../cmd/gofmt\
../cmd/gotest\
../cmd/vet\
../cmd/yacc\
......@@ -192,7 +191,6 @@ NOTEST+=\
testing/iotest\
../cmd/cgo\
../cmd/godoc\
../cmd/gotest\
../cmd/yacc\
NOBENCH+=\
......
......@@ -31,7 +31,7 @@ func init() {
gcPath = gcName
return
}
gcPath, _ = exec.LookPath(gcName)
gcPath = filepath.Join(runtime.GOROOT(), "/bin/go-tool/", gcName)
}
func compile(t *testing.T, dirname, filename string) {
......
......@@ -15,6 +15,7 @@ case "$GOARCH" in
amd64) CC=6c;;
arm) CC=5c;;
esac
CC="$GOROOT/bin/go-tool/$CC"
export CC
export CFLAGS="-Dos_$GOOS -Darch_$GOARCH"
......@@ -29,7 +30,7 @@ cat <<'EOF'
// AUTO-GENERATED by autogen.sh; DO NOT EDIT
EOF
if [ ! -x "${GOBIN:=$GOROOT/bin}/$CC" ]; then
if [ ! -x "$CC" ]; then
echo "// dummy file for cmd/go to correctly generate buildscript"
exit
fi
......@@ -114,7 +115,7 @@ arm)
esac
echo
$GOBIN/$CC $CFLAGS -a proc.c |
"$CC" $CFLAGS -a proc.c |
awk '
{ gsub(/\r/, ""); }
/^aggr G$/ { aggr="g" }
......
......@@ -15,6 +15,7 @@ case "$GOARCH" in
amd64) CC=6c;;
arm) CC=5c;;
esac
CC="$GOROOT/bin/go-tool/$CC"
export CC
export CFLAGS="-DGOOS_$GOOS -DGOARCH_$GOARCH"
......@@ -28,7 +29,7 @@ cat <<EOF
// Go definitions for C variables and types.
// AUTO-GENERATED by autogen.sh; DO NOT EDIT
EOF
if [ ! -x "${GOBIN:=$GOROOT/bin}/$CC" ]; then
if [ ! -x "$CC" ]; then
echo "// dummy file for cmd/go to correctly generate buildscript"
echo "package runtime"
exit
......@@ -42,7 +43,7 @@ var _ unsafe.Pointer
EOF
for i in "$@"; do
$GOBIN/$CC $CFLAGS -q $i
"$CC" $CFLAGS -q $i
done | awk '
/^func/ { next }
/^const/ { next }
......
......@@ -59,7 +59,7 @@ if $USE_GO_TOOL; then
go test runtime -short -cpu=1,2,4
else
(xcd pkg/runtime;
gotest -short -cpu=1,2,4
go test -short -cpu=1,2,4
) || exit $?
fi
......@@ -99,7 +99,7 @@ gomake clean
[ "$CGO_ENABLED" != 1 ] ||
(xcd ../misc/cgo/test
gomake clean
gotest
make test
) || exit $?
[ "$CGO_ENABLED" != 1 ] ||
......
......@@ -5,3 +5,6 @@ GOFILES=\
dummy.go\
include $(GOROOT)/src/Make.pkg
test:
echo go1: tests disabled for now TODO
......@@ -33,6 +33,9 @@ failed=0
PATH=${GOBIN:-$GOROOT/bin}:`pwd`:/bin:/usr/bin:/usr/local/bin
# TODO: We add the go-tools directory to the PATH to avoid thinking about a better way.
PATH="$GOROOT/bin/go-tool":$PATH
RUNFILE="/tmp/gorun-$$-$USER"
TMP1FILE="/tmp/gotest1-$$-$USER"
TMP2FILE="/tmp/gotest2-$$-$USER"
......
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