]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/dist/buildtool.go
cmd/compile: update types2.Info.FileVersions API to match go/types
[gostls13.git] / src / cmd / dist / buildtool.go
index 1eeb32afd3b4d202217aa1127f82c04355e0f55f..3232896f262564f66d0565854eb249fd01e3e0af 100644 (file)
@@ -31,6 +31,7 @@ import (
 // include all packages within subdirectories as well.
 // These will be imported during bootstrap as bootstrap/name, like bootstrap/math/big.
 var bootstrapDirs = []string{
+       "cmp",
        "cmd/asm",
        "cmd/asm/internal/...",
        "cmd/cgo",
@@ -59,26 +60,37 @@ var bootstrapDirs = []string{
        "debug/elf",
        "debug/macho",
        "debug/pe",
+       "go/build/constraint",
        "go/constant",
+       "go/version",
        "internal/abi",
        "internal/coverage",
+       "cmd/internal/cov/covcmd",
+       "internal/bisect",
        "internal/buildcfg",
        "internal/goarch",
+       "internal/godebugs",
        "internal/goexperiment",
        "internal/goroot",
+       "internal/gover",
        "internal/goversion",
+       // internal/lazyregexp is provided by Go 1.17, which permits it to
+       // be imported by other packages in this list, but is not provided
+       // by the Go 1.17 version of gccgo. It's on this list only to
+       // support gccgo, and can be removed if we require gccgo 14 or later.
+       "internal/lazyregexp",
        "internal/pkgbits",
+       "internal/platform",
        "internal/profile",
        "internal/race",
        "internal/saferio",
-       "internal/platform",
+       "internal/syscall/unix",
        "internal/types/errors",
        "internal/unsafeheader",
        "internal/xcoff",
-       "math/big",
+       "internal/zstd",
        "math/bits",
        "sort",
-       "strconv",
 }
 
 // File prefixes that are ignored by go/build anyway, and cause
@@ -95,6 +107,10 @@ var ignorePrefixes = []string{
 var ignoreSuffixes = []string{
        "_test.s",
        "_test.go",
+       // Skip PGO profile. No need to build toolchain1 compiler
+       // with PGO. And as it is not a text file the import path
+       // rewrite will break it.
+       ".pgo",
 }
 
 var tryDirs = []string{
@@ -130,7 +146,7 @@ func bootstrapBuildTools() {
        xmkdirall(base)
 
        // Copy source code into $GOROOT/pkg/bootstrap and rewrite import paths.
-       writefile("module bootstrap\n", pathf("%s/%s", base, "go.mod"), 0)
+       writefile("module bootstrap\ngo 1.20\n", pathf("%s/%s", base, "go.mod"), 0)
        for _, dir := range bootstrapDirs {
                recurse := strings.HasSuffix(dir, "/...")
                dir = strings.TrimSuffix(dir, "/...")
@@ -273,13 +289,11 @@ func bootstrapRewriteFile(srcFile string) string {
        // binary that works for the current gohostarch.
        // This saves 6+ seconds of bootstrap.
        if archCaps, ok := isUnneededSSARewriteFile(srcFile, gohostarch); ok {
-               return fmt.Sprintf(`// Code generated by go tool dist; DO NOT EDIT.
-
-package ssa
+               return fmt.Sprintf(`%spackage ssa
 
 func rewriteValue%s(v *Value) bool { panic("unused during bootstrap") }
 func rewriteBlock%s(b *Block) bool { panic("unused during bootstrap") }
-`, archCaps, archCaps)
+`, generatedHeader, archCaps, archCaps)
        }
 
        return bootstrapFixImports(srcFile)
@@ -302,7 +316,7 @@ func bootstrapFixImports(srcFile string) string {
                        continue
                }
                if strings.HasPrefix(line, `import "`) || strings.HasPrefix(line, `import . "`) ||
-                       inBlock && (strings.HasPrefix(line, "\t\"") || strings.HasPrefix(line, "\t. \"") || strings.HasPrefix(line, "\texec \"")) {
+                       inBlock && (strings.HasPrefix(line, "\t\"") || strings.HasPrefix(line, "\t. \"") || strings.HasPrefix(line, "\texec \"") || strings.HasPrefix(line, "\trtabi \"")) {
                        line = strings.Replace(line, `"cmd/`, `"bootstrap/cmd/`, -1)
                        for _, dir := range bootstrapDirs {
                                if strings.HasPrefix(dir, "cmd/") {
@@ -314,7 +328,7 @@ func bootstrapFixImports(srcFile string) string {
                }
        }
 
-       lines[0] = "// Code generated by go tool dist; DO NOT EDIT.\n// This is a bootstrap copy of " + srcFile + "\n\n//line " + srcFile + ":1\n" + lines[0]
+       lines[0] = generatedHeader + "// This is a bootstrap copy of " + srcFile + "\n\n//line " + srcFile + ":1\n" + lines[0]
 
        return strings.Join(lines, "")
 }