diff --git a/.gitignore b/.gitignore index 7b63aaf3d4d5276e2a8cfbca112c4bb883bf176b..f1c72632372644d5098e0eac16072048f00bd34d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ src/cmd/gc/mkbuiltin1 src/cmd/gc/opnames.h src/cmd/gc/y.output src/cmd/go/zdefaultcc.go +src/cmd/internal/obj/zbootstrap.go src/go/doc/headscan src/runtime/mkversion src/runtime/zaexperiment.h diff --git a/src/cmd/dist/buildruntime.go b/src/cmd/dist/buildruntime.go index 1e6ae823972b564c5989fb7fc4690ec0684bce15..5e2605966b881518780b8ace2e16c312b57651ad 100644 --- a/src/cmd/dist/buildruntime.go +++ b/src/cmd/dist/buildruntime.go @@ -45,3 +45,31 @@ func mkzexperiment(dir, file string) { writefile(out, file, 0) } + +// mkzbootstrap writes cmd/internal/obj/zbootstrap.go: +// +// package obj +// +// const defaultGOROOT = <goroot> +// const defaultGOARM = <goarm> +// const defaultGOOS = <goos> +// const defaultGOARCH = <goarch> +// const version = <version> +// const goexperiment = <goexperiment> +// +func mkzbootstrap(file string) { + out := fmt.Sprintf( + "// auto generated by go tool dist\n"+ + "\n"+ + "package obj\n"+ + "\n"+ + "const defaultGOROOT = `%s`\n"+ + "const defaultGOARM = `%s`\n"+ + "const defaultGOOS = `%s`\n"+ + "const defaultGOARCH = `%s`\n"+ + "const version = `%s`\n"+ + "const goexperiment = `%s`\n", + goroot_final, goarm, gohostos, gohostarch, goversion, os.Getenv("GOEXPERIMENT")) + + writefile(out, file, 0) +} diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index c493dd1e51f44464d2c20cf2e9be4761e440aaa6..10371526d33d1ff71a64c424b33e842ac3029368 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -38,6 +38,8 @@ func bootstrapBuildTools() { } xprintf("##### Building Go toolchain using %s.\n", goroot_bootstrap) + mkzbootstrap(pathf("%s/src/cmd/internal/obj/zbootstrap.go", goroot)) + // Use $GOROOT/pkg/bootstrap as the bootstrap workspace root. // We use a subdirectory of $GOROOT/pkg because that's the // space within $GOROOT where we store all generated objects.