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