diff options
author | Russ Cox <rsc@golang.org> | 2021-04-15 23:05:49 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-04-16 19:20:53 +0000 |
commit | 95ed5c3800a87ddf9b0ec3958eaaa1a969306293 (patch) | |
tree | cb0c555f10ab706a5c491cbe48dd36da16658a1e /src/cmd/dist | |
parent | 2fc0ebb623e2859094ad3f41e61325df0c2163f8 (diff) | |
download | go-95ed5c3800a87ddf9b0ec3958eaaa1a969306293.tar.gz go-95ed5c3800a87ddf9b0ec3958eaaa1a969306293.zip |
internal/buildcfg: move build configuration out of cmd/internal/objabi
The go/build package needs access to this configuration,
so move it into a new package available to the standard library.
Change-Id: I868a94148b52350c76116451f4ad9191246adcff
Reviewed-on: https://go-review.googlesource.com/c/go/+/310731
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r-- | src/cmd/dist/buildruntime.go | 37 | ||||
-rw-r--r-- | src/cmd/dist/buildtool.go | 4 |
2 files changed, 26 insertions, 15 deletions
diff --git a/src/cmd/dist/buildruntime.go b/src/cmd/dist/buildruntime.go index 3ef551e187..54e935ad3b 100644 --- a/src/cmd/dist/buildruntime.go +++ b/src/cmd/dist/buildruntime.go @@ -32,22 +32,15 @@ func mkzversion(dir, file string) { writefile(buf.String(), file, writeSkipSame) } -// mkzbootstrap writes cmd/internal/objabi/zbootstrap.go: +// mkbuildcfg writes internal/buildcfg/zbootstrap.go: // -// package objabi +// package buildcfg // // const defaultGOROOT = <goroot> // const defaultGO386 = <go386> -// const defaultGOARM = <goarm> -// const defaultGOMIPS = <gomips> -// const defaultGOMIPS64 = <gomips64> -// const defaultGOPPC64 = <goppc64> +// ... // const defaultGOOS = runtime.GOOS // const defaultGOARCH = runtime.GOARCH -// const defaultGOEXPERIMENT = <goexperiment> -// const defaultGO_EXTLINK_ENABLED = <goextlinkenabled> -// const version = <version> -// const stackGuardMultiplierDefault = <multiplier value> // // The use of runtime.GOOS and runtime.GOARCH makes sure that // a cross-compiled compiler expects to compile for its own target @@ -58,11 +51,11 @@ func mkzversion(dir, file string) { // the resulting compiler will default to generating linux/ppc64 object files. // This is more useful than having it default to generating objects for the // original target (in this example, a Mac). -func mkzbootstrap(file string) { +func mkbuildcfg(file string) { var buf bytes.Buffer fmt.Fprintf(&buf, "// Code generated by go tool dist; DO NOT EDIT.\n") fmt.Fprintln(&buf) - fmt.Fprintf(&buf, "package objabi\n") + fmt.Fprintf(&buf, "package buildcfg\n") fmt.Fprintln(&buf) fmt.Fprintf(&buf, "import \"runtime\"\n") fmt.Fprintln(&buf) @@ -71,12 +64,28 @@ func mkzbootstrap(file string) { fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips) fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64) fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64) - fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n") - fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n") fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`\n", goexperiment) fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled) fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso) fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion()) + fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n") + fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n") + + writefile(buf.String(), file, writeSkipSame) +} + +// mkobjabi writes cmd/internal/objabi/zbootstrap.go: +// +// package objabi +// +// const stackGuardMultiplierDefault = <multiplier value> +// +func mkobjabi(file string) { + var buf bytes.Buffer + fmt.Fprintf(&buf, "// Code generated by go tool dist; DO NOT EDIT.\n") + fmt.Fprintln(&buf) + fmt.Fprintf(&buf, "package objabi\n") + fmt.Fprintln(&buf) fmt.Fprintf(&buf, "const stackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault()) writefile(buf.String(), file, writeSkipSame) diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index 44b1886968..26b33e389f 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -58,6 +58,7 @@ var bootstrapDirs = []string{ "debug/macho", "debug/pe", "go/constant", + "internal/buildcfg", "internal/goexperiment", "internal/goversion", "internal/race", @@ -98,7 +99,8 @@ func bootstrapBuildTools() { } xprintf("Building Go toolchain1 using %s.\n", goroot_bootstrap) - mkzbootstrap(pathf("%s/src/cmd/internal/objabi/zbootstrap.go", goroot)) + mkbuildcfg(pathf("%s/src/internal/buildcfg/zbootstrap.go", goroot)) + mkobjabi(pathf("%s/src/cmd/internal/objabi/zbootstrap.go", goroot)) // Use $GOROOT/pkg/bootstrap as the bootstrap workspace root. // We use a subdirectory of $GOROOT/pkg because that's the |