// 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",
"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/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
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{
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, "/...")
// 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)
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/") {
}
}
- 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, "")
}