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/asm | |
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/asm')
-rw-r--r-- | src/cmd/asm/internal/asm/endtoend_test.go | 6 | ||||
-rw-r--r-- | src/cmd/asm/internal/asm/operand_test.go | 6 | ||||
-rw-r--r-- | src/cmd/asm/internal/lex/input.go | 3 | ||||
-rw-r--r-- | src/cmd/asm/main.go | 7 |
4 files changed, 12 insertions, 10 deletions
diff --git a/src/cmd/asm/internal/asm/endtoend_test.go b/src/cmd/asm/internal/asm/endtoend_test.go index ee2982df39..ead8b27b01 100644 --- a/src/cmd/asm/internal/asm/endtoend_test.go +++ b/src/cmd/asm/internal/asm/endtoend_test.go @@ -8,6 +8,7 @@ import ( "bufio" "bytes" "fmt" + "internal/buildcfg" "io/ioutil" "os" "path/filepath" @@ -19,7 +20,6 @@ import ( "cmd/asm/internal/lex" "cmd/internal/obj" - "cmd/internal/objabi" ) // An end-to-end test for the assembler: Do we print what we parse? @@ -368,10 +368,10 @@ func Test386EndToEnd(t *testing.T) { } func TestARMEndToEnd(t *testing.T) { - defer func(old int) { objabi.GOARM = old }(objabi.GOARM) + defer func(old int) { buildcfg.GOARM = old }(buildcfg.GOARM) for _, goarm := range []int{5, 6, 7} { t.Logf("GOARM=%d", goarm) - objabi.GOARM = goarm + buildcfg.GOARM = goarm testEndToEnd(t, "arm", "arm") if goarm == 6 { testEndToEnd(t, "arm", "armv6") diff --git a/src/cmd/asm/internal/asm/operand_test.go b/src/cmd/asm/internal/asm/operand_test.go index c6def15e20..8ef02b1a0e 100644 --- a/src/cmd/asm/internal/asm/operand_test.go +++ b/src/cmd/asm/internal/asm/operand_test.go @@ -5,20 +5,20 @@ package asm import ( + "internal/buildcfg" "strings" "testing" "cmd/asm/internal/arch" "cmd/asm/internal/lex" "cmd/internal/obj" - "cmd/internal/objabi" ) // A simple in-out test: Do we print what we parse? func setArch(goarch string) (*arch.Arch, *obj.Link) { - objabi.GOOS = "linux" // obj can handle this OS for all architectures. - objabi.GOARCH = goarch + buildcfg.GOOS = "linux" // obj can handle this OS for all architectures. + buildcfg.GOARCH = goarch architecture := arch.Set(goarch) if architecture == nil { panic("asm: unrecognized architecture " + goarch) diff --git a/src/cmd/asm/internal/lex/input.go b/src/cmd/asm/internal/lex/input.go index aa03759c7d..e373ae817e 100644 --- a/src/cmd/asm/internal/lex/input.go +++ b/src/cmd/asm/internal/lex/input.go @@ -6,6 +6,7 @@ package lex import ( "fmt" + "internal/buildcfg" "os" "path/filepath" "strconv" @@ -49,7 +50,7 @@ func predefine(defines flags.MultiFlag) map[string]*Macro { // Set macros for GOEXPERIMENTs so we can easily switch // runtime assembly code based on them. if *flags.CompilingRuntime { - for _, exp := range objabi.EnabledExperiments() { + for _, exp := range buildcfg.EnabledExperiments() { // Define macro. name := "GOEXPERIMENT_" + exp macros[name] = &Macro{ diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 98618a67ef..e5a9ee565e 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -8,6 +8,7 @@ import ( "bufio" "flag" "fmt" + "internal/buildcfg" "log" "os" @@ -18,14 +19,14 @@ import ( "cmd/internal/bio" "cmd/internal/obj" - "cmd/internal/objabi" ) func main() { log.SetFlags(0) log.SetPrefix("asm: ") - GOARCH := objabi.GOARCH + buildcfg.Check() + GOARCH := buildcfg.GOARCH architecture := arch.Set(GOARCH) if architecture == nil { @@ -68,7 +69,7 @@ func main() { defer buf.Close() if !*flags.SymABIs { - fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version) + fmt.Fprintf(buf, "go object %s %s %s\n", buildcfg.GOOS, buildcfg.GOARCH, buildcfg.Version) fmt.Fprintf(buf, "!\n") } |