diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/api/goapi.go | 152 | ||||
-rw-r--r-- | src/cmd/dist/build.c | 19 | ||||
-rw-r--r-- | src/cmd/dist/buildruntime.c | 41 | ||||
-rw-r--r-- | src/cmd/go/build.go | 3 |
4 files changed, 15 insertions, 200 deletions
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 5a8c87603..568aec8c0 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -352,139 +352,16 @@ var parsedFileCache = make(map[string]*ast.File) func (w *Walker) parseFile(dir, file string) (*ast.File, error) { filename := filepath.Join(dir, file) - f, _ := parsedFileCache[filename] - if f != nil { + if f := parsedFileCache[filename]; f != nil { return f, nil } - var err error - - // generate missing context-dependent files. - - 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 - } + f, err := parser.ParseFile(fset, filename, nil, 0) + if err != nil { + return nil, err } - parsedFileCache[filename] = f + return f, nil } @@ -591,25 +468,6 @@ func (w *Walker) Import(name string) (pkg *types.Package) { 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. var files []*ast.File for _, file := range filenames { diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index bfb3d15b8..3743b7300 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -588,9 +588,6 @@ static struct { }}, {"runtime", { "zaexperiment.h", - "zsys_$GOOS_$GOARCH.s", - "zgoarch_$GOARCH.go", - "zgoos_$GOOS.go", "zversion.go", }}, }; @@ -614,7 +611,6 @@ static struct { {"anames8.c", mkanames}, {"anames9.c", mkanames}, {"zdefaultcc.go", mkzdefaultcc}, - {"zsys_", mkzsys}, {"zversion.go", mkzversion}, {"zaexperiment.h", mkzexperiment}, @@ -1391,6 +1387,11 @@ static char *cleantab[] = { "unicode/utf8", }; +static char *runtimegen[] = { + "zaexperiment.h", + "zversion.go", +}; + static void clean(void) { @@ -1417,15 +1418,11 @@ clean(void) 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. - vreset(&dir); bpathf(&path, "%s/src/runtime", goroot); - xreaddir(&dir, bstr(&path)); - for(j=0; j<dir.len; j++) { - if(hasprefix(dir.p[j], "z") && !hasprefix(dir.p[j], "zg")) - xremove(bpathf(&b, "%s/%s", bstr(&path), dir.p[j])); - } + for(j=0; j<nelem(runtimegen); j++) + xremove(bpathf(&b, "%s/%s", bstr(&path), runtimegen[j])); if(rebuildall) { // Remove object tree. diff --git a/src/cmd/dist/buildruntime.c b/src/cmd/dist/buildruntime.c index 38e99e116..add689768 100644 --- a/src/cmd/dist/buildruntime.c +++ b/src/cmd/dist/buildruntime.c @@ -66,44 +66,3 @@ mkzexperiment(char *dir, char *file) bfree(&out); 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); -} diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index 5dcaa04a1..58fc98d84 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -813,7 +813,8 @@ func (b *builder) build(a *action) (err error) { } 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()) } |