mirror of https://github.com/golang/go.git
runtime: generate windows callback list with go generate
This is the last system-dependent file written by cmd/dist. They are all now written by go generate. cmd/dist is not needed to start building package runtime for a different system anymore. Now all the generated files can be assumed generated, so delete the clumsy hacks in cmd/api. Re-enable api check in run.bash. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/185040044
This commit is contained in:
parent
7d516079de
commit
dcb2ec3b65
|
|
@ -352,139 +352,16 @@ var parsedFileCache = make(map[string]*ast.File)
|
||||||
|
|
||||||
func (w *Walker) parseFile(dir, file string) (*ast.File, error) {
|
func (w *Walker) parseFile(dir, file string) (*ast.File, error) {
|
||||||
filename := filepath.Join(dir, file)
|
filename := filepath.Join(dir, file)
|
||||||
f, _ := parsedFileCache[filename]
|
if f := parsedFileCache[filename]; f != nil {
|
||||||
if f != nil {
|
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
f, err := parser.ParseFile(fset, filename, nil, 0)
|
||||||
|
if err != nil {
|
||||||
// generate missing context-dependent files.
|
return nil, err
|
||||||
|
|
||||||
if w.context != nil && file == fmt.Sprintf("zgoos_%s.go", w.context.GOOS) {
|
|
||||||
src := fmt.Sprintf("package runtime; const theGoos = `%s`", w.context.GOOS)
|
|
||||||
f, err = parser.ParseFile(fset, filename, src, 0)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("incorrect generated file: %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.context != nil && file == fmt.Sprintf("zgoarch_%s.go", w.context.GOARCH) {
|
|
||||||
src := fmt.Sprintf("package runtime; const theGoarch = `%s`", w.context.GOARCH)
|
|
||||||
f, err = parser.ParseFile(fset, filename, src, 0)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("incorrect generated file: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if w.context != nil && file == fmt.Sprintf("zruntime_defs_%s_%s.go", w.context.GOOS, w.context.GOARCH) {
|
|
||||||
// Just enough to keep the api checker happy. Keep sorted.
|
|
||||||
src := "package runtime; type (" +
|
|
||||||
" _defer struct{};" +
|
|
||||||
" _func struct{};" +
|
|
||||||
" _panic struct{};" +
|
|
||||||
" _select struct{}; " +
|
|
||||||
" _type struct{};" +
|
|
||||||
" alg struct{};" +
|
|
||||||
" chantype struct{};" +
|
|
||||||
" context struct{};" + // windows
|
|
||||||
" eface struct{};" +
|
|
||||||
" epollevent struct{};" +
|
|
||||||
" funcval struct{};" +
|
|
||||||
" g struct{};" +
|
|
||||||
" gobuf struct{};" +
|
|
||||||
" hchan struct{};" +
|
|
||||||
" iface struct{};" +
|
|
||||||
" interfacetype struct{};" +
|
|
||||||
" itab struct{};" +
|
|
||||||
" keventt struct{};" +
|
|
||||||
" m struct{};" +
|
|
||||||
" maptype struct{};" +
|
|
||||||
" mcache struct{};" +
|
|
||||||
" mspan struct{};" +
|
|
||||||
" mutex struct{};" +
|
|
||||||
" note struct{};" +
|
|
||||||
" p struct{};" +
|
|
||||||
" parfor struct{};" +
|
|
||||||
" slicetype struct{};" +
|
|
||||||
" stkframe struct{};" +
|
|
||||||
" sudog struct{};" +
|
|
||||||
" timespec struct{};" +
|
|
||||||
" waitq struct{};" +
|
|
||||||
" wincallbackcontext struct{};" +
|
|
||||||
"); " +
|
|
||||||
"const (" +
|
|
||||||
" cb_max = 2000;" +
|
|
||||||
" _CacheLineSize = 64;" +
|
|
||||||
" _Gidle = 1;" +
|
|
||||||
" _Grunnable = 2;" +
|
|
||||||
" _Grunning = 3;" +
|
|
||||||
" _Gsyscall = 4;" +
|
|
||||||
" _Gwaiting = 5;" +
|
|
||||||
" _Gdead = 6;" +
|
|
||||||
" _Genqueue = 7;" +
|
|
||||||
" _Gcopystack = 8;" +
|
|
||||||
" _NSIG = 32;" +
|
|
||||||
" _FlagNoScan = iota;" +
|
|
||||||
" _FlagNoZero;" +
|
|
||||||
" _TinySize;" +
|
|
||||||
" _TinySizeClass;" +
|
|
||||||
" _MaxSmallSize;" +
|
|
||||||
" _PageShift;" +
|
|
||||||
" _PageSize;" +
|
|
||||||
" _PageMask;" +
|
|
||||||
" _BitsPerPointer;" +
|
|
||||||
" _BitsMask;" +
|
|
||||||
" _PointersPerByte;" +
|
|
||||||
" _MaxGCMask;" +
|
|
||||||
" _BitsDead;" +
|
|
||||||
" _BitsPointer;" +
|
|
||||||
" _MSpanInUse;" +
|
|
||||||
" _ConcurrentSweep;" +
|
|
||||||
" _KindBool;" +
|
|
||||||
" _KindInt;" +
|
|
||||||
" _KindInt8;" +
|
|
||||||
" _KindInt16;" +
|
|
||||||
" _KindInt32;" +
|
|
||||||
" _KindInt64;" +
|
|
||||||
" _KindUint;" +
|
|
||||||
" _KindUint8;" +
|
|
||||||
" _KindUint16;" +
|
|
||||||
" _KindUint32;" +
|
|
||||||
" _KindUint64;" +
|
|
||||||
" _KindUintptr;" +
|
|
||||||
" _KindFloat32;" +
|
|
||||||
" _KindFloat64;" +
|
|
||||||
" _KindComplex64;" +
|
|
||||||
" _KindComplex128;" +
|
|
||||||
" _KindArray;" +
|
|
||||||
" _KindChan;" +
|
|
||||||
" _KindFunc;" +
|
|
||||||
" _KindInterface;" +
|
|
||||||
" _KindMap;" +
|
|
||||||
" _KindPtr;" +
|
|
||||||
" _KindSlice;" +
|
|
||||||
" _KindString;" +
|
|
||||||
" _KindStruct;" +
|
|
||||||
" _KindUnsafePointer;" +
|
|
||||||
" _KindDirectIface;" +
|
|
||||||
" _KindGCProg;" +
|
|
||||||
" _KindNoPointers;" +
|
|
||||||
" _KindMask;" +
|
|
||||||
")"
|
|
||||||
f, err = parser.ParseFile(fset, filename, src, 0)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("incorrect generated file: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if f == nil {
|
|
||||||
f, err = parser.ParseFile(fset, filename, nil, 0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedFileCache[filename] = f
|
parsedFileCache[filename] = f
|
||||||
|
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -591,25 +468,6 @@ func (w *Walker) Import(name string) (pkg *types.Package) {
|
||||||
|
|
||||||
filenames := append(append([]string{}, info.GoFiles...), info.CgoFiles...)
|
filenames := append(append([]string{}, info.GoFiles...), info.CgoFiles...)
|
||||||
|
|
||||||
// Certain files only exist when building for the specified context.
|
|
||||||
// Add them manually.
|
|
||||||
if name == "runtime" {
|
|
||||||
n := fmt.Sprintf("zgoos_%s.go", w.context.GOOS)
|
|
||||||
if !contains(filenames, n) {
|
|
||||||
filenames = append(filenames, n)
|
|
||||||
}
|
|
||||||
|
|
||||||
n = fmt.Sprintf("zgoarch_%s.go", w.context.GOARCH)
|
|
||||||
if !contains(filenames, n) {
|
|
||||||
filenames = append(filenames, n)
|
|
||||||
}
|
|
||||||
|
|
||||||
n = fmt.Sprintf("zruntime_defs_%s_%s.go", w.context.GOOS, w.context.GOARCH)
|
|
||||||
if !contains(filenames, n) {
|
|
||||||
filenames = append(filenames, n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse package files.
|
// Parse package files.
|
||||||
var files []*ast.File
|
var files []*ast.File
|
||||||
for _, file := range filenames {
|
for _, file := range filenames {
|
||||||
|
|
|
||||||
|
|
@ -588,9 +588,6 @@ static struct {
|
||||||
}},
|
}},
|
||||||
{"runtime", {
|
{"runtime", {
|
||||||
"zaexperiment.h",
|
"zaexperiment.h",
|
||||||
"zsys_$GOOS_$GOARCH.s",
|
|
||||||
"zgoarch_$GOARCH.go",
|
|
||||||
"zgoos_$GOOS.go",
|
|
||||||
"zversion.go",
|
"zversion.go",
|
||||||
}},
|
}},
|
||||||
};
|
};
|
||||||
|
|
@ -614,7 +611,6 @@ static struct {
|
||||||
{"anames8.c", mkanames},
|
{"anames8.c", mkanames},
|
||||||
{"anames9.c", mkanames},
|
{"anames9.c", mkanames},
|
||||||
{"zdefaultcc.go", mkzdefaultcc},
|
{"zdefaultcc.go", mkzdefaultcc},
|
||||||
{"zsys_", mkzsys},
|
|
||||||
{"zversion.go", mkzversion},
|
{"zversion.go", mkzversion},
|
||||||
{"zaexperiment.h", mkzexperiment},
|
{"zaexperiment.h", mkzexperiment},
|
||||||
|
|
||||||
|
|
@ -1391,6 +1387,11 @@ static char *cleantab[] = {
|
||||||
"unicode/utf8",
|
"unicode/utf8",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *runtimegen[] = {
|
||||||
|
"zaexperiment.h",
|
||||||
|
"zversion.go",
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clean(void)
|
clean(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1417,15 +1418,11 @@ clean(void)
|
||||||
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
|
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove src/runtime/z* unconditionally,
|
// remove src/runtime/zaexperiment.h and
|
||||||
// except leave zgoos and zgoarch, now maintained with go generate.
|
// except leave zgoos and zgoarch, now maintained with go generate.
|
||||||
vreset(&dir);
|
|
||||||
bpathf(&path, "%s/src/runtime", goroot);
|
bpathf(&path, "%s/src/runtime", goroot);
|
||||||
xreaddir(&dir, bstr(&path));
|
for(j=0; j<nelem(runtimegen); j++)
|
||||||
for(j=0; j<dir.len; j++) {
|
xremove(bpathf(&b, "%s/%s", bstr(&path), runtimegen[j]));
|
||||||
if(hasprefix(dir.p[j], "z") && !hasprefix(dir.p[j], "zg"))
|
|
||||||
xremove(bpathf(&b, "%s/%s", bstr(&path), dir.p[j]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rebuildall) {
|
if(rebuildall) {
|
||||||
// Remove object tree.
|
// Remove object tree.
|
||||||
|
|
|
||||||
|
|
@ -66,44 +66,3 @@ mkzexperiment(char *dir, char *file)
|
||||||
bfree(&out);
|
bfree(&out);
|
||||||
bfree(&exp);
|
bfree(&exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAXWINCB 2000 /* maximum number of windows callbacks allowed */
|
|
||||||
|
|
||||||
// mkzsys writes zsys_$GOOS_$GOARCH.s,
|
|
||||||
// which contains arch or os specific asm code.
|
|
||||||
//
|
|
||||||
void
|
|
||||||
mkzsys(char *dir, char *file)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
Buf out;
|
|
||||||
|
|
||||||
USED(dir);
|
|
||||||
|
|
||||||
binit(&out);
|
|
||||||
|
|
||||||
bwritestr(&out, "// auto generated by go tool dist\n\n");
|
|
||||||
if(streq(goos, "linux")) {
|
|
||||||
bwritestr(&out, "// +build !android\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(streq(goos, "windows")) {
|
|
||||||
bwritef(&out,
|
|
||||||
"// runtime·callbackasm is called by external code to\n"
|
|
||||||
"// execute Go implemented callback function. It is not\n"
|
|
||||||
"// called from the start, instead runtime·compilecallback\n"
|
|
||||||
"// always returns address into runtime·callbackasm offset\n"
|
|
||||||
"// appropriately so different callbacks start with different\n"
|
|
||||||
"// CALL instruction in runtime·callbackasm. This determines\n"
|
|
||||||
"// which Go callback function is executed later on.\n"
|
|
||||||
"TEXT runtime·callbackasm(SB),7,$0\n");
|
|
||||||
for(i=0; i<MAXWINCB; i++) {
|
|
||||||
bwritef(&out, "\tCALL\truntime·callbackasm1(SB)\n");
|
|
||||||
}
|
|
||||||
bwritef(&out, "\tRET\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
writefile(&out, file, 0);
|
|
||||||
|
|
||||||
bfree(&out);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -813,7 +813,8 @@ func (b *builder) build(a *action) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.p.Standard && a.p.ImportPath == "runtime" && buildContext.Compiler == "gc" &&
|
if a.p.Standard && a.p.ImportPath == "runtime" && buildContext.Compiler == "gc" &&
|
||||||
!hasString(a.p.SFiles, "zsys_"+buildContext.GOOS+"_"+buildContext.GOARCH+".s") {
|
(!hasString(a.p.GoFiles, "zgoos_"+buildContext.GOOS+".go") ||
|
||||||
|
!hasString(a.p.GoFiles, "zgoarch_"+buildContext.GOARCH+".go")) {
|
||||||
return fmt.Errorf("%s/%s must be bootstrapped using make%v", buildContext.GOOS, buildContext.GOARCH, defaultSuffix())
|
return fmt.Errorf("%s/%s must be bootstrapped using make%v", buildContext.GOOS, buildContext.GOARCH, defaultSuffix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,8 +255,7 @@ rm -f runtest
|
||||||
[ "$GOOS" == nacl ] ||
|
[ "$GOOS" == nacl ] ||
|
||||||
(
|
(
|
||||||
echo
|
echo
|
||||||
echo '# SKIPPING API CHECK UNTIL ALL SYSTEMS BUILD.'
|
time go run $GOROOT/src/cmd/api/run.go || exit 1
|
||||||
# time go run $GOROOT/src/cmd/api/run.go || exit 1
|
|
||||||
) || exit $?
|
) || exit $?
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,8 @@ set GOMAXPROCS=%OLDGOMAXPROCS%
|
||||||
set OLDGOMAXPROCS=
|
set OLDGOMAXPROCS=
|
||||||
|
|
||||||
:: echo # Checking API compatibility.
|
:: echo # Checking API compatibility.
|
||||||
:: go run "%GOROOT%\src\cmd\api\run.go"
|
go run "%GOROOT%\src\cmd\api\run.go"
|
||||||
:: if errorlevel 1 goto fail
|
if errorlevel 1 goto fail
|
||||||
:: echo.
|
|
||||||
echo # SKIPPING API COMPATIBILITY UNTIL ALL SYSTEMS BUILD.
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo ALL TESTS PASSED
|
echo ALL TESTS PASSED
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
//go:generate go run wincallback.go
|
||||||
|
|
||||||
var ticks struct {
|
var ticks struct {
|
||||||
lock mutex
|
lock mutex
|
||||||
val uint64
|
val uint64
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// Generate Windows callback assembly file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
const maxCallback = 2000
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
buf.WriteString(`// generated by wincallback.go; run go generate
|
||||||
|
|
||||||
|
// runtime·callbackasm is called by external code to
|
||||||
|
// execute Go implemented callback function. It is not
|
||||||
|
// called from the start, instead runtime·compilecallback
|
||||||
|
// always returns address into runtime·callbackasm offset
|
||||||
|
// appropriately so different callbacks start with different
|
||||||
|
// CALL instruction in runtime·callbackasm. This determines
|
||||||
|
// which Go callback function is executed later on.
|
||||||
|
TEXT runtime·callbackasm(SB),7,$0
|
||||||
|
`)
|
||||||
|
for i := 0; i < maxCallback; i++ {
|
||||||
|
buf.WriteString("\tCALL\truntime·callbackasm1(SB)\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := ioutil.WriteFile("zcallback_windows.s", buf.Bytes(), 0666)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "wincallback: %s\n", err)
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue