]> Cypherpunks.ru repositories - gostls13.git/commitdiff
internal/buildcfg: move build configuration out of cmd/internal/objabi
authorRuss Cox <rsc@golang.org>
Fri, 16 Apr 2021 03:05:49 +0000 (23:05 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 16 Apr 2021 19:20:53 +0000 (19:20 +0000)
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>
94 files changed:
.gitignore
src/cmd/asm/internal/asm/endtoend_test.go
src/cmd/asm/internal/asm/operand_test.go
src/cmd/asm/internal/lex/input.go
src/cmd/asm/main.go
src/cmd/cgo/main.go
src/cmd/compile/internal/amd64/ggen.go
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/arm/galign.go
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/arm64/ggen.go
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/base/print.go
src/cmd/compile/internal/dwarfgen/dwarf.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/logopt/log_opts.go
src/cmd/compile/internal/mips/galign.go
src/cmd/compile/internal/mips64/galign.go
src/cmd/compile/internal/noder/import.go
src/cmd/compile/internal/noder/lex.go
src/cmd/compile/internal/ppc64/galign.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/config.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/gen/Wasm.rules
src/cmd/compile/internal/ssa/gen/rulegen.go
src/cmd/compile/internal/ssa/nilcheck.go
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/ssa/rewrite386.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/cmd/compile/internal/ssa/rewriteARM.go
src/cmd/compile/internal/ssa/rewritePPC64.go
src/cmd/compile/internal/ssa/rewriteRISCV64.go
src/cmd/compile/internal/ssa/rewriteS390X.go
src/cmd/compile/internal/ssa/rewriteWasm.go
src/cmd/compile/internal/ssa/rewritegeneric.go
src/cmd/compile/internal/ssagen/abi.go
src/cmd/compile/internal/ssagen/pgen.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/staticdata/data.go
src/cmd/compile/internal/walk/expr.go
src/cmd/compile/internal/walk/order.go
src/cmd/compile/internal/walk/range.go
src/cmd/compile/internal/wasm/ssa.go
src/cmd/compile/internal/x86/galign.go
src/cmd/compile/main.go
src/cmd/dist/buildruntime.go
src/cmd/dist/buildtool.go
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/work/exec.go
src/cmd/go/internal/work/gc.go
src/cmd/go/internal/work/init.go
src/cmd/go/main.go
src/cmd/go/script_test.go
src/cmd/internal/dwarf/dwarf.go
src/cmd/internal/goobj/objfile_test.go
src/cmd/internal/obj/arm/asm5.go
src/cmd/internal/obj/arm/obj5.go
src/cmd/internal/obj/arm64/obj7.go
src/cmd/internal/obj/sym.go
src/cmd/internal/obj/util.go
src/cmd/internal/obj/x86/asm6.go
src/cmd/internal/obj/x86/obj6.go
src/cmd/internal/objabi/flag.go
src/cmd/internal/objabi/line.go
src/cmd/internal/objabi/stack.go
src/cmd/internal/objabi/util.go
src/cmd/link/internal/ld/ar.go
src/cmd/link/internal/ld/config.go
src/cmd/link/internal/ld/data_test.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/main.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/internal/ld/sym.go
src/cmd/link/internal/ld/symtab.go
src/cmd/link/internal/mips/obj.go
src/cmd/link/internal/mips64/obj.go
src/cmd/link/internal/ppc64/obj.go
src/cmd/link/internal/wasm/asm.go
src/cmd/link/linkbig_test.go
src/cmd/link/main.go
src/go/build/deps_test.go
src/internal/buildcfg/cfg.go [new file with mode: 0644]
src/internal/buildcfg/exp.go [moved from src/cmd/internal/objabi/exp.go with 94% similarity]
src/internal/goexperiment/flags.go

index 39723909c71c28974ce56903c9c52fc1386c3d24..aa62a9fad7104de144269ef1150df344eb638322 100644 (file)
@@ -37,6 +37,7 @@ _testmain.go
 /src/cmd/internal/objabi/zbootstrap.go
 /src/go/build/zcgo.go
 /src/go/doc/headscan
+/src/internal/buildcfg/zbootstrap.go
 /src/runtime/internal/sys/zversion.go
 /src/unicode/maketables
 /test.out
index ee2982df39f29060f28f4d8d32d91b443b527b3b..ead8b27b015df922982c11db2cb881dcb10a1765 100644 (file)
@@ -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")
index c6def15e20eac16b07239ecca149ac03a66e0929..8ef02b1a0e8acacafb379d12030e1c522de984f0 100644 (file)
@@ -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)
index aa03759c7d2908a7b4bf0eaf32cf7b07587cfd2b..e373ae817e0d83f70bdc3ae5fe7b58f89c179f26 100644 (file)
@@ -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{
index 98618a67ef5311c94ab19adfaa0d9e728898aa26..e5a9ee565ed29d655f24ddfa55c1dc14fe8b4b1c 100644 (file)
@@ -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")
        }
 
index 77ac5e0d3a7f3dca1354724bc71101706b8c8d14..03a662e689de8abe8229142c1e2ff37fd6e1f709 100644 (file)
@@ -17,6 +17,7 @@ import (
        "go/ast"
        "go/printer"
        "go/token"
+       "internal/buildcfg"
        "io"
        "io/ioutil"
        "os"
@@ -414,8 +415,9 @@ func newPackage(args []string) *Package {
        if s := os.Getenv("GOOS"); s != "" {
                goos = s
        }
-       gomips = objabi.GOMIPS
-       gomips64 = objabi.GOMIPS64
+       buildcfg.Check()
+       gomips = buildcfg.GOMIPS
+       gomips64 = buildcfg.GOMIPS64
        ptrSize := ptrSizeMap[goarch]
        if ptrSize == 0 {
                fatalf("unknown ptrSize for $GOARCH %q", goarch)
index b5847d48b98bcdac8883533a5186a33e43e76a0d..1484ad5404b4797552195b597fd0e22cab00e85b 100644 (file)
@@ -11,11 +11,11 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/x86"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 // no floating point in note handlers on Plan 9
-var isPlan9 = objabi.GOOS == "plan9"
+var isPlan9 = buildcfg.GOOS == "plan9"
 
 // DUFFZERO consists of repeated blocks of 4 MOVUPSs + LEAQ,
 // See runtime/mkduff.go.
@@ -85,7 +85,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj.
                }
                p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_R13, 0, obj.TYPE_MEM, x86.REG_SP, off)
        } else if !isPlan9 && cnt <= int64(8*types.RegSize) {
-               if !objabi.Experiment.RegabiG && *state&x15 == 0 {
+               if !buildcfg.Experiment.RegabiG && *state&x15 == 0 {
                        p = pp.Append(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_REG, x86.REG_X15, 0)
                        *state |= x15
                }
@@ -98,7 +98,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj.
                        p = pp.Append(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_MEM, x86.REG_SP, off+cnt-int64(16))
                }
        } else if !isPlan9 && (cnt <= int64(128*types.RegSize)) {
-               if !objabi.Experiment.RegabiG && *state&x15 == 0 {
+               if !buildcfg.Experiment.RegabiG && *state&x15 == 0 {
                        p = pp.Append(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_REG, x86.REG_X15, 0)
                        *state |= x15
                }
index fce3c6b8205416f1460ae6252375bb7f0529182e..42c12953f95a7685b24e309cd3f23bdfddd86680 100644 (file)
@@ -6,6 +6,7 @@ package amd64
 
 import (
        "fmt"
+       "internal/buildcfg"
        "math"
 
        "cmd/compile/internal/base"
@@ -17,7 +18,6 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/x86"
-       "cmd/internal/objabi"
 )
 
 // markMoves marks any MOVXconst ops that need to avoid clobbering flags.
@@ -825,7 +825,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                p.To.Reg = v.Args[0].Reg()
                ssagen.AddAux2(&p.To, v, sc.Off64())
        case ssa.OpAMD64MOVOstorezero:
-               if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal {
+               if !buildcfg.Experiment.RegabiG || s.ABI != obj.ABIInternal {
                        // zero X15 manually
                        opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
                }
@@ -916,7 +916,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
        case ssa.OpAMD64DUFFZERO:
-               if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal {
+               if !buildcfg.Experiment.RegabiG || s.ABI != obj.ABIInternal {
                        // zero X15 manually
                        opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
                }
@@ -999,20 +999,20 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                // Closure pointer is DX.
                ssagen.CheckLoweredGetClosurePtr(v)
        case ssa.OpAMD64LoweredGetG:
-               if objabi.Experiment.RegabiG && s.ABI == obj.ABIInternal {
+               if buildcfg.Experiment.RegabiG && s.ABI == obj.ABIInternal {
                        v.Fatalf("LoweredGetG should not appear in ABIInternal")
                }
                r := v.Reg()
                getgFromTLS(s, r)
        case ssa.OpAMD64CALLstatic:
-               if objabi.Experiment.RegabiG && s.ABI == obj.ABI0 && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABIInternal {
+               if buildcfg.Experiment.RegabiG && s.ABI == obj.ABI0 && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABIInternal {
                        // zeroing X15 when entering ABIInternal from ABI0
                        opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
                        // set G register from TLS
                        getgFromTLS(s, x86.REG_R14)
                }
                s.Call(v)
-               if objabi.Experiment.RegabiG && s.ABI == obj.ABIInternal && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABI0 {
+               if buildcfg.Experiment.RegabiG && s.ABI == obj.ABIInternal && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABI0 {
                        // zeroing X15 when entering ABIInternal from ABI0
                        opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
                        // set G register from TLS
@@ -1306,7 +1306,7 @@ func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) {
        case ssa.BlockRet:
                s.Prog(obj.ARET)
        case ssa.BlockRetJmp:
-               if objabi.Experiment.RegabiG && s.ABI == obj.ABI0 && b.Aux.(*obj.LSym).ABI() == obj.ABIInternal {
+               if buildcfg.Experiment.RegabiG && s.ABI == obj.ABI0 && b.Aux.(*obj.LSym).ABI() == obj.ABIInternal {
                        // zeroing X15 when entering ABIInternal from ABI0
                        opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15)
                        // set G register from TLS
index 81959ae0abcb32d5045a1980cdd4f5198433da84..d68500280d00b79376d976a39fab34286faa65a8 100644 (file)
@@ -8,14 +8,14 @@ import (
        "cmd/compile/internal/ssa"
        "cmd/compile/internal/ssagen"
        "cmd/internal/obj/arm"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 func Init(arch *ssagen.ArchInfo) {
        arch.LinkArch = &arm.Linkarm
        arch.REGSP = arm.REGSP
        arch.MAXWIDTH = (1 << 32) - 1
-       arch.SoftFloat = objabi.GOARM == 5
+       arch.SoftFloat = buildcfg.GOARM == 5
        arch.ZeroRange = zerorange
        arch.Ginsnop = ginsnop
        arch.Ginsnopdefer = ginsnop
index 832f940c261ee438228cd554003c3d5e2aa5e22b..4b083cec46b4a5cff59981de626a75f62fc0e1b7 100644 (file)
@@ -6,6 +6,7 @@ package arm
 
 import (
        "fmt"
+       "internal/buildcfg"
        "math"
        "math/bits"
 
@@ -17,7 +18,6 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/arm"
-       "cmd/internal/objabi"
 )
 
 // loadByType returns the load instruction of the given type.
@@ -286,7 +286,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
        case ssa.OpARMANDconst, ssa.OpARMBICconst:
                // try to optimize ANDconst and BICconst to BFC, which saves bytes and ticks
                // BFC is only available on ARMv7, and its result and source are in the same register
-               if objabi.GOARM == 7 && v.Reg() == v.Args[0].Reg() {
+               if buildcfg.GOARM == 7 && v.Reg() == v.Args[0].Reg() {
                        var val uint32
                        if v.Op == ssa.OpARMANDconst {
                                val = ^uint32(v.AuxInt)
@@ -643,7 +643,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                        default:
                        }
                }
-               if objabi.GOARM >= 6 {
+               if buildcfg.GOARM >= 6 {
                        // generate more efficient "MOVB/MOVBU/MOVH/MOVHU Reg@>0, Reg" on ARMv6 & ARMv7
                        genshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_RR, 0)
                        return
index 8364535f63bb8f49882faeb8d54ff2eb82cc6562..89be4964619c16a30f469de696451a0aec5bab51 100644 (file)
@@ -10,10 +10,10 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/arm64"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
-var darwin = objabi.GOOS == "darwin" || objabi.GOOS == "ios"
+var darwin = buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios"
 
 func padframe(frame int64) int64 {
        // arm64 requires that the frame size (not counting saved FP&LR)
index 4b7ef155a11573240162c2cbc359a924d350f84e..42c0c1b94b559c17ae593b9592b7ec5152e3a5f8 100644 (file)
@@ -8,6 +8,7 @@ import (
        "encoding/json"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "io/ioutil"
        "log"
        "os"
@@ -146,7 +147,7 @@ func ParseFlags() {
        Flag.LowerP = &Ctxt.Pkgpath
        Flag.LowerV = &Ctxt.Debugvlog
 
-       Flag.Dwarf = objabi.GOARCH != "wasm"
+       Flag.Dwarf = buildcfg.GOARCH != "wasm"
        Flag.DwarfBASEntries = &Ctxt.UseBASEntries
        Flag.DwarfLocationLists = &Ctxt.Flag_locationlists
        *Flag.DwarfLocationLists = true
@@ -168,14 +169,14 @@ func ParseFlags() {
        registerFlags()
        objabi.Flagparse(usage)
 
-       if Flag.MSan && !sys.MSanSupported(objabi.GOOS, objabi.GOARCH) {
-               log.Fatalf("%s/%s does not support -msan", objabi.GOOS, objabi.GOARCH)
+       if Flag.MSan && !sys.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) {
+               log.Fatalf("%s/%s does not support -msan", buildcfg.GOOS, buildcfg.GOARCH)
        }
-       if Flag.Race && !sys.RaceDetectorSupported(objabi.GOOS, objabi.GOARCH) {
-               log.Fatalf("%s/%s does not support -race", objabi.GOOS, objabi.GOARCH)
+       if Flag.Race && !sys.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) {
+               log.Fatalf("%s/%s does not support -race", buildcfg.GOOS, buildcfg.GOARCH)
        }
        if (*Flag.Shared || *Flag.Dynlink || *Flag.LinkShared) && !Ctxt.Arch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.PPC64, sys.RISCV64, sys.S390X) {
-               log.Fatalf("%s/%s does not support -shared", objabi.GOOS, objabi.GOARCH)
+               log.Fatalf("%s/%s does not support -shared", buildcfg.GOOS, buildcfg.GOARCH)
        }
        parseSpectre(Flag.Spectre) // left as string for RecordFlags
 
@@ -347,7 +348,7 @@ func concurrentBackendAllowed() bool {
                return false
        }
        // TODO: Test and delete this condition.
-       if objabi.Experiment.FieldTrack {
+       if buildcfg.Experiment.FieldTrack {
                return false
        }
        // TODO: fix races and enable the following flags
@@ -458,11 +459,11 @@ func parseSpectre(s string) {
        }
 
        if Flag.Cfg.SpectreIndex {
-               switch objabi.GOARCH {
+               switch buildcfg.GOARCH {
                case "amd64":
                        // ok
                default:
-                       log.Fatalf("GOARCH=%s does not support -spectre=index", objabi.GOARCH)
+                       log.Fatalf("GOARCH=%s does not support -spectre=index", buildcfg.GOARCH)
                }
        }
 }
index 668c600d31774c34bb016c3e5a8f366cdfd2c6ba..b095fd704daad807b3847bbd2916024356161af2 100644 (file)
@@ -6,12 +6,12 @@ package base
 
 import (
        "fmt"
+       "internal/buildcfg"
        "os"
        "runtime/debug"
        "sort"
        "strings"
 
-       "cmd/internal/objabi"
        "cmd/internal/src"
 )
 
@@ -217,7 +217,7 @@ func FatalfAt(pos src.XPos, format string, args ...interface{}) {
                fmt.Printf("\n")
 
                // If this is a released compiler version, ask for a bug report.
-               if strings.HasPrefix(objabi.Version, "go") {
+               if strings.HasPrefix(buildcfg.Version, "go") {
                        fmt.Printf("\n")
                        fmt.Printf("Please file a bug report including a short program that triggers the error.\n")
                        fmt.Printf("https://golang.org/issue/new\n")
index 7b5863bbc6e319cb2611b5b55909ff8b10add404..0754a8810c7bb824b05361ffd39e1406afc90023 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bytes"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "sort"
 
        "cmd/compile/internal/base"
@@ -278,7 +279,7 @@ func createSimpleVar(fnsym *obj.LSym, n *ir.Name) *dwarf.Var {
                if base.Ctxt.FixedFrameSize() == 0 {
                        offs -= int64(types.PtrSize)
                }
-               if objabi.FramePointerEnabled {
+               if buildcfg.FramePointerEnabled {
                        offs -= int64(types.PtrSize)
                }
 
index 68506c7a7b7d5e6074106f994d414754616a49b6..ce50cbb4c2e691ed3054d20894fc1bc722623eda 100644 (file)
@@ -28,6 +28,7 @@ import (
        "cmd/internal/src"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "log"
        "os"
        "runtime"
@@ -158,7 +159,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
                dwarf.EnableLogging(base.Debug.DwarfInl != 0)
        }
        if base.Debug.SoftFloat != 0 {
-               if objabi.Experiment.RegabiArgs {
+               if buildcfg.Experiment.RegabiArgs {
                        log.Fatalf("softfloat mode with GOEXPERIMENT=regabiargs not implemented ")
                }
                ssagen.Arch.SoftFloat = true
@@ -335,7 +336,7 @@ func writebench(filename string) error {
        }
 
        var buf bytes.Buffer
-       fmt.Fprintln(&buf, "commit:", objabi.Version)
+       fmt.Fprintln(&buf, "commit:", buildcfg.Version)
        fmt.Fprintln(&buf, "goos:", runtime.GOOS)
        fmt.Fprintln(&buf, "goarch:", runtime.GOARCH)
        base.Timer.Write(&buf, "BenchmarkCompile:"+base.Ctxt.Pkgpath+":")
index 37a049d6403dcb5216d41912a308b5e43433cb8d..97ebf569448982ddc478cbe5cc2cf6211aa8bc2e 100644 (file)
@@ -6,10 +6,10 @@ package logopt
 
 import (
        "cmd/internal/obj"
-       "cmd/internal/objabi"
        "cmd/internal/src"
        "encoding/json"
        "fmt"
+       "internal/buildcfg"
        "io"
        "log"
        "net/url"
@@ -408,7 +408,7 @@ func uprootedPath(filename string) string {
        if !strings.HasPrefix(filename, "$GOROOT/") {
                return filename
        }
-       return objabi.GOROOT + filename[len("$GOROOT"):]
+       return buildcfg.GOROOT + filename[len("$GOROOT"):]
 }
 
 // FlushLoggedOpts flushes all the accumulated optimization log entries.
@@ -448,7 +448,7 @@ func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string) {
                                currentFile = p0f
                                w = writerForLSP(subdirpath, currentFile)
                                encoder = json.NewEncoder(w)
-                               encoder.Encode(VersionHeader{Version: 0, Package: slashPkgPath, Goos: objabi.GOOS, Goarch: objabi.GOARCH, GcVersion: objabi.Version, File: currentFile})
+                               encoder.Encode(VersionHeader{Version: 0, Package: slashPkgPath, Goos: buildcfg.GOOS, Goarch: buildcfg.GOARCH, GcVersion: buildcfg.Version, File: currentFile})
                        }
 
                        // The first "target" is the most important one.
index 599163550bb2942ee4d64aa570edecfe4efef5d1..f892923ba038f32a370873af79a9671e55e65a1b 100644 (file)
@@ -8,17 +8,17 @@ import (
        "cmd/compile/internal/ssa"
        "cmd/compile/internal/ssagen"
        "cmd/internal/obj/mips"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 func Init(arch *ssagen.ArchInfo) {
        arch.LinkArch = &mips.Linkmips
-       if objabi.GOARCH == "mipsle" {
+       if buildcfg.GOARCH == "mipsle" {
                arch.LinkArch = &mips.Linkmipsle
        }
        arch.REGSP = mips.REGSP
        arch.MAXWIDTH = (1 << 31) - 1
-       arch.SoftFloat = (objabi.GOMIPS == "softfloat")
+       arch.SoftFloat = (buildcfg.GOMIPS == "softfloat")
        arch.ZeroRange = zerorange
        arch.Ginsnop = ginsnop
        arch.Ginsnopdefer = ginsnop
index fc0a34228c8f40bb70dd753aea0756777ed2f864..af81366e51bdf51c4cd88b55da03440da29773c6 100644 (file)
@@ -8,17 +8,17 @@ import (
        "cmd/compile/internal/ssa"
        "cmd/compile/internal/ssagen"
        "cmd/internal/obj/mips"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 func Init(arch *ssagen.ArchInfo) {
        arch.LinkArch = &mips.Linkmips64
-       if objabi.GOARCH == "mips64le" {
+       if buildcfg.GOARCH == "mips64le" {
                arch.LinkArch = &mips.Linkmips64le
        }
        arch.REGSP = mips.REGSP
        arch.MAXWIDTH = 1 << 50
-       arch.SoftFloat = objabi.GOMIPS64 == "softfloat"
+       arch.SoftFloat = buildcfg.GOMIPS64 == "softfloat"
        arch.ZeroRange = zerorange
        arch.Ginsnop = ginsnop
        arch.Ginsnopdefer = ginsnop
index e6e3fe1834253de8babdf64c3537b37be512eb93..701e9001c859ea8d2819b0e2850a1604e8e0c978 100644 (file)
@@ -7,6 +7,7 @@ package noder
 import (
        "errors"
        "fmt"
+       "internal/buildcfg"
        "io"
        "os"
        pathpkg "path"
@@ -108,7 +109,7 @@ func openPackage(path string) (*os.File, error) {
                }
        }
 
-       if objabi.GOROOT != "" {
+       if buildcfg.GOROOT != "" {
                suffix := ""
                if base.Flag.InstallSuffix != "" {
                        suffix = "_" + base.Flag.InstallSuffix
@@ -118,10 +119,10 @@ func openPackage(path string) (*os.File, error) {
                        suffix = "_msan"
                }
 
-               if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil {
+               if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil {
                        return file, nil
                }
-               if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil {
+               if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil {
                        return file, nil
                }
        }
index 60b724d154fb8925da12a8c0173f119d923795f0..66a56a50ec8ebcf2f1f63ecbfa545b0e64c7b37b 100644 (file)
@@ -6,11 +6,11 @@ package noder
 
 import (
        "fmt"
+       "internal/buildcfg"
        "strings"
 
        "cmd/compile/internal/ir"
        "cmd/compile/internal/syntax"
-       "cmd/internal/objabi"
 )
 
 func isSpace(c rune) bool {
@@ -44,7 +44,7 @@ func pragmaFlag(verb string) ir.PragmaFlag {
        case "go:build":
                return ir.GoBuildPragma
        case "go:nointerface":
-               if objabi.Experiment.FieldTrack {
+               if buildcfg.Experiment.FieldTrack {
                        return ir.Nointerface
                }
        case "go:noescape":
@@ -110,7 +110,7 @@ func (p *noder) pragcgo(pos syntax.Pos, text string) {
                case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]):
                case len(f) == 4 && !isQuoted(f[1]) && !isQuoted(f[2]) && isQuoted(f[3]):
                        f[3] = strings.Trim(f[3], `"`)
-                       if objabi.GOOS == "aix" && f[3] != "" {
+                       if buildcfg.GOOS == "aix" && f[3] != "" {
                                // On Aix, library pattern must be "lib.a/object.o"
                                // or "lib.a/libname.so.X"
                                n := strings.Split(f[3], "/")
index c72d1aa8348c40f27df9e45fa0b0b6fa0a55b133..590290fa371008db507ade8df55c54b4bc160f69 100644 (file)
@@ -7,12 +7,12 @@ package ppc64
 import (
        "cmd/compile/internal/ssagen"
        "cmd/internal/obj/ppc64"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 func Init(arch *ssagen.ArchInfo) {
        arch.LinkArch = &ppc64.Linkppc64
-       if objabi.GOARCH == "ppc64le" {
+       if buildcfg.GOARCH == "ppc64le" {
                arch.LinkArch = &ppc64.Linkppc64le
        }
        arch.REGSP = ppc64.REGSP
index a0ad69a68d250ea2b4a9f489bdf7f9a17e97bf9e..11226f65a0f01639359fe2992e2f266b2301be20 100644 (file)
@@ -13,7 +13,7 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/ppc64"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
        "math"
        "strings"
 )
@@ -1873,7 +1873,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                s.UseArgs(16) // space used in callee args area by assembly stubs
 
        case ssa.OpPPC64LoweredNilCheck:
-               if objabi.GOOS == "aix" {
+               if buildcfg.GOOS == "aix" {
                        // CMP Rarg0, R0
                        // BNE 2(PC)
                        // STW R0, 0(R0)
index 379735e86bb0f6e45ae58ad2be78e02b3693d18f..f0a60998a1455a223899075a15e1627e40b587f2 100644 (file)
@@ -6,6 +6,7 @@ package reflectdata
 
 import (
        "fmt"
+       "internal/buildcfg"
        "os"
        "sort"
        "strings"
@@ -1774,7 +1775,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym {
        // Disable tailcall for RegabiArgs for now. The IR does not connect the
        // arguments with the OTAILCALL node, and the arguments are not marshaled
        // correctly.
-       if !base.Flag.Cfg.Instrumenting && rcvr.IsPtr() && methodrcvr.IsPtr() && method.Embedded != 0 && !types.IsInterfaceMethod(method.Type) && !(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) && !objabi.Experiment.RegabiArgs {
+       if !base.Flag.Cfg.Instrumenting && rcvr.IsPtr() && methodrcvr.IsPtr() && method.Embedded != 0 && !types.IsInterfaceMethod(method.Type) && !(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) && !buildcfg.Experiment.RegabiArgs {
                // generate tail call: adjust pointer receiver and jump to embedded method.
                left := dot.X // skip final .M
                if !left.Type().IsPtr() {
index b1bcd4566ef8e147fc8f83def5dee2756b7b1d0b..8aae04f2ec0181701f6b956f9b86fcd22cae3c74 100644 (file)
@@ -6,10 +6,10 @@ package ssa
 
 import (
        "bytes"
-       "cmd/internal/objabi"
        "cmd/internal/src"
        "fmt"
        "hash/crc32"
+       "internal/buildcfg"
        "log"
        "math/rand"
        "os"
@@ -454,7 +454,7 @@ var passes = [...]pass{
        {name: "dse", fn: dse},
        {name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
        {name: "insert resched checks", fn: insertLoopReschedChecks,
-               disabled: !objabi.Experiment.PreemptibleLoops}, // insert resched checks in loops.
+               disabled: !buildcfg.Experiment.PreemptibleLoops}, // insert resched checks in loops.
        {name: "lower", fn: lower, required: true},
        {name: "addressing modes", fn: addressingModes, required: false},
        {name: "lowered deadcode for cse", fn: deadcode}, // deadcode immediately before CSE avoids CSE making dead values live again
index 75fa71ce353db13df93e4f7a9094ea033eceae73..4ffa047096b17a2c245e2f0526990b57389374cb 100644 (file)
@@ -9,8 +9,8 @@ import (
        "cmd/compile/internal/ir"
        "cmd/compile/internal/types"
        "cmd/internal/obj"
-       "cmd/internal/objabi"
        "cmd/internal/src"
+       "internal/buildcfg"
 )
 
 // A Config holds readonly compilation information.
@@ -203,7 +203,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
                c.floatParamRegs = paramFloatRegAMD64
                c.FPReg = framepointerRegAMD64
                c.LinkReg = linkRegAMD64
-               c.hasGReg = objabi.Experiment.RegabiG
+               c.hasGReg = buildcfg.Experiment.RegabiG
        case "386":
                c.PtrSize = 4
                c.RegSize = 4
@@ -238,7 +238,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
                c.FPReg = framepointerRegARM64
                c.LinkReg = linkRegARM64
                c.hasGReg = true
-               c.noDuffDevice = objabi.GOOS == "darwin" || objabi.GOOS == "ios" // darwin linker cannot handle BR26 reloc with non-zero addend
+               c.noDuffDevice = buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios" // darwin linker cannot handle BR26 reloc with non-zero addend
        case "ppc64":
                c.BigEndian = true
                fallthrough
@@ -336,7 +336,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
        c.ABI1 = abi.NewABIConfig(len(c.intParamRegs), len(c.floatParamRegs), ctxt.FixedFrameSize())
 
        // On Plan 9, floating point operations are not allowed in note handler.
-       if objabi.GOOS == "plan9" {
+       if buildcfg.GOOS == "plan9" {
                // Don't use FMA on Plan 9
                c.UseFMA = false
 
index 839d4a330e2c610cc35bd0b41837dd8c7d59c040..7a88a488c03928e4f0a1dcb67da3fc24eeae4292 100644 (file)
 (IsInBounds idx len) => (SETB (CMPQ idx len))
 (IsSliceInBounds idx len) => (SETBE (CMPQ idx len))
 (NilCheck ...) => (LoweredNilCheck ...)
-(GetG mem) && !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register.
+(GetG mem) && !(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register.
 (GetClosurePtr ...) => (LoweredGetClosurePtr ...)
 (GetCallerPC ...) => (LoweredGetCallerPC ...)
 (GetCallerSP ...) => (LoweredGetCallerSP ...)
index 5c6438a9866b8f6458ea9b29269a5d54b20eb836..bcacbafe3a5f0299dd47e45962a46170bd9896d4 100644 (file)
 
 // count trailing zero for ARMv5 and ARMv6
 // 32 - CLZ(x&-x - 1)
-(Ctz32 <t> x) && objabi.GOARM<=6 =>
+(Ctz32 <t> x) && buildcfg.GOARM<=6 =>
        (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
-(Ctz16 <t> x) && objabi.GOARM<=6 =>
+(Ctz16 <t> x) && buildcfg.GOARM<=6 =>
        (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x10000] x))) [1])))
-(Ctz8 <t> x) && objabi.GOARM<=6 =>
+(Ctz8 <t> x) && buildcfg.GOARM<=6 =>
        (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x100] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x100] x))) [1])))
 
 // count trailing zero for ARMv7
-(Ctz32 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <t> x))
-(Ctz16 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x)))
-(Ctz8 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x)))
+(Ctz32 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <t> x))
+(Ctz16 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x)))
+(Ctz8 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x)))
 
 // bit length
 (BitLen32 <t> x) => (RSBconst [32] (CLZ <t> x))
 // t5 = x right rotate 8 bits  -- (d,   a,   b,   c  )
 // result = t4 ^ t5            -- (d,   c,   b,   a  )
 // using shifted ops this can be done in 4 instructions.
-(Bswap32 <t> x) && objabi.GOARM==5 =>
+(Bswap32 <t> x) && buildcfg.GOARM==5 =>
        (XOR <t>
                (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8])
                (SRRconst <t> x [8]))
 
 // byte swap for ARMv6 and above
-(Bswap32 x) && objabi.GOARM>=6 => (REV x)
+(Bswap32 x) && buildcfg.GOARM>=6 => (REV x)
 
 // boolean ops -- booleans are represented with 0=false, 1=true
 (AndB ...) => (AND ...)
 (SUBconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) => (ADDconst [-c] x)
 (ANDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) => (BICconst [int32(^uint32(c))] x)
 (BICconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) => (ANDconst [int32(^uint32(c))] x)
-(ADDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (SUBconst [-c] x)
-(SUBconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (ADDconst [-c] x)
-(ANDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (BICconst [int32(^uint32(c))] x)
-(BICconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (ANDconst [int32(^uint32(c))] x)
+(ADDconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (SUBconst [-c] x)
+(SUBconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (ADDconst [-c] x)
+(ANDconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (BICconst [int32(^uint32(c))] x)
+(BICconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (ANDconst [int32(^uint32(c))] x)
 (ADDconst [c] (MOVWconst [d])) => (MOVWconst [c+d])
 (ADDconst [c] (ADDconst [d] x)) => (ADDconst [c+d] x)
 (ADDconst [c] (SUBconst [d] x)) => (ADDconst [c-d] x)
 // UBFX instruction is supported by ARMv6T2, ARMv7 and above versions, REV16 is supported by
 // ARMv6 and above versions. So for ARMv6, we need to match SLLconst, SRLconst and ORshiftLL.
 ((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (BFXU <typ.UInt16> [int32(armBFAuxInt(8, 8))] x) x) => (REV16 x)
-((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) && objabi.GOARM>=6 => (REV16 x)
+((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) && buildcfg.GOARM>=6 => (REV16 x)
 
 // use indexed loads and stores
 (MOVWload [0] {sym} (ADD ptr idx) mem) && sym == nil => (MOVWloadidx ptr idx mem)
 (BIC x x) => (MOVWconst [0])
 
 (ADD (MUL x y) a) => (MULA x y a)
-(SUB a (MUL x y)) && objabi.GOARM == 7 => (MULS x y a)
-(RSB (MUL x y) a) && objabi.GOARM == 7 => (MULS x y a)
+(SUB a (MUL x y)) && buildcfg.GOARM == 7 => (MULS x y a)
+(RSB (MUL x y) a) && buildcfg.GOARM == 7 => (MULS x y a)
 
-(NEGF (MULF x y)) && objabi.GOARM >= 6 => (NMULF x y)
-(NEGD (MULD x y)) && objabi.GOARM >= 6 => (NMULD x y)
-(MULF (NEGF x) y) && objabi.GOARM >= 6 => (NMULF x y)
-(MULD (NEGD x) y) && objabi.GOARM >= 6 => (NMULD x y)
+(NEGF (MULF x y)) && buildcfg.GOARM >= 6 => (NMULF x y)
+(NEGD (MULD x y)) && buildcfg.GOARM >= 6 => (NMULD x y)
+(MULF (NEGF x) y) && buildcfg.GOARM >= 6 => (NMULF x y)
+(MULD (NEGD x) y) && buildcfg.GOARM >= 6 => (NMULD x y)
 (NMULF (NEGF x) y) => (MULF x y)
 (NMULD (NEGD x) y) => (MULD x y)
 
 // the result will overwrite the addend, since they are in the same register
-(ADDF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAF a x y)
-(ADDF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSF a x y)
-(ADDD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAD a x y)
-(ADDD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSD a x y)
-(SUBF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSF a x y)
-(SUBF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAF a x y)
-(SUBD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSD a x y)
-(SUBD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAD a x y)
+(ADDF a (MULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAF a x y)
+(ADDF a (NMULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSF a x y)
+(ADDD a (MULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAD a x y)
+(ADDD a (NMULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSD a x y)
+(SUBF a (MULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSF a x y)
+(SUBF a (NMULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAF a x y)
+(SUBD a (MULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSD a x y)
+(SUBD a (NMULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAD a x y)
 
 (AND x (MVN y)) => (BIC x y)
 
 (CMPD x (MOVDconst [0])) => (CMPD0 x)
 
 // bit extraction
-(SRAconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFX [(d-c)|(32-d)<<8] x)
-(SRLconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFXU [(d-c)|(32-d)<<8] x)
+(SRAconst (SLLconst x [c]) [d]) && buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFX [(d-c)|(32-d)<<8] x)
+(SRLconst (SLLconst x [c]) [d]) && buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFXU [(d-c)|(32-d)<<8] x)
 
 // comparison simplification
 ((LT|LE|EQ|NE|GE|GT) (CMP x (RSBconst [0] y))) => ((LT|LE|EQ|NE|GE|GT) (CMN x y)) // sense of carry bit not preserved
index f83ff75761290984a0095142fec98a6ddb61135a..ce4b324b5e10227bef0406b69f33b2bdef3652c9 100644 (file)
 (Sub64F ...) => (FSUB ...)
 
 // Combine 64 bit integer multiply and adds
-(ADD l:(MULLD x y) z) && objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) => (MADDLD x y z)
+(ADD l:(MULLD x y) z) && buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) => (MADDLD x y z)
 
 (Mod16 x y) => (Mod32 (SignExt16to32 x) (SignExt16to32 y))
 (Mod16u x y) => (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y))
 (Mod8 x y) => (Mod32 (SignExt8to32 x) (SignExt8to32 y))
 (Mod8u x y) => (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y))
-(Mod64 x y) && objabi.GOPPC64 >=9 => (MODSD x y)
-(Mod64 x y) && objabi.GOPPC64 <=8 => (SUB x (MULLD y (DIVD x y)))
-(Mod64u x y) && objabi.GOPPC64 >= 9 => (MODUD x y)
-(Mod64u x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLD y (DIVDU x y)))
-(Mod32 x y) && objabi.GOPPC64 >= 9 => (MODSW x y)
-(Mod32 x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLW y (DIVW x y)))
-(Mod32u x y) && objabi.GOPPC64 >= 9 => (MODUW x y)
-(Mod32u x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLW y (DIVWU x y)))
+(Mod64 x y) && buildcfg.GOPPC64 >=9 => (MODSD x y)
+(Mod64 x y) && buildcfg.GOPPC64 <=8 => (SUB x (MULLD y (DIVD x y)))
+(Mod64u x y) && buildcfg.GOPPC64 >= 9 => (MODUD x y)
+(Mod64u x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLD y (DIVDU x y)))
+(Mod32 x y) && buildcfg.GOPPC64 >= 9 => (MODSW x y)
+(Mod32 x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLW y (DIVW x y)))
+(Mod32u x y) && buildcfg.GOPPC64 >= 9 => (MODUW x y)
+(Mod32u x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLW y (DIVWU x y)))
 
 // (x + y) / 2 with x>=y => (x - y) / 2 + y
 (Avg64u <t> x y) => (ADD (SRDconst <t> (SUB <t> x y) [1]) y)
 (Ctz32NonZero ...) => (Ctz32 ...)
 (Ctz64NonZero ...) => (Ctz64 ...)
 
-(Ctz64 x) && objabi.GOPPC64<=8 => (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x))
+(Ctz64 x) && buildcfg.GOPPC64<=8 => (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x))
 (Ctz64 x) => (CNTTZD x)
-(Ctz32 x) && objabi.GOPPC64<=8 => (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x)))
+(Ctz32 x) && buildcfg.GOPPC64<=8 => (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x)))
 (Ctz32 x) => (CNTTZW (MOVWZreg x))
 (Ctz16 x) => (POPCNTW (MOVHZreg (ANDN <typ.Int16> (ADDconst <typ.Int16> [-1] x) x)))
 (Ctz8 x)  => (POPCNTB (MOVBZreg (ANDN <typ.UInt8> (ADDconst <typ.UInt8> [-1] x) x)))
 // Handle cases not handled above
 // Lowered Short cases do not generate loops, and as a result don't clobber
 // the address registers or flags.
-(Zero [s] ptr mem) && objabi.GOPPC64 <= 8 && s < 64 => (LoweredZeroShort [s] ptr mem)
-(Zero [s] ptr mem) && objabi.GOPPC64 <= 8 => (LoweredZero [s] ptr mem)
-(Zero [s] ptr mem) && s < 128 && objabi.GOPPC64 >= 9 => (LoweredQuadZeroShort [s] ptr mem)
-(Zero [s] ptr mem) && objabi.GOPPC64 >= 9 => (LoweredQuadZero [s] ptr mem)
+(Zero [s] ptr mem) && buildcfg.GOPPC64 <= 8 && s < 64 => (LoweredZeroShort [s] ptr mem)
+(Zero [s] ptr mem) && buildcfg.GOPPC64 <= 8 => (LoweredZero [s] ptr mem)
+(Zero [s] ptr mem) && s < 128 && buildcfg.GOPPC64 >= 9 => (LoweredQuadZeroShort [s] ptr mem)
+(Zero [s] ptr mem) && buildcfg.GOPPC64 >= 9 => (LoweredQuadZero [s] ptr mem)
 
 // moves
 (Move [0] _ _ mem) => mem
 
 // Large move uses a loop. Since the address is computed and the
 // offset is zero, any alignment can be used.
-(Move [s] dst src mem) && s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s) =>
+(Move [s] dst src mem) && s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s) =>
         (LoweredMove [s] dst src mem)
-(Move [s] dst src mem) && s > 8 && s <= 64 && objabi.GOPPC64 >= 9 =>
+(Move [s] dst src mem) && s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9 =>
         (LoweredQuadMoveShort [s] dst src mem)
-(Move [s] dst src mem) && s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s) =>
+(Move [s] dst src mem) && s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s) =>
         (LoweredQuadMove [s] dst src mem)
 
 // Calls
 (SLWconst [c] z:(ANDconst [d] x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x)
 (SLWconst [c] z:(AND (MOVDconst [d]) x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x)
 // special case for power9
-(SL(W|D)const [c] z:(MOVWreg x)) && c < 32 && objabi.GOPPC64 >= 9 => (EXTSWSLconst [c] x)
+(SL(W|D)const [c] z:(MOVWreg x)) && c < 32 && buildcfg.GOPPC64 >= 9 => (EXTSWSLconst [c] x)
 
 // Lose widening ops fed to stores
 (MOVBstore [off] {sym} ptr (MOV(B|BZ|H|HZ|W|WZ)reg x) mem) => (MOVBstore [off] {sym} ptr x mem)
index 7cda16b4b523a6ed8676b530a6fcae1bb9f06435..7ad3d1c72e1fb04db56f2b937410dd030de4fea7 100644 (file)
@@ -55,9 +55,9 @@
 (ZeroExt32to64        x:(I64Load32U _ _)) => x
 (ZeroExt16to(64|32)   x:(I64Load16U _ _)) => x
 (ZeroExt8to(64|32|16) x:(I64Load8U  _ _)) => x
-(SignExt32to64        x) && objabi.GOWASM.SignExt => (I64Extend32S x)
-(SignExt8to(64|32|16) x) && objabi.GOWASM.SignExt => (I64Extend8S x)
-(SignExt16to(64|32)   x) && objabi.GOWASM.SignExt => (I64Extend16S x)
+(SignExt32to64        x) && buildcfg.GOWASM.SignExt => (I64Extend32S x)
+(SignExt8to(64|32|16) x) && buildcfg.GOWASM.SignExt => (I64Extend8S x)
+(SignExt16to(64|32)   x) && buildcfg.GOWASM.SignExt => (I64Extend16S x)
 (SignExt32to64        x) => (I64ShrS (I64Shl x (I64Const [32])) (I64Const [32]))
 (SignExt16to(64|32)   x) => (I64ShrS (I64Shl x (I64Const [48])) (I64Const [48]))
 (SignExt8to(64|32|16) x) => (I64ShrS (I64Shl x (I64Const [56])) (I64Const [56]))
index fd672b2f7453c6491a6ac0ba93840b3642d704a8..fe8db4ed1f251898e7e4c5a449749a9ec263365c 100644 (file)
@@ -584,9 +584,9 @@ func fprint(w io.Writer, n Node) {
                fmt.Fprintf(w, "\npackage ssa\n")
                for _, path := range append([]string{
                        "fmt",
+                       "internal/buildcfg",
                        "math",
                        "cmd/internal/obj",
-                       "cmd/internal/objabi",
                        "cmd/compile/internal/base",
                        "cmd/compile/internal/types",
                }, n.Arch.imports...) {
index bae50657c9adc08311759abe4eb37e2a617c7a3e..14f511a5f1cfc6545f35a8f414b2a62b1cdae35d 100644 (file)
@@ -6,8 +6,8 @@ package ssa
 
 import (
        "cmd/compile/internal/ir"
-       "cmd/internal/objabi"
        "cmd/internal/src"
+       "internal/buildcfg"
 )
 
 // nilcheckelim eliminates unnecessary nil checks.
@@ -192,7 +192,7 @@ func nilcheckelim(f *Func) {
 const minZeroPage = 4096
 
 // faultOnLoad is true if a load to an address below minZeroPage will trigger a SIGSEGV.
-var faultOnLoad = objabi.GOOS != "aix"
+var faultOnLoad = buildcfg.GOOS != "aix"
 
 // nilcheckelim2 eliminates unnecessary nil checks.
 // Runs after lowering and scheduling.
index 1baff184b0b4fcff81238dee737f1b2c43dac556..336cd3d737ecd4d1e2cc21262361d7cd554831bf 100644 (file)
@@ -117,10 +117,10 @@ import (
        "cmd/compile/internal/base"
        "cmd/compile/internal/ir"
        "cmd/compile/internal/types"
-       "cmd/internal/objabi"
        "cmd/internal/src"
        "cmd/internal/sys"
        "fmt"
+       "internal/buildcfg"
        "math/bits"
        "unsafe"
 )
@@ -609,7 +609,7 @@ func (s *regAllocState) init(f *Func) {
        if s.f.Config.hasGReg {
                s.allocatable &^= 1 << s.GReg
        }
-       if objabi.FramePointerEnabled && s.f.Config.FPReg >= 0 {
+       if buildcfg.FramePointerEnabled && s.f.Config.FPReg >= 0 {
                s.allocatable &^= 1 << uint(s.f.Config.FPReg)
        }
        if s.f.Config.LinkReg != -1 {
index 1ec2d26f750f6b7998933fca8cbeb668d9188f1a..93b258afac256a3156cf465afdb5632212cca78d 100644 (file)
@@ -3,8 +3,10 @@
 
 package ssa
 
-import "math"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "math"
+)
 
 func rewriteValue386(v *Value) bool {
        switch v.Op {
index 1f56b70816ff67379f6272ba1576c49505f14262..dd92b41c206e7d2dbbb1a6012e6fc47c9e9182f0 100644 (file)
@@ -3,10 +3,12 @@
 
 package ssa
 
-import "math"
-import "cmd/internal/obj"
-import "cmd/internal/objabi"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "cmd/internal/obj"
+       "internal/buildcfg"
+       "math"
+)
 
 func rewriteValueAMD64(v *Value) bool {
        switch v.Op {
@@ -30466,11 +30468,11 @@ func rewriteValueAMD64_OpFloor(v *Value) bool {
 func rewriteValueAMD64_OpGetG(v *Value) bool {
        v_0 := v.Args[0]
        // match: (GetG mem)
-       // cond: !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)
+       // cond: !(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)
        // result: (LoweredGetG mem)
        for {
                mem := v_0
-               if !(!(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)) {
+               if !(!(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)) {
                        break
                }
                v.reset(OpAMD64LoweredGetG)
index 175bbc3e7e656a9cdc25a5397d0290efffccb792..25db5b9fbada885faa9666a23f96370af1ff27ee 100644 (file)
@@ -3,8 +3,10 @@
 
 package ssa
 
-import "cmd/internal/objabi"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "internal/buildcfg"
+)
 
 func rewriteValueARM(v *Value) bool {
        switch v.Op {
@@ -1475,7 +1477,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (ADDD a (MULD x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULAD a x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -1485,7 +1487,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool {
                        }
                        y := v_1.Args[1]
                        x := v_1.Args[0]
-                       if !(a.Uses == 1 && objabi.GOARM >= 6) {
+                       if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMMULAD)
@@ -1495,7 +1497,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool {
                break
        }
        // match: (ADDD a (NMULD x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULSD a x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -1505,7 +1507,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool {
                        }
                        y := v_1.Args[1]
                        x := v_1.Args[0]
-                       if !(a.Uses == 1 && objabi.GOARM >= 6) {
+                       if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMMULSD)
@@ -1520,7 +1522,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (ADDF a (MULF x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULAF a x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -1530,7 +1532,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool {
                        }
                        y := v_1.Args[1]
                        x := v_1.Args[0]
-                       if !(a.Uses == 1 && objabi.GOARM >= 6) {
+                       if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMMULAF)
@@ -1540,7 +1542,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool {
                break
        }
        // match: (ADDF a (NMULF x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULSF a x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -1550,7 +1552,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool {
                        }
                        y := v_1.Args[1]
                        x := v_1.Args[0]
-                       if !(a.Uses == 1 && objabi.GOARM >= 6) {
+                       if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMMULSF)
@@ -1946,12 +1948,12 @@ func rewriteValueARM_OpARMADDconst(v *Value) bool {
                return true
        }
        // match: (ADDconst [c] x)
-       // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff
+       // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff
        // result: (SUBconst [-c] x)
        for {
                c := auxIntToInt32(v.AuxInt)
                x := v_0
-               if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) {
+               if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) {
                        break
                }
                v.reset(OpARMSUBconst)
@@ -2082,7 +2084,7 @@ func rewriteValueARM_OpARMADDshiftLL(v *Value) bool {
                return true
        }
        // match: (ADDshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x)
-       // cond: objabi.GOARM>=6
+       // cond: buildcfg.GOARM>=6
        // result: (REV16 x)
        for {
                if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 {
@@ -2093,7 +2095,7 @@ func rewriteValueARM_OpARMADDshiftLL(v *Value) bool {
                        break
                }
                x := v_0_0.Args[0]
-               if x != v_1 || !(objabi.GOARM >= 6) {
+               if x != v_1 || !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMREV16)
@@ -2538,12 +2540,12 @@ func rewriteValueARM_OpARMANDconst(v *Value) bool {
                return true
        }
        // match: (ANDconst [c] x)
-       // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff
+       // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff
        // result: (BICconst [int32(^uint32(c))] x)
        for {
                c := auxIntToInt32(v.AuxInt)
                x := v_0
-               if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) {
+               if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) {
                        break
                }
                v.reset(OpARMBICconst)
@@ -3033,12 +3035,12 @@ func rewriteValueARM_OpARMBICconst(v *Value) bool {
                return true
        }
        // match: (BICconst [c] x)
-       // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff
+       // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff
        // result: (ANDconst [int32(^uint32(c))] x)
        for {
                c := auxIntToInt32(v.AuxInt)
                x := v_0
-               if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) {
+               if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) {
                        break
                }
                v.reset(OpARMANDconst)
@@ -7541,7 +7543,7 @@ func rewriteValueARM_OpARMMULD(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (MULD (NEGD x) y)
-       // cond: objabi.GOARM >= 6
+       // cond: buildcfg.GOARM >= 6
        // result: (NMULD x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -7550,7 +7552,7 @@ func rewriteValueARM_OpARMMULD(v *Value) bool {
                        }
                        x := v_0.Args[0]
                        y := v_1
-                       if !(objabi.GOARM >= 6) {
+                       if !(buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMNMULD)
@@ -7565,7 +7567,7 @@ func rewriteValueARM_OpARMMULF(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (MULF (NEGF x) y)
-       // cond: objabi.GOARM >= 6
+       // cond: buildcfg.GOARM >= 6
        // result: (NMULF x y)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -7574,7 +7576,7 @@ func rewriteValueARM_OpARMMULF(v *Value) bool {
                        }
                        x := v_0.Args[0]
                        y := v_1
-                       if !(objabi.GOARM >= 6) {
+                       if !(buildcfg.GOARM >= 6) {
                                continue
                        }
                        v.reset(OpARMNMULF)
@@ -8186,7 +8188,7 @@ func rewriteValueARM_OpARMMVNshiftRLreg(v *Value) bool {
 func rewriteValueARM_OpARMNEGD(v *Value) bool {
        v_0 := v.Args[0]
        // match: (NEGD (MULD x y))
-       // cond: objabi.GOARM >= 6
+       // cond: buildcfg.GOARM >= 6
        // result: (NMULD x y)
        for {
                if v_0.Op != OpARMMULD {
@@ -8194,7 +8196,7 @@ func rewriteValueARM_OpARMNEGD(v *Value) bool {
                }
                y := v_0.Args[1]
                x := v_0.Args[0]
-               if !(objabi.GOARM >= 6) {
+               if !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMNMULD)
@@ -8206,7 +8208,7 @@ func rewriteValueARM_OpARMNEGD(v *Value) bool {
 func rewriteValueARM_OpARMNEGF(v *Value) bool {
        v_0 := v.Args[0]
        // match: (NEGF (MULF x y))
-       // cond: objabi.GOARM >= 6
+       // cond: buildcfg.GOARM >= 6
        // result: (NMULF x y)
        for {
                if v_0.Op != OpARMMULF {
@@ -8214,7 +8216,7 @@ func rewriteValueARM_OpARMNEGF(v *Value) bool {
                }
                y := v_0.Args[1]
                x := v_0.Args[0]
-               if !(objabi.GOARM >= 6) {
+               if !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMNMULF)
@@ -8538,7 +8540,7 @@ func rewriteValueARM_OpARMORshiftLL(v *Value) bool {
                return true
        }
        // match: (ORshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x)
-       // cond: objabi.GOARM>=6
+       // cond: buildcfg.GOARM>=6
        // result: (REV16 x)
        for {
                if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 {
@@ -8549,7 +8551,7 @@ func rewriteValueARM_OpARMORshiftLL(v *Value) bool {
                        break
                }
                x := v_0_0.Args[0]
-               if x != v_1 || !(objabi.GOARM >= 6) {
+               if x != v_1 || !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMREV16)
@@ -9013,7 +9015,7 @@ func rewriteValueARM_OpARMRSB(v *Value) bool {
                return true
        }
        // match: (RSB (MUL x y) a)
-       // cond: objabi.GOARM == 7
+       // cond: buildcfg.GOARM == 7
        // result: (MULS x y a)
        for {
                if v_0.Op != OpARMMUL {
@@ -9022,7 +9024,7 @@ func rewriteValueARM_OpARMRSB(v *Value) bool {
                y := v_0.Args[1]
                x := v_0.Args[0]
                a := v_1
-               if !(objabi.GOARM == 7) {
+               if !(buildcfg.GOARM == 7) {
                        break
                }
                v.reset(OpARMMULS)
@@ -10449,7 +10451,7 @@ func rewriteValueARM_OpARMSRAconst(v *Value) bool {
                return true
        }
        // match: (SRAconst (SLLconst x [c]) [d])
-       // cond: objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31
+       // cond: buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31
        // result: (BFX [(d-c)|(32-d)<<8] x)
        for {
                d := auxIntToInt32(v.AuxInt)
@@ -10458,7 +10460,7 @@ func rewriteValueARM_OpARMSRAconst(v *Value) bool {
                }
                c := auxIntToInt32(v_0.AuxInt)
                x := v_0.Args[0]
-               if !(objabi.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) {
+               if !(buildcfg.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) {
                        break
                }
                v.reset(OpARMBFX)
@@ -10501,7 +10503,7 @@ func rewriteValueARM_OpARMSRLconst(v *Value) bool {
                return true
        }
        // match: (SRLconst (SLLconst x [c]) [d])
-       // cond: objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31
+       // cond: buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31
        // result: (BFXU [(d-c)|(32-d)<<8] x)
        for {
                d := auxIntToInt32(v.AuxInt)
@@ -10510,7 +10512,7 @@ func rewriteValueARM_OpARMSRLconst(v *Value) bool {
                }
                c := auxIntToInt32(v_0.AuxInt)
                x := v_0.Args[0]
-               if !(objabi.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) {
+               if !(buildcfg.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) {
                        break
                }
                v.reset(OpARMBFXU)
@@ -10723,7 +10725,7 @@ func rewriteValueARM_OpARMSUB(v *Value) bool {
                return true
        }
        // match: (SUB a (MUL x y))
-       // cond: objabi.GOARM == 7
+       // cond: buildcfg.GOARM == 7
        // result: (MULS x y a)
        for {
                a := v_0
@@ -10732,7 +10734,7 @@ func rewriteValueARM_OpARMSUB(v *Value) bool {
                }
                y := v_1.Args[1]
                x := v_1.Args[0]
-               if !(objabi.GOARM == 7) {
+               if !(buildcfg.GOARM == 7) {
                        break
                }
                v.reset(OpARMMULS)
@@ -10745,7 +10747,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (SUBD a (MULD x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULSD a x y)
        for {
                a := v_0
@@ -10754,7 +10756,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool {
                }
                y := v_1.Args[1]
                x := v_1.Args[0]
-               if !(a.Uses == 1 && objabi.GOARM >= 6) {
+               if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMMULSD)
@@ -10762,7 +10764,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool {
                return true
        }
        // match: (SUBD a (NMULD x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULAD a x y)
        for {
                a := v_0
@@ -10771,7 +10773,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool {
                }
                y := v_1.Args[1]
                x := v_1.Args[0]
-               if !(a.Uses == 1 && objabi.GOARM >= 6) {
+               if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMMULAD)
@@ -10784,7 +10786,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool {
        v_1 := v.Args[1]
        v_0 := v.Args[0]
        // match: (SUBF a (MULF x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULSF a x y)
        for {
                a := v_0
@@ -10793,7 +10795,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool {
                }
                y := v_1.Args[1]
                x := v_1.Args[0]
-               if !(a.Uses == 1 && objabi.GOARM >= 6) {
+               if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMMULSF)
@@ -10801,7 +10803,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool {
                return true
        }
        // match: (SUBF a (NMULF x y))
-       // cond: a.Uses == 1 && objabi.GOARM >= 6
+       // cond: a.Uses == 1 && buildcfg.GOARM >= 6
        // result: (MULAF a x y)
        for {
                a := v_0
@@ -10810,7 +10812,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool {
                }
                y := v_1.Args[1]
                x := v_1.Args[0]
-               if !(a.Uses == 1 && objabi.GOARM >= 6) {
+               if !(a.Uses == 1 && buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMMULAF)
@@ -11264,12 +11266,12 @@ func rewriteValueARM_OpARMSUBconst(v *Value) bool {
                return true
        }
        // match: (SUBconst [c] x)
-       // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff
+       // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff
        // result: (ADDconst [-c] x)
        for {
                c := auxIntToInt32(v.AuxInt)
                x := v_0
-               if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) {
+               if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) {
                        break
                }
                v.reset(OpARMADDconst)
@@ -12577,7 +12579,7 @@ func rewriteValueARM_OpARMXORshiftLL(v *Value) bool {
                return true
        }
        // match: (XORshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x)
-       // cond: objabi.GOARM>=6
+       // cond: buildcfg.GOARM>=6
        // result: (REV16 x)
        for {
                if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 {
@@ -12588,7 +12590,7 @@ func rewriteValueARM_OpARMXORshiftLL(v *Value) bool {
                        break
                }
                x := v_0_0.Args[0]
-               if x != v_1 || !(objabi.GOARM >= 6) {
+               if x != v_1 || !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMREV16)
@@ -12939,12 +12941,12 @@ func rewriteValueARM_OpBswap32(v *Value) bool {
        v_0 := v.Args[0]
        b := v.Block
        // match: (Bswap32 <t> x)
-       // cond: objabi.GOARM==5
+       // cond: buildcfg.GOARM==5
        // result: (XOR <t> (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8]) (SRRconst <t> x [8]))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM == 5) {
+               if !(buildcfg.GOARM == 5) {
                        break
                }
                v.reset(OpARMXOR)
@@ -12967,11 +12969,11 @@ func rewriteValueARM_OpBswap32(v *Value) bool {
                return true
        }
        // match: (Bswap32 x)
-       // cond: objabi.GOARM>=6
+       // cond: buildcfg.GOARM>=6
        // result: (REV x)
        for {
                x := v_0
-               if !(objabi.GOARM >= 6) {
+               if !(buildcfg.GOARM >= 6) {
                        break
                }
                v.reset(OpARMREV)
@@ -13054,12 +13056,12 @@ func rewriteValueARM_OpCtz16(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Ctz16 <t> x)
-       // cond: objabi.GOARM<=6
+       // cond: buildcfg.GOARM<=6
        // result: (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x10000] x))) [1])))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM <= 6) {
+               if !(buildcfg.GOARM <= 6) {
                        break
                }
                v.reset(OpARMRSBconst)
@@ -13081,12 +13083,12 @@ func rewriteValueARM_OpCtz16(v *Value) bool {
                return true
        }
        // match: (Ctz16 <t> x)
-       // cond: objabi.GOARM==7
+       // cond: buildcfg.GOARM==7
        // result: (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x)))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM == 7) {
+               if !(buildcfg.GOARM == 7) {
                        break
                }
                v.reset(OpARMCLZ)
@@ -13105,12 +13107,12 @@ func rewriteValueARM_OpCtz32(v *Value) bool {
        v_0 := v.Args[0]
        b := v.Block
        // match: (Ctz32 <t> x)
-       // cond: objabi.GOARM<=6
+       // cond: buildcfg.GOARM<=6
        // result: (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM <= 6) {
+               if !(buildcfg.GOARM <= 6) {
                        break
                }
                v.reset(OpARMRSBconst)
@@ -13129,12 +13131,12 @@ func rewriteValueARM_OpCtz32(v *Value) bool {
                return true
        }
        // match: (Ctz32 <t> x)
-       // cond: objabi.GOARM==7
+       // cond: buildcfg.GOARM==7
        // result: (CLZ <t> (RBIT <t> x))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM == 7) {
+               if !(buildcfg.GOARM == 7) {
                        break
                }
                v.reset(OpARMCLZ)
@@ -13151,12 +13153,12 @@ func rewriteValueARM_OpCtz8(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Ctz8 <t> x)
-       // cond: objabi.GOARM<=6
+       // cond: buildcfg.GOARM<=6
        // result: (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x100] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x100] x))) [1])))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM <= 6) {
+               if !(buildcfg.GOARM <= 6) {
                        break
                }
                v.reset(OpARMRSBconst)
@@ -13178,12 +13180,12 @@ func rewriteValueARM_OpCtz8(v *Value) bool {
                return true
        }
        // match: (Ctz8 <t> x)
-       // cond: objabi.GOARM==7
+       // cond: buildcfg.GOARM==7
        // result: (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x)))
        for {
                t := v.Type
                x := v_0
-               if !(objabi.GOARM == 7) {
+               if !(buildcfg.GOARM == 7) {
                        break
                }
                v.reset(OpARMCLZ)
index f181d433cc042757b99f4145e5f73e8549f8bc6a..fe7620c218449221cb1a9bc34e6f79f9914824fd 100644 (file)
@@ -3,9 +3,11 @@
 
 package ssa
 
-import "math"
-import "cmd/internal/objabi"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "internal/buildcfg"
+       "math"
+)
 
 func rewriteValuePPC64(v *Value) bool {
        switch v.Op {
@@ -1290,11 +1292,11 @@ func rewriteValuePPC64_OpCtz32(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Ctz32 x)
-       // cond: objabi.GOPPC64<=8
+       // cond: buildcfg.GOPPC64<=8
        // result: (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x)))
        for {
                x := v_0
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64POPCNTW)
@@ -1324,11 +1326,11 @@ func rewriteValuePPC64_OpCtz64(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Ctz64 x)
-       // cond: objabi.GOPPC64<=8
+       // cond: buildcfg.GOPPC64<=8
        // result: (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x))
        for {
                x := v_0
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64POPCNTD)
@@ -3286,12 +3288,12 @@ func rewriteValuePPC64_OpMod32(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Mod32 x y)
-       // cond: objabi.GOPPC64 >= 9
+       // cond: buildcfg.GOPPC64 >= 9
        // result: (MODSW x y)
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 >= 9) {
+               if !(buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64MODSW)
@@ -3299,12 +3301,12 @@ func rewriteValuePPC64_OpMod32(v *Value) bool {
                return true
        }
        // match: (Mod32 x y)
-       // cond: objabi.GOPPC64 <= 8
+       // cond: buildcfg.GOPPC64 <= 8
        // result: (SUB x (MULLW y (DIVW x y)))
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64SUB)
@@ -3323,12 +3325,12 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Mod32u x y)
-       // cond: objabi.GOPPC64 >= 9
+       // cond: buildcfg.GOPPC64 >= 9
        // result: (MODUW x y)
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 >= 9) {
+               if !(buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64MODUW)
@@ -3336,12 +3338,12 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool {
                return true
        }
        // match: (Mod32u x y)
-       // cond: objabi.GOPPC64 <= 8
+       // cond: buildcfg.GOPPC64 <= 8
        // result: (SUB x (MULLW y (DIVWU x y)))
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64SUB)
@@ -3360,12 +3362,12 @@ func rewriteValuePPC64_OpMod64(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Mod64 x y)
-       // cond: objabi.GOPPC64 >=9
+       // cond: buildcfg.GOPPC64 >=9
        // result: (MODSD x y)
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 >= 9) {
+               if !(buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64MODSD)
@@ -3373,12 +3375,12 @@ func rewriteValuePPC64_OpMod64(v *Value) bool {
                return true
        }
        // match: (Mod64 x y)
-       // cond: objabi.GOPPC64 <=8
+       // cond: buildcfg.GOPPC64 <=8
        // result: (SUB x (MULLD y (DIVD x y)))
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64SUB)
@@ -3397,12 +3399,12 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (Mod64u x y)
-       // cond: objabi.GOPPC64 >= 9
+       // cond: buildcfg.GOPPC64 >= 9
        // result: (MODUD x y)
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 >= 9) {
+               if !(buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64MODUD)
@@ -3410,12 +3412,12 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool {
                return true
        }
        // match: (Mod64u x y)
-       // cond: objabi.GOPPC64 <= 8
+       // cond: buildcfg.GOPPC64 <= 8
        // result: (SUB x (MULLD y (DIVDU x y)))
        for {
                x := v_0
                y := v_1
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64SUB)
@@ -3633,14 +3635,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool {
                return true
        }
        // match: (Move [s] dst src mem)
-       // cond: s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s)
+       // cond: s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s)
        // result: (LoweredMove [s] dst src mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                dst := v_0
                src := v_1
                mem := v_2
-               if !(s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s)) {
+               if !(s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s)) {
                        break
                }
                v.reset(OpPPC64LoweredMove)
@@ -3649,14 +3651,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool {
                return true
        }
        // match: (Move [s] dst src mem)
-       // cond: s > 8 && s <= 64 && objabi.GOPPC64 >= 9
+       // cond: s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9
        // result: (LoweredQuadMoveShort [s] dst src mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                dst := v_0
                src := v_1
                mem := v_2
-               if !(s > 8 && s <= 64 && objabi.GOPPC64 >= 9) {
+               if !(s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64LoweredQuadMoveShort)
@@ -3665,14 +3667,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool {
                return true
        }
        // match: (Move [s] dst src mem)
-       // cond: s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s)
+       // cond: s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s)
        // result: (LoweredQuadMove [s] dst src mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                dst := v_0
                src := v_1
                mem := v_2
-               if !(s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s)) {
+               if !(s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s)) {
                        break
                }
                v.reset(OpPPC64LoweredQuadMove)
@@ -3882,7 +3884,7 @@ func rewriteValuePPC64_OpPPC64ADD(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (ADD l:(MULLD x y) z)
-       // cond: objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)
+       // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)
        // result: (MADDLD x y z)
        for {
                for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
@@ -3893,7 +3895,7 @@ func rewriteValuePPC64_OpPPC64ADD(v *Value) bool {
                        y := l.Args[1]
                        x := l.Args[0]
                        z := v_1
-                       if !(objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) {
+                       if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) {
                                continue
                        }
                        v.reset(OpPPC64MADDLD)
@@ -13241,7 +13243,7 @@ func rewriteValuePPC64_OpPPC64SLDconst(v *Value) bool {
                break
        }
        // match: (SLDconst [c] z:(MOVWreg x))
-       // cond: c < 32 && objabi.GOPPC64 >= 9
+       // cond: c < 32 && buildcfg.GOPPC64 >= 9
        // result: (EXTSWSLconst [c] x)
        for {
                c := auxIntToInt64(v.AuxInt)
@@ -13250,7 +13252,7 @@ func rewriteValuePPC64_OpPPC64SLDconst(v *Value) bool {
                        break
                }
                x := z.Args[0]
-               if !(c < 32 && objabi.GOPPC64 >= 9) {
+               if !(c < 32 && buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64EXTSWSLconst)
@@ -13364,7 +13366,7 @@ func rewriteValuePPC64_OpPPC64SLWconst(v *Value) bool {
                break
        }
        // match: (SLWconst [c] z:(MOVWreg x))
-       // cond: c < 32 && objabi.GOPPC64 >= 9
+       // cond: c < 32 && buildcfg.GOPPC64 >= 9
        // result: (EXTSWSLconst [c] x)
        for {
                c := auxIntToInt64(v.AuxInt)
@@ -13373,7 +13375,7 @@ func rewriteValuePPC64_OpPPC64SLWconst(v *Value) bool {
                        break
                }
                x := z.Args[0]
-               if !(c < 32 && objabi.GOPPC64 >= 9) {
+               if !(c < 32 && buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64EXTSWSLconst)
@@ -16906,13 +16908,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool {
                return true
        }
        // match: (Zero [s] ptr mem)
-       // cond: objabi.GOPPC64 <= 8 && s < 64
+       // cond: buildcfg.GOPPC64 <= 8 && s < 64
        // result: (LoweredZeroShort [s] ptr mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                ptr := v_0
                mem := v_1
-               if !(objabi.GOPPC64 <= 8 && s < 64) {
+               if !(buildcfg.GOPPC64 <= 8 && s < 64) {
                        break
                }
                v.reset(OpPPC64LoweredZeroShort)
@@ -16921,13 +16923,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool {
                return true
        }
        // match: (Zero [s] ptr mem)
-       // cond: objabi.GOPPC64 <= 8
+       // cond: buildcfg.GOPPC64 <= 8
        // result: (LoweredZero [s] ptr mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                ptr := v_0
                mem := v_1
-               if !(objabi.GOPPC64 <= 8) {
+               if !(buildcfg.GOPPC64 <= 8) {
                        break
                }
                v.reset(OpPPC64LoweredZero)
@@ -16936,13 +16938,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool {
                return true
        }
        // match: (Zero [s] ptr mem)
-       // cond: s < 128 && objabi.GOPPC64 >= 9
+       // cond: s < 128 && buildcfg.GOPPC64 >= 9
        // result: (LoweredQuadZeroShort [s] ptr mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                ptr := v_0
                mem := v_1
-               if !(s < 128 && objabi.GOPPC64 >= 9) {
+               if !(s < 128 && buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64LoweredQuadZeroShort)
@@ -16951,13 +16953,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool {
                return true
        }
        // match: (Zero [s] ptr mem)
-       // cond: objabi.GOPPC64 >= 9
+       // cond: buildcfg.GOPPC64 >= 9
        // result: (LoweredQuadZero [s] ptr mem)
        for {
                s := auxIntToInt64(v.AuxInt)
                ptr := v_0
                mem := v_1
-               if !(objabi.GOPPC64 >= 9) {
+               if !(buildcfg.GOPPC64 >= 9) {
                        break
                }
                v.reset(OpPPC64LoweredQuadZero)
index 431fb1aaf66e0dd288704707d9ed909780533d4b..bc4b18e0cd6f7cbdc094633f29d50c1a2d173518 100644 (file)
@@ -3,8 +3,10 @@
 
 package ssa
 
-import "math"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "math"
+)
 
 func rewriteValueRISCV64(v *Value) bool {
        switch v.Op {
index 8b41d62c315bd25de6fa2adbdd553c17e1ca2a3e..49c58987046d640fa51b01a41dca984588b80714 100644 (file)
@@ -3,9 +3,11 @@
 
 package ssa
 
-import "math"
-import "cmd/compile/internal/types"
-import "cmd/internal/obj/s390x"
+import (
+       "cmd/compile/internal/types"
+       "cmd/internal/obj/s390x"
+       "math"
+)
 
 func rewriteValueS390X(v *Value) bool {
        switch v.Op {
index 6efcdfe37148150e07abd38f2ff6feaad8089931..ed23ae032a29c06233141cd497fa90a6f2981938 100644 (file)
@@ -3,9 +3,11 @@
 
 package ssa
 
-import "math"
-import "cmd/internal/objabi"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "internal/buildcfg"
+       "math"
+)
 
 func rewriteValueWasm(v *Value) bool {
        switch v.Op {
@@ -3193,11 +3195,11 @@ func rewriteValueWasm_OpSignExt16to32(v *Value) bool {
                return true
        }
        // match: (SignExt16to32 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend16S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend16S)
@@ -3232,11 +3234,11 @@ func rewriteValueWasm_OpSignExt16to64(v *Value) bool {
                return true
        }
        // match: (SignExt16to64 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend16S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend16S)
@@ -3271,11 +3273,11 @@ func rewriteValueWasm_OpSignExt32to64(v *Value) bool {
                return true
        }
        // match: (SignExt32to64 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend32S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend32S)
@@ -3310,11 +3312,11 @@ func rewriteValueWasm_OpSignExt8to16(v *Value) bool {
                return true
        }
        // match: (SignExt8to16 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend8S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend8S)
@@ -3349,11 +3351,11 @@ func rewriteValueWasm_OpSignExt8to32(v *Value) bool {
                return true
        }
        // match: (SignExt8to32 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend8S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend8S)
@@ -3388,11 +3390,11 @@ func rewriteValueWasm_OpSignExt8to64(v *Value) bool {
                return true
        }
        // match: (SignExt8to64 x)
-       // cond: objabi.GOWASM.SignExt
+       // cond: buildcfg.GOWASM.SignExt
        // result: (I64Extend8S x)
        for {
                x := v_0
-               if !(objabi.GOWASM.SignExt) {
+               if !(buildcfg.GOWASM.SignExt) {
                        break
                }
                v.reset(OpWasmI64Extend8S)
index 52258201ca105163e20197a200794c7604176ad2..0e5f49491ebcd245a70a01d8ef82d9d7b382921c 100644 (file)
@@ -3,8 +3,10 @@
 
 package ssa
 
-import "math"
-import "cmd/compile/internal/types"
+import (
+       "cmd/compile/internal/types"
+       "math"
+)
 
 func rewriteValuegeneric(v *Value) bool {
        switch v.Op {
index 8103b08ce51a7b1d5ef85b4f323a0296a898557e..7d563623020a0b9bdc1df86ae5b83ec669078ca8 100644 (file)
@@ -6,6 +6,7 @@ package ssagen
 
 import (
        "fmt"
+       "internal/buildcfg"
        "io/ioutil"
        "log"
        "os"
@@ -213,7 +214,7 @@ func (s *SymABIs) GenABIWrappers() {
                        base.Fatalf("cgo exported function %s cannot have ABI wrappers", fn)
                }
 
-               if !objabi.Experiment.RegabiWrappers {
+               if !buildcfg.Experiment.RegabiWrappers {
                        // We'll generate ABI aliases instead of
                        // wrappers once we have LSyms in InitLSym.
                        continue
@@ -241,7 +242,7 @@ func InitLSym(f *ir.Func, hasBody bool) {
                if f.Pragma&ir.Systemstack != 0 {
                        f.LSym.Set(obj.AttrCFunc, true)
                }
-               if f.ABI == obj.ABIInternal || !objabi.Experiment.RegabiWrappers {
+               if f.ABI == obj.ABIInternal || !buildcfg.Experiment.RegabiWrappers {
                        // Function values can only point to
                        // ABIInternal entry points. This will create
                        // the funcsym for either the defining
@@ -253,7 +254,7 @@ func InitLSym(f *ir.Func, hasBody bool) {
                        // when we see that.
                        staticdata.NeedFuncSym(f)
                }
-               if !objabi.Experiment.RegabiWrappers {
+               if !buildcfg.Experiment.RegabiWrappers {
                        // Create ABI aliases instead of wrappers.
                        forEachWrapperABI(f, makeABIAlias)
                }
index 92f6f562f3683f5fa88574aa94b7635784e08403..62567535d76caccdd37e1fdea3996b51a0fac13c 100644 (file)
@@ -5,6 +5,7 @@
 package ssagen
 
 import (
+       "internal/buildcfg"
        "internal/race"
        "math/rand"
        "sort"
@@ -215,7 +216,7 @@ func StackOffset(slot ssa.LocalSlot) int32 {
                if base.Ctxt.FixedFrameSize() == 0 {
                        off -= int64(types.PtrSize)
                }
-               if objabi.FramePointerEnabled {
+               if buildcfg.FramePointerEnabled {
                        off -= int64(types.PtrSize)
                }
        }
@@ -228,7 +229,7 @@ func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) {
        if fnsym == nil {
                return
        }
-       if !objabi.Experiment.FieldTrack || len(tracked) == 0 {
+       if !buildcfg.Experiment.FieldTrack || len(tracked) == 0 {
                return
        }
 
index 61f23a9c408fb394350fe8d9e47a6fb4c48fe5a3..f0bce0756a97f7369cf062ccd6f7cd6863883bb3 100644 (file)
@@ -12,6 +12,7 @@ import (
        "fmt"
        "go/constant"
        "html"
+       "internal/buildcfg"
        "os"
        "path/filepath"
        "sort"
@@ -227,7 +228,7 @@ const magicLastTypeName = "MagicLastTypeNameForTestingRegisterABI"
 // abiForFunc implements ABI policy for a function, but does not return a copy of the ABI.
 // Passing a nil function returns the default ABI based on experiment configuration.
 func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig {
-       if objabi.Experiment.RegabiArgs {
+       if buildcfg.Experiment.RegabiArgs {
                // Select the ABI based on the function's defining ABI.
                if fn == nil {
                        return abi1
@@ -4646,7 +4647,7 @@ func (s *state) openDeferRecord(n *ir.CallExpr) {
        var args []*ssa.Value
        var argNodes []*ir.Name
 
-       if objabi.Experiment.RegabiDefer && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
+       if buildcfg.Experiment.RegabiDefer && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
                s.Fatalf("defer call with arguments or results: %v", n)
        }
 
@@ -4883,7 +4884,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
 
        callABI := s.f.ABIDefault
 
-       if !objabi.Experiment.RegabiArgs {
+       if !buildcfg.Experiment.RegabiArgs {
                var magicFnNameSym *types.Sym
                if fn.Name() != nil {
                        magicFnNameSym = fn.Name().Sym()
@@ -4901,7 +4902,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
                }
        }
 
-       if objabi.Experiment.RegabiDefer && k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
+       if buildcfg.Experiment.RegabiDefer && k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
                s.Fatalf("go/defer call with arguments: %v", n)
        }
 
@@ -4910,7 +4911,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
                if k == callNormal && fn.Op() == ir.ONAME && fn.(*ir.Name).Class == ir.PFUNC {
                        fn := fn.(*ir.Name)
                        callee = fn
-                       if objabi.Experiment.RegabiArgs {
+                       if buildcfg.Experiment.RegabiArgs {
                                // This is a static call, so it may be
                                // a direct call to a non-ABIInternal
                                // function. fn.Func may be nil for
@@ -4951,7 +4952,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
                }
        }
 
-       if !objabi.Experiment.RegabiArgs {
+       if !buildcfg.Experiment.RegabiArgs {
                if regAbiForFuncType(n.X.Type().FuncType()) {
                        // Magic last type in input args to call
                        callABI = s.f.ABI1
@@ -5135,7 +5136,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
 // maybeNilCheckClosure checks if a nil check of a closure is needed in some
 // architecture-dependent situations and, if so, emits the nil check.
 func (s *state) maybeNilCheckClosure(closure *ssa.Value, k callKind) {
-       if Arch.LinkArch.Family == sys.Wasm || objabi.GOOS == "aix" && k != callGo {
+       if Arch.LinkArch.Family == sys.Wasm || buildcfg.GOOS == "aix" && k != callGo {
                // On AIX, the closure needs to be verified as fn can be nil, except if it's a call go. This needs to be handled by the runtime to have the "go of nil func value" error.
                // TODO(neelance): On other architectures this should be eliminated by the optimization steps
                s.nilCheck(closure)
@@ -6881,7 +6882,7 @@ func defframe(s *State, e *ssafn, f *ssa.Func) {
        // and not address-taken (for non-SSA-able or address-taken arguments we always
        // spill upfront).
        // TODO(register args) Make liveness more fine-grained to that partial spilling is okay.
-       if objabi.Experiment.RegabiArgs {
+       if buildcfg.Experiment.RegabiArgs {
                // First, see if it is already spilled before it may be live. Look for a spill
                // in the entry block up to the first safepoint.
                type nameOff struct {
index 7ca05d3bf47dd6392261a90684f47605c48d37c9..b5206c2442817526642c9bd9d9b12e1a2d919eec 100644 (file)
@@ -8,6 +8,7 @@ import (
        "crypto/sha256"
        "fmt"
        "go/constant"
+       "internal/buildcfg"
        "io"
        "io/ioutil"
        "os"
@@ -269,7 +270,7 @@ func NeedFuncSym(fn *ir.Func) {
                // funcsymsmu, like in FuncSym.
                base.Fatalf("NeedFuncSym must be called in serial")
        }
-       if fn.ABI != obj.ABIInternal && objabi.Experiment.RegabiWrappers {
+       if fn.ABI != obj.ABIInternal && buildcfg.Experiment.RegabiWrappers {
                // Function values must always reference ABIInternal
                // entry points, so it doesn't make sense to create a
                // funcsym for other ABIs.
index 0995c1314d0916266c4200041a7946cf00796f20..d8160d971c551c0b34c42ec46d970b66f9dc28c5 100644 (file)
@@ -7,6 +7,7 @@ package walk
 import (
        "fmt"
        "go/constant"
+       "internal/buildcfg"
        "strings"
 
        "cmd/compile/internal/base"
@@ -16,7 +17,6 @@ import (
        "cmd/compile/internal/typecheck"
        "cmd/compile/internal/types"
        "cmd/internal/obj"
-       "cmd/internal/objabi"
 )
 
 // The result of walkExpr MUST be assigned back to n, e.g.
@@ -927,7 +927,7 @@ func usemethod(n *ir.CallExpr) {
 }
 
 func usefield(n *ir.SelectorExpr) {
-       if !objabi.Experiment.FieldTrack {
+       if !buildcfg.Experiment.FieldTrack {
                return
        }
 
index 42d9d589713e9aeabe42e25036cd55db8e6cabeb..7b69f34e859854aa26dbb223b4975aa3a0f638cc 100644 (file)
@@ -7,6 +7,7 @@ package walk
 import (
        "fmt"
        "go/constant"
+       "internal/buildcfg"
 
        "cmd/compile/internal/base"
        "cmd/compile/internal/escape"
@@ -15,7 +16,6 @@ import (
        "cmd/compile/internal/staticinit"
        "cmd/compile/internal/typecheck"
        "cmd/compile/internal/types"
-       "cmd/internal/objabi"
        "cmd/internal/src"
 )
 
@@ -780,7 +780,7 @@ func (o *orderState) stmt(n ir.Node) {
                        n.Call = walkRecover(n.Call.(*ir.CallExpr), &init)
                        o.stmtList(init)
                }
-               if objabi.Experiment.RegabiDefer {
+               if buildcfg.Experiment.RegabiDefer {
                        o.wrapGoDefer(n)
                }
                o.out = append(o.out, n)
index 80bd8750faef93e1de40b6c152df5505cbdea8a6..3384bc826e9c2de01a6e79dfbb11489919741301 100644 (file)
@@ -170,7 +170,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
                th := hit.Type()
                // depends on layout of iterator struct.
                // See cmd/compile/internal/reflectdata/reflect.go:MapIterType
-               keysym := th.Field(0).Sym  
+               keysym := th.Field(0).Sym
                elemsym := th.Field(1).Sym // ditto
 
                fn := typecheck.LookupRuntime("mapiterinit")
index 904871b15f9665cbc9007989e38e9cf2fb267cc4..31b09016eb98296a3838bc39125dbb3f4f73a101 100644 (file)
@@ -14,7 +14,7 @@ import (
        "cmd/compile/internal/types"
        "cmd/internal/obj"
        "cmd/internal/obj/wasm"
-       "cmd/internal/objabi"
+       "internal/buildcfg"
 )
 
 func Init(arch *ssagen.ArchInfo) {
@@ -325,7 +325,7 @@ func ssaGenValueOnStack(s *ssagen.State, v *ssa.Value, extend bool) {
 
        case ssa.OpWasmI64TruncSatF32S, ssa.OpWasmI64TruncSatF64S:
                getValue64(s, v.Args[0])
-               if objabi.GOWASM.SatConv {
+               if buildcfg.GOWASM.SatConv {
                        s.Prog(v.Op.Asm())
                } else {
                        if v.Op == ssa.OpWasmI64TruncSatF32S {
@@ -337,7 +337,7 @@ func ssaGenValueOnStack(s *ssagen.State, v *ssa.Value, extend bool) {
 
        case ssa.OpWasmI64TruncSatF32U, ssa.OpWasmI64TruncSatF64U:
                getValue64(s, v.Args[0])
-               if objabi.GOWASM.SatConv {
+               if buildcfg.GOWASM.SatConv {
                        s.Prog(v.Op.Asm())
                } else {
                        if v.Op == ssa.OpWasmI64TruncSatF32U {
index fc806f91196df0da5f1fb3b93aa2b85d5e0be63e..00a20e429f1d6112cbf985e0b3c8706b187b0356 100644 (file)
@@ -8,8 +8,8 @@ import (
        "cmd/compile/internal/base"
        "cmd/compile/internal/ssagen"
        "cmd/internal/obj/x86"
-       "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "os"
 )
 
@@ -19,7 +19,7 @@ func Init(arch *ssagen.ArchInfo) {
        arch.SSAGenValue = ssaGenValue
        arch.SSAGenBlock = ssaGenBlock
        arch.MAXWIDTH = (1 << 32) - 1
-       switch v := objabi.GO386; v {
+       switch v := buildcfg.GO386; v {
        case "sse2":
        case "softfloat":
                arch.SoftFloat = true
index cb2f4e8cf475a74f263d07f2091e5c3ef184f0a9..3af1e1fafdfef2dbea6686e3e33398276ffb69f8 100644 (file)
@@ -18,8 +18,8 @@ import (
        "cmd/compile/internal/ssagen"
        "cmd/compile/internal/wasm"
        "cmd/compile/internal/x86"
-       "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "log"
        "os"
 )
@@ -45,9 +45,10 @@ func main() {
        log.SetFlags(0)
        log.SetPrefix("compile: ")
 
-       archInit, ok := archInits[objabi.GOARCH]
+       buildcfg.Check()
+       archInit, ok := archInits[buildcfg.GOARCH]
        if !ok {
-               fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", objabi.GOARCH)
+               fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", buildcfg.GOARCH)
                os.Exit(2)
        }
 
index 3ef551e187e9b11131f060c01b6b29ceeecdb313..54e935ad3bec1d35c5bf37732ed1bb659965792c 100644 (file)
@@ -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)
index 44b18869681ab41f1ac00a62e4a2beea7de29e9a..26b33e389fe9283aabd5c0c8f44fba88fa44ea8c 100644 (file)
@@ -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
index 810189c15d782589d8aa3acce6cde782680db282..b47eb812b59ea54d6911fa687ba01fbf6469bcb6 100644 (file)
@@ -10,6 +10,7 @@ import (
        "bytes"
        "fmt"
        "go/build"
+       "internal/buildcfg"
        "internal/cfg"
        "io"
        "os"
@@ -19,8 +20,6 @@ import (
        "sync"
 
        "cmd/go/internal/fsys"
-
-       "cmd/internal/objabi"
 )
 
 // These are general "build flags" used by build and other commands.
@@ -252,12 +251,12 @@ var (
        GOMODCACHE   = envOr("GOMODCACHE", gopathDir("pkg/mod"))
 
        // Used in envcmd.MkEnv and build ID computations.
-       GOARM    = envOr("GOARM", fmt.Sprint(objabi.GOARM))
-       GO386    = envOr("GO386", objabi.GO386)
-       GOMIPS   = envOr("GOMIPS", objabi.GOMIPS)
-       GOMIPS64 = envOr("GOMIPS64", objabi.GOMIPS64)
-       GOPPC64  = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", objabi.GOPPC64))
-       GOWASM   = envOr("GOWASM", fmt.Sprint(objabi.GOWASM))
+       GOARM    = envOr("GOARM", fmt.Sprint(buildcfg.GOARM))
+       GO386    = envOr("GO386", buildcfg.GO386)
+       GOMIPS   = envOr("GOMIPS", buildcfg.GOMIPS)
+       GOMIPS64 = envOr("GOMIPS64", buildcfg.GOMIPS64)
+       GOPPC64  = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", buildcfg.GOPPC64))
+       GOWASM   = envOr("GOWASM", fmt.Sprint(buildcfg.GOWASM))
 
        GOPROXY    = envOr("GOPROXY", "https://proxy.golang.org,direct")
        GOSUMDB    = envOr("GOSUMDB", "sum.golang.org")
index e1916007a6568558ae8625869451a20df227b999..a68bdd6d29accc573c638f23457e6eb4a5309abb 100644 (file)
@@ -12,6 +12,7 @@ import (
        "encoding/json"
        "errors"
        "fmt"
+       "internal/buildcfg"
        exec "internal/execabs"
        "internal/lazyregexp"
        "io"
@@ -35,7 +36,6 @@ import (
        "cmd/go/internal/modload"
        "cmd/go/internal/str"
        "cmd/go/internal/trace"
-       "cmd/internal/objabi"
 )
 
 // actionList returns the list of actions in the dag rooted at root
@@ -277,7 +277,7 @@ func (b *Builder) buildActionID(a *Action) cache.ActionID {
                key, val := cfg.GetArchEnv()
                fmt.Fprintf(h, "%s=%s\n", key, val)
 
-               if goexperiment := objabi.GOEXPERIMENT(); goexperiment != "" {
+               if goexperiment := buildcfg.GOEXPERIMENT(); goexperiment != "" {
                        fmt.Fprintf(h, "GOEXPERIMENT=%q\n", goexperiment)
                }
 
@@ -1251,7 +1251,7 @@ func (b *Builder) printLinkerConfig(h io.Writer, p *load.Package) {
                key, val := cfg.GetArchEnv()
                fmt.Fprintf(h, "%s=%s\n", key, val)
 
-               if goexperiment := objabi.GOEXPERIMENT(); goexperiment != "" {
+               if goexperiment := buildcfg.GOEXPERIMENT(); goexperiment != "" {
                        fmt.Fprintf(h, "GOEXPERIMENT=%q\n", goexperiment)
                }
 
index 60d0b29a21ed0eae046f67cd410696594431a2b0..9adcf3035f43d69f153f37c0f410ad14f7f7bed4 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bufio"
        "bytes"
        "fmt"
+       "internal/buildcfg"
        "io"
        "log"
        "os"
@@ -231,7 +232,7 @@ CheckFlags:
        }
 
        // TODO: Test and delete these conditions.
-       if objabi.Experiment.FieldTrack || objabi.Experiment.PreemptibleLoops {
+       if buildcfg.Experiment.FieldTrack || buildcfg.Experiment.PreemptibleLoops {
                canDashC = false
        }
 
index 1e1494998a96c196bb38ebe5155175096fd47f5c..66e1ca7d80ba52bca5053d855fc967d29f872a2c 100644 (file)
@@ -11,10 +11,10 @@ import (
        "cmd/go/internal/cfg"
        "cmd/go/internal/fsys"
        "cmd/go/internal/modload"
-       "cmd/internal/objabi"
        "cmd/internal/sys"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "os"
        "path/filepath"
        "runtime"
@@ -52,7 +52,7 @@ func BuildInit() {
        // used for compiling alternative files for the experiment. This allows
        // changes for the experiment, like extra struct fields in the runtime,
        // without affecting the base non-experiment code at all.
-       for _, expt := range objabi.EnabledExperiments() {
+       for _, expt := range buildcfg.EnabledExperiments() {
                cfg.BuildContext.BuildTags = append(cfg.BuildContext.BuildTags, "goexperiment."+expt)
        }
 }
index 9cc44da84db6a378de4156df4ba87bb0082537d9..02174a56ff0bef40871f3ef7301588233d7bb355 100644 (file)
@@ -10,6 +10,7 @@ import (
        "context"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "log"
        "os"
        "path/filepath"
@@ -144,6 +145,11 @@ func main() {
                os.Exit(2)
        }
 
+       if err := buildcfg.Error; err != nil {
+               fmt.Fprintf(os.Stderr, "go: %v\n", buildcfg.Error)
+               os.Exit(2)
+       }
+
        // Set environment (GOOS, GOARCH, etc) explicitly.
        // In theory all the commands we invoke should have
        // the same default computation of these as we do,
index 20d0f956a7fd13d3632015c7cb26bdc14e4bba93..87b5971aa71915f146843bf3b82268389e003df1 100644 (file)
@@ -13,6 +13,7 @@ import (
        "errors"
        "fmt"
        "go/build"
+       "internal/buildcfg"
        "internal/testenv"
        "io/fs"
        "os"
@@ -32,7 +33,6 @@ import (
        "cmd/go/internal/robustio"
        "cmd/go/internal/txtar"
        "cmd/go/internal/work"
-       "cmd/internal/objabi"
        "cmd/internal/sys"
 )
 
@@ -165,7 +165,7 @@ func (ts *testScript) setup() {
                "GOCACHE=" + testGOCACHE,
                "GODEBUG=" + os.Getenv("GODEBUG"),
                "GOEXE=" + cfg.ExeSuffix,
-               "GOEXPERIMENT=" + objabi.GOEXPERIMENT(),
+               "GOEXPERIMENT=" + buildcfg.GOEXPERIMENT(),
                "GOOS=" + runtime.GOOS,
                "GOPATH=" + filepath.Join(ts.workdir, "gopath"),
                "GOPROXY=" + proxyURL,
index c48e1723c8da558f7978d7b94b012239d3adf718..ec441c2bcb687d898ff75dd0646ffc5ab5230b1b 100644 (file)
@@ -9,13 +9,15 @@ package dwarf
 
 import (
        "bytes"
-       "cmd/internal/objabi"
        "errors"
        "fmt"
+       "internal/buildcfg"
        exec "internal/execabs"
        "sort"
        "strconv"
        "strings"
+
+       "cmd/internal/objabi"
 )
 
 // InfoPrefix is the prefix for all the symbols containing DWARF info entries.
@@ -381,7 +383,7 @@ func expandPseudoForm(form uint8) uint8 {
                return form
        }
        expandedForm := DW_FORM_udata
-       if objabi.GOOS == "darwin" || objabi.GOOS == "ios" {
+       if buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios" {
                expandedForm = DW_FORM_data4
        }
        return uint8(expandedForm)
index ad80ede0f38e5035f30011fe5082685ed64a7d09..ed942aa93448bd1e36c57309039beadf5efaf090 100644 (file)
@@ -10,6 +10,7 @@ import (
        "cmd/internal/bio"
        "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "internal/testenv"
        "io/ioutil"
        "os"
@@ -91,8 +92,8 @@ func main() {
 `
 
 func TestIssue41621LargeNumberOfRelocations(t *testing.T) {
-       if testing.Short() || (objabi.GOARCH != "amd64") {
-               t.Skipf("Skipping large number of relocations test in short mode or on %s", objabi.GOARCH)
+       if testing.Short() || (buildcfg.GOARCH != "amd64") {
+               t.Skipf("Skipping large number of relocations test in short mode or on %s", buildcfg.GOARCH)
        }
        testenv.MustHaveGoBuild(t)
 
index ebb98b4859d1a5b16a3a47af17fb33a497683020..ccf5f9e7f8d959da412e76835290e8f694b85599 100644 (file)
@@ -34,6 +34,7 @@ import (
        "cmd/internal/obj"
        "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "log"
        "math"
        "sort"
@@ -976,7 +977,7 @@ func (c *ctxt5) aclass(a *obj.Addr) int {
                        if immrot(^uint32(c.instoffset)) != 0 {
                                return C_NCON
                        }
-                       if uint32(c.instoffset) <= 0xffff && objabi.GOARM == 7 {
+                       if uint32(c.instoffset) <= 0xffff && buildcfg.GOARM == 7 {
                                return C_SCON
                        }
                        if x, y := immrot2a(uint32(c.instoffset)); x != 0 && y != 0 {
@@ -3044,7 +3045,7 @@ func (c *ctxt5) omvl(p *obj.Prog, a *obj.Addr, dr int) uint32 {
 
 func (c *ctxt5) chipzero5(e float64) int {
        // We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
-       if objabi.GOARM < 7 || math.Float64bits(e) != 0 {
+       if buildcfg.GOARM < 7 || math.Float64bits(e) != 0 {
                return -1
        }
        return 0
@@ -3052,7 +3053,7 @@ func (c *ctxt5) chipzero5(e float64) int {
 
 func (c *ctxt5) chipfloat5(e float64) int {
        // We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
-       if objabi.GOARM < 7 {
+       if buildcfg.GOARM < 7 {
                return -1
        }
 
index edb384806b4bc1ed1be6f0b710d830a08231f8a8..1454d8a7c92045e0f9b6a9af7a282ecfc577d080 100644 (file)
@@ -34,6 +34,7 @@ import (
        "cmd/internal/obj"
        "cmd/internal/objabi"
        "cmd/internal/sys"
+       "internal/buildcfg"
        "log"
 )
 
@@ -64,7 +65,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
                                ctxt.Diag("%v: TLS MRC instruction must write to R0 as it might get translated into a BL instruction", p.Line())
                        }
 
-                       if objabi.GOARM < 7 {
+                       if buildcfg.GOARM < 7 {
                                // Replace it with BL runtime.read_tls_fallback(SB) for ARM CPUs that lack the tls extension.
                                if progedit_tlsfallback == nil {
                                        progedit_tlsfallback = ctxt.Lookup("runtime.read_tls_fallback")
index 514991e3408e440415c0baabfdfe358a19e18868..e41fb3bb7531cb01e7c8319343c2c2cb5730d3ea 100644 (file)
@@ -35,6 +35,7 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/src"
        "cmd/internal/sys"
+       "internal/buildcfg"
        "log"
        "math"
 )
@@ -576,7 +577,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                                q1.To.Reg = REGSP
                                q1.Spadj = c.autosize
 
-                               if objabi.GOOS == "ios" {
+                               if buildcfg.GOOS == "ios" {
                                        // iOS does not support SA_ONSTACK. We will run the signal handler
                                        // on the G stack. If we write below SP, it may be clobbered by
                                        // the signal handler. So we save LR after decrementing SP.
index 98c7364e2a03915cd97a58e6d4d9e8d7a1d66391..9e8b4dd790f001435f4eac4a48d3d6a267797d32 100644 (file)
@@ -35,6 +35,7 @@ import (
        "cmd/internal/goobj"
        "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "log"
        "math"
        "sort"
@@ -49,8 +50,8 @@ func Linknew(arch *LinkArch) *Link {
        ctxt.Arch = arch
        ctxt.Pathname = objabi.WorkingDir()
 
-       if err := ctxt.Headtype.Set(objabi.GOOS); err != nil {
-               log.Fatalf("unknown goos %s", objabi.GOOS)
+       if err := ctxt.Headtype.Set(buildcfg.GOOS); err != nil {
+               log.Fatalf("unknown goos %s", buildcfg.GOOS)
        }
 
        ctxt.Flag_optimize = true
index 1c34b4e833e2257dde4ac3e6a7e9c642258bd1f2..e8441a69694452544092ef6225fdd8c7d8e3143f 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bytes"
        "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "io"
        "strings"
 )
@@ -83,7 +84,7 @@ func CConv(s uint8) string {
        }
        for i := range opSuffixSpace {
                sset := &opSuffixSpace[i]
-               if sset.arch == objabi.GOARCH {
+               if sset.arch == buildcfg.GOARCH {
                        return sset.cconv(s)
                }
        }
@@ -330,7 +331,7 @@ func writeDconv(w io.Writer, p *Prog, a *Addr, abiDetail bool) {
        case TYPE_SHIFT:
                v := int(a.Offset)
                ops := "<<>>->@>"
-               switch objabi.GOARCH {
+               switch buildcfg.GOARCH {
                case "arm":
                        op := ops[((v>>5)&3)<<1:]
                        if v&(1<<4) != 0 {
@@ -346,7 +347,7 @@ func writeDconv(w io.Writer, p *Prog, a *Addr, abiDetail bool) {
                        r := (v >> 16) & 31
                        fmt.Fprintf(w, "%s%c%c%d", Rconv(r+RBaseARM64), op[0], op[1], (v>>10)&63)
                default:
-                       panic("TYPE_SHIFT is not supported on " + objabi.GOARCH)
+                       panic("TYPE_SHIFT is not supported on " + buildcfg.GOARCH)
                }
 
        case TYPE_REGREG:
index 52ac567a3627a9f961a9178894cb8bf2f9b80d81..17fa76727e6212061f46548664530c88570ff734 100644 (file)
@@ -36,6 +36,7 @@ import (
        "cmd/internal/sys"
        "encoding/binary"
        "fmt"
+       "internal/buildcfg"
        "log"
        "strings"
 )
@@ -2460,7 +2461,7 @@ func instinit(ctxt *obj.Link) {
        }
 }
 
-var isAndroid = objabi.GOOS == "android"
+var isAndroid = buildcfg.GOOS == "android"
 
 func prefixof(ctxt *obj.Link, a *obj.Addr) int {
        if a.Reg < REG_CS && a.Index < REG_CS { // fast path
index 06736d43bd1696896a4e55985e3ac237e4284df1..e2732d53e3067b4d21c7774d84b180a90908ee22 100644 (file)
@@ -35,6 +35,7 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/src"
        "cmd/internal/sys"
+       "internal/buildcfg"
        "log"
        "math"
        "path"
@@ -646,13 +647,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
 
        var regg int16
        if !p.From.Sym.NoSplit() || p.From.Sym.Wrapper() {
-               if ctxt.Arch.Family == sys.AMD64 && objabi.Experiment.RegabiG && cursym.ABI() == obj.ABIInternal {
+               if ctxt.Arch.Family == sys.AMD64 && buildcfg.Experiment.RegabiG && cursym.ABI() == obj.ABIInternal {
                        regg = REGG // use the g register directly in ABIInternal
                } else {
                        p = obj.Appendp(p, newprog)
                        regg = REG_CX
                        if ctxt.Arch.Family == sys.AMD64 {
-                               // Using this register means that stacksplit works w/ //go:registerparams even when !objabi.Experiment.RegabiG
+                               // Using this register means that stacksplit works w/ //go:registerparams even when !buildcfg.Experiment.RegabiG
                                regg = REGG // == REG_R14
                        }
                        p = load_g(ctxt, p, newprog, regg) // load g into regg
index 9fcab4cc85b1c4a855c298e9c51c8dd90992fd29..e41fc570b0894926a29ccd0736fb4199f53b0c6c 100644 (file)
@@ -8,6 +8,7 @@ import (
        "bytes"
        "flag"
        "fmt"
+       "internal/buildcfg"
        "io"
        "io/ioutil"
        "log"
@@ -96,11 +97,11 @@ func (versionFlag) Set(s string) error {
        if s == "goexperiment" {
                // test/run.go uses this to discover the full set of
                // experiment tags. Report everything.
-               p = " X:" + strings.Join(expList(&Experiment, nil, true), ",")
+               p = " X:" + strings.Join(buildcfg.AllExperiments(), ",")
        } else {
                // If the enabled experiments differ from the defaults,
                // include that difference.
-               if goexperiment := GOEXPERIMENT(); goexperiment != "" {
+               if goexperiment := buildcfg.GOEXPERIMENT(); goexperiment != "" {
                        p = " X:" + goexperiment
                }
        }
@@ -111,12 +112,12 @@ func (versionFlag) Set(s string) error {
        // build ID of the binary, so that if the compiler is changed and
        // rebuilt, we notice and rebuild all packages.
        if s == "full" {
-               if strings.HasPrefix(Version, "devel") {
+               if strings.HasPrefix(buildcfg.Version, "devel") {
                        p += " buildID=" + buildID
                }
        }
 
-       fmt.Printf("%s version %s%s\n", name, Version, p)
+       fmt.Printf("%s version %s%s\n", name, buildcfg.Version, p)
        os.Exit(0)
        return nil
 }
index 0733b65138db50371baf7a3268d036bcc986f4f8..0b1e0bb181c4d3866d96a1a0077a1c678c942c08 100644 (file)
@@ -5,6 +5,7 @@
 package objabi
 
 import (
+       "internal/buildcfg"
        "os"
        "path/filepath"
        "strings"
@@ -38,8 +39,8 @@ func AbsFile(dir, file, rewrites string) string {
        }
 
        abs, rewritten := ApplyRewrites(abs, rewrites)
-       if !rewritten && hasPathPrefix(abs, GOROOT) {
-               abs = "$GOROOT" + abs[len(GOROOT):]
+       if !rewritten && hasPathPrefix(abs, buildcfg.GOROOT) {
+               abs = "$GOROOT" + abs[len(buildcfg.GOROOT):]
        }
 
        if abs == "" {
index 1f531176cc66b2c0559674ca41eda9c65457bf2b..0c82a7c6dd10e76285325776d3c0abdc2f6249b1 100644 (file)
@@ -4,6 +4,8 @@
 
 package objabi
 
+import "internal/buildcfg"
+
 // For the linkers. Must match Go definitions.
 
 const (
@@ -22,7 +24,7 @@ var StackLimit = StackGuard - StackSystem - StackSmall
 // builds that have larger stack frames or for specific targets.
 func stackGuardMultiplier() int {
        // On AIX, a larger stack is needed for syscalls.
-       if GOOS == "aix" {
+       if buildcfg.GOOS == "aix" {
                return 2
        }
        return stackGuardMultiplierDefault
index 5a7a74cfde8d0441ddc839421aeb8c487cdfc3a7..63640950d9f8ee609ad30e607c1528b4664d5b77 100644 (file)
@@ -6,32 +6,9 @@ package objabi
 
 import (
        "fmt"
-       "log"
-       "os"
        "strings"
-)
-
-func envOr(key, value string) string {
-       if x := os.Getenv(key); x != "" {
-               return x
-       }
-       return value
-}
 
-var (
-       defaultGOROOT string // set by linker
-
-       GOROOT   = envOr("GOROOT", defaultGOROOT)
-       GOARCH   = envOr("GOARCH", defaultGOARCH)
-       GOOS     = envOr("GOOS", defaultGOOS)
-       GO386    = envOr("GO386", defaultGO386)
-       GOARM    = goarm()
-       GOMIPS   = gomips()
-       GOMIPS64 = gomips64()
-       GOPPC64  = goppc64()
-       GOWASM   = gowasm()
-       GO_LDSO  = defaultGO_LDSO
-       Version  = version
+       "internal/buildcfg"
 )
 
 const (
@@ -39,94 +16,10 @@ const (
        MachoRelocOffset = 2048 // reserve enough space for ELF relocations
 )
 
-func goarm() int {
-       def := defaultGOARM
-       if GOOS == "android" && GOARCH == "arm" {
-               // Android arm devices always support GOARM=7.
-               def = "7"
-       }
-       switch v := envOr("GOARM", def); v {
-       case "5":
-               return 5
-       case "6":
-               return 6
-       case "7":
-               return 7
-       }
-       // Fail here, rather than validate at multiple call sites.
-       log.Fatalf("Invalid GOARM value. Must be 5, 6, or 7.")
-       panic("unreachable")
-}
-
-func gomips() string {
-       switch v := envOr("GOMIPS", defaultGOMIPS); v {
-       case "hardfloat", "softfloat":
-               return v
-       }
-       log.Fatalf("Invalid GOMIPS value. Must be hardfloat or softfloat.")
-       panic("unreachable")
-}
-
-func gomips64() string {
-       switch v := envOr("GOMIPS64", defaultGOMIPS64); v {
-       case "hardfloat", "softfloat":
-               return v
-       }
-       log.Fatalf("Invalid GOMIPS64 value. Must be hardfloat or softfloat.")
-       panic("unreachable")
-}
-
-func goppc64() int {
-       switch v := envOr("GOPPC64", defaultGOPPC64); v {
-       case "power8":
-               return 8
-       case "power9":
-               return 9
-       }
-       log.Fatalf("Invalid GOPPC64 value. Must be power8 or power9.")
-       panic("unreachable")
-}
-
-type gowasmFeatures struct {
-       SignExt bool
-       SatConv bool
-}
-
-func (f gowasmFeatures) String() string {
-       var flags []string
-       if f.SatConv {
-               flags = append(flags, "satconv")
-       }
-       if f.SignExt {
-               flags = append(flags, "signext")
-       }
-       return strings.Join(flags, ",")
-}
-
-func gowasm() (f gowasmFeatures) {
-       for _, opt := range strings.Split(envOr("GOWASM", ""), ",") {
-               switch opt {
-               case "satconv":
-                       f.SatConv = true
-               case "signext":
-                       f.SignExt = true
-               case "":
-                       // ignore
-               default:
-                       log.Fatalf("Invalid GOWASM value. No such feature: " + opt)
-               }
-       }
-       return
-}
-
-func Getgoextlinkenabled() string {
-       return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
-}
-
 // HeaderString returns the toolchain configuration string written in
 // Go object headers. This string ensures we don't attempt to import
 // or link object files that are incompatible with each other. This
 // string always starts with "go object ".
 func HeaderString() string {
-       return fmt.Sprintf("go object %s %s %s X:%s\n", GOOS, GOARCH, Version, strings.Join(EnabledExperiments(), ","))
+       return fmt.Sprintf("go object %s %s %s X:%s\n", buildcfg.GOOS, buildcfg.GOARCH, buildcfg.Version, strings.Join(buildcfg.EnabledExperiments(), ","))
 }
index e4fd591676626ce56a6213a66b67274361c97d6c..22f53a4df2ee369ce71df17390178ac1b94d04ff 100644 (file)
@@ -32,10 +32,10 @@ package ld
 
 import (
        "cmd/internal/bio"
-       "cmd/internal/objabi"
        "cmd/link/internal/sym"
        "encoding/binary"
        "fmt"
+       "internal/buildcfg"
        "io"
        "os"
 )
@@ -170,7 +170,7 @@ func readArmap(filename string, f *bio.Reader, arhdr ArHdr) archiveMap {
 
                // For Mach-O and PE/386 files we strip a leading
                // underscore from the symbol name.
-               if objabi.GOOS == "darwin" || objabi.GOOS == "ios" || (objabi.GOOS == "windows" && objabi.GOARCH == "386") {
+               if buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios" || (buildcfg.GOOS == "windows" && buildcfg.GOARCH == "386") {
                        if name[0] == '_' && len(name) > 1 {
                                name = name[1:]
                        }
index 9228962fb33b881ee9a4a8d4ebc83555f9ca2012..75fddc6a38e94c2797c378ddd154d204c54a1bb5 100644 (file)
@@ -5,9 +5,9 @@
 package ld
 
 import (
-       "cmd/internal/objabi"
        "cmd/internal/sys"
        "fmt"
+       "internal/buildcfg"
 )
 
 // A BuildMode indicates the sort of object we are building.
@@ -28,23 +28,23 @@ const (
 
 func (mode *BuildMode) Set(s string) error {
        badmode := func() error {
-               return fmt.Errorf("buildmode %s not supported on %s/%s", s, objabi.GOOS, objabi.GOARCH)
+               return fmt.Errorf("buildmode %s not supported on %s/%s", s, buildcfg.GOOS, buildcfg.GOARCH)
        }
        switch s {
        default:
                return fmt.Errorf("invalid buildmode: %q", s)
        case "exe":
-               switch objabi.GOOS + "/" + objabi.GOARCH {
+               switch buildcfg.GOOS + "/" + buildcfg.GOARCH {
                case "darwin/arm64", "windows/arm", "windows/arm64": // On these platforms, everything is PIE
                        *mode = BuildModePIE
                default:
                        *mode = BuildModeExe
                }
        case "pie":
-               switch objabi.GOOS {
+               switch buildcfg.GOOS {
                case "aix", "android", "linux", "windows", "darwin", "ios":
                case "freebsd":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "amd64":
                        default:
                                return badmode()
@@ -54,16 +54,16 @@ func (mode *BuildMode) Set(s string) error {
                }
                *mode = BuildModePIE
        case "c-archive":
-               switch objabi.GOOS {
+               switch buildcfg.GOOS {
                case "aix", "darwin", "ios", "linux":
                case "freebsd":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "amd64":
                        default:
                                return badmode()
                        }
                case "windows":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "amd64", "386", "arm", "arm64":
                        default:
                                return badmode()
@@ -73,16 +73,16 @@ func (mode *BuildMode) Set(s string) error {
                }
                *mode = BuildModeCArchive
        case "c-shared":
-               switch objabi.GOARCH {
+               switch buildcfg.GOARCH {
                case "386", "amd64", "arm", "arm64", "ppc64le", "s390x":
                default:
                        return badmode()
                }
                *mode = BuildModeCShared
        case "shared":
-               switch objabi.GOOS {
+               switch buildcfg.GOOS {
                case "linux":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "386", "amd64", "arm", "arm64", "ppc64le", "s390x":
                        default:
                                return badmode()
@@ -92,21 +92,21 @@ func (mode *BuildMode) Set(s string) error {
                }
                *mode = BuildModeShared
        case "plugin":
-               switch objabi.GOOS {
+               switch buildcfg.GOOS {
                case "linux":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "386", "amd64", "arm", "arm64", "s390x", "ppc64le":
                        default:
                                return badmode()
                        }
                case "darwin":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "amd64", "arm64":
                        default:
                                return badmode()
                        }
                case "freebsd":
-                       switch objabi.GOARCH {
+                       switch buildcfg.GOARCH {
                        case "amd64":
                        default:
                                return badmode()
@@ -185,8 +185,8 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) {
                }()
        }
 
-       if sys.MustLinkExternal(objabi.GOOS, objabi.GOARCH) {
-               return true, fmt.Sprintf("%s/%s requires external linking", objabi.GOOS, objabi.GOARCH)
+       if sys.MustLinkExternal(buildcfg.GOOS, buildcfg.GOARCH) {
+               return true, fmt.Sprintf("%s/%s requires external linking", buildcfg.GOOS, buildcfg.GOARCH)
        }
 
        if *flagMsan {
@@ -197,20 +197,20 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) {
        // https://golang.org/issue/14449
        // https://golang.org/issue/21961
        if iscgo && ctxt.Arch.InFamily(sys.MIPS64, sys.MIPS, sys.PPC64, sys.RISCV64) {
-               return true, objabi.GOARCH + " does not support internal cgo"
+               return true, buildcfg.GOARCH + " does not support internal cgo"
        }
-       if iscgo && (objabi.GOOS == "android" || objabi.GOOS == "dragonfly") {
+       if iscgo && (buildcfg.GOOS == "android" || buildcfg.GOOS == "dragonfly") {
                // It seems that on Dragonfly thread local storage is
                // set up by the dynamic linker, so internal cgo linking
                // doesn't work. Test case is "go test runtime/cgo".
-               return true, objabi.GOOS + " does not support internal cgo"
+               return true, buildcfg.GOOS + " does not support internal cgo"
        }
 
        // When the race flag is set, the LLVM tsan relocatable file is linked
        // into the final binary, which means external linking is required because
        // internal linking does not support it.
        if *flagRace && ctxt.Arch.InFamily(sys.PPC64) {
-               return true, "race on " + objabi.GOARCH
+               return true, "race on " + buildcfg.GOARCH
        }
 
        // Some build modes require work the internal linker cannot do (yet).
@@ -220,7 +220,7 @@ func mustLinkExternal(ctxt *Link) (res bool, reason string) {
        case BuildModeCShared:
                return true, "buildmode=c-shared"
        case BuildModePIE:
-               switch objabi.GOOS + "/" + objabi.GOARCH {
+               switch buildcfg.GOOS + "/" + buildcfg.GOARCH {
                case "linux/amd64", "linux/arm64", "android/arm64":
                case "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
                case "darwin/amd64", "darwin/arm64":
@@ -254,7 +254,7 @@ func determineLinkMode(ctxt *Link) {
                // default value of -linkmode. If it is not set when the
                // linker is called we take the value it was set to when
                // cmd/link was compiled. (See make.bash.)
-               switch objabi.Getgoextlinkenabled() {
+               switch buildcfg.Getgoextlinkenabled() {
                case "0":
                        ctxt.LinkMode = LinkInternal
                        via = "via GO_EXTLINK_ENABLED "
@@ -277,8 +277,8 @@ func determineLinkMode(ctxt *Link) {
                }
        case LinkExternal:
                switch {
-               case objabi.GOARCH == "ppc64" && objabi.GOOS != "aix":
-                       Exitf("external linking not supported for %s/ppc64", objabi.GOOS)
+               case buildcfg.GOARCH == "ppc64" && buildcfg.GOOS != "aix":
+                       Exitf("external linking not supported for %s/ppc64", buildcfg.GOOS)
                }
        }
 }
index 7c46307bd8c4aa4e0e246aa9878b639e73840a7f..f91493bc417db47b87f2e0b6c5f024fd494501c1 100644 (file)
@@ -8,6 +8,7 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/sys"
        "cmd/link/internal/loader"
+       "internal/buildcfg"
        "testing"
 )
 
@@ -63,14 +64,14 @@ func TestAddGotSym(t *testing.T) {
        }
 
        // Save the architecture as we're going to set it on each test run.
-       origArch := objabi.GOARCH
+       origArch := buildcfg.GOARCH
        defer func() {
-               objabi.GOARCH = origArch
+               buildcfg.GOARCH = origArch
        }()
 
        for i, test := range tests {
                iself := len(test.rel) != 0
-               objabi.GOARCH = test.arch.Name
+               buildcfg.GOARCH = test.arch.Name
                ctxt := setUpContext(test.arch, iself, test.ht, test.bm, test.lm)
                foo := ctxt.loader.CreateSymForUpdate("foo", 0)
                ctxt.loader.CreateExtSym("bar", 0)
index 741a72cad844b24f03b2294255c2e8ffb851f8d3..1ed5598c99d510b1d71ed85c89c21ad04dba9063 100644 (file)
@@ -11,6 +11,7 @@ import (
        "cmd/link/internal/loader"
        "cmd/link/internal/sym"
        "fmt"
+       "internal/buildcfg"
        "unicode"
 )
 
@@ -32,7 +33,7 @@ type deadcodePass struct {
 func (d *deadcodePass) init() {
        d.ldr.InitReachable()
        d.ifaceMethod = make(map[methodsig]bool)
-       if objabi.Experiment.FieldTrack {
+       if buildcfg.Experiment.FieldTrack {
                d.ldr.Reachparent = make([]loader.Sym, d.ldr.NSym())
        }
        d.dynlink = d.ctxt.DynlinkingGo()
@@ -258,7 +259,7 @@ func (d *deadcodePass) mark(symIdx, parent loader.Sym) {
        if symIdx != 0 && !d.ldr.AttrReachable(symIdx) {
                d.wq.push(symIdx)
                d.ldr.SetAttrReachable(symIdx, true)
-               if objabi.Experiment.FieldTrack && d.ldr.Reachparent[symIdx] == 0 {
+               if buildcfg.Experiment.FieldTrack && d.ldr.Reachparent[symIdx] == 0 {
                        d.ldr.Reachparent[symIdx] = parent
                }
                if *flagDumpDep {
index 2f19c3eaa2f93f0bbec3806e6adf735e06d87e48..c53d2408cbe5105fd9011b416e2d2d738241200d 100644 (file)
@@ -22,6 +22,7 @@ import (
        "cmd/link/internal/loader"
        "cmd/link/internal/sym"
        "fmt"
+       "internal/buildcfg"
        "log"
        "path"
        "runtime"
@@ -1843,7 +1844,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
                        if producerExtra := d.ldr.Lookup(dwarf.CUInfoPrefix+"producer."+unit.Lib.Pkg, 0); producerExtra != 0 {
                                peData = d.ldr.Data(producerExtra)
                        }
-                       producer := "Go cmd/compile " + objabi.Version
+                       producer := "Go cmd/compile " + buildcfg.Version
                        if len(peData) > 0 {
                                // We put a semicolon before the flags to clearly
                                // separate them from the version, which can be long
index 3ba9f329ee62ee8f41fa3df9719957338e3fd7c8..87d88dd957de9e564e8072fe135a5b2adfea1b9f 100644 (file)
@@ -14,6 +14,7 @@ import (
        "encoding/binary"
        "encoding/hex"
        "fmt"
+       "internal/buildcfg"
        "path/filepath"
        "sort"
        "strings"
@@ -584,7 +585,7 @@ func elfWriteMipsAbiFlags(ctxt *Link) int {
        ctxt.Out.Write8(1)  // gprSize
        ctxt.Out.Write8(1)  // cpr1Size
        ctxt.Out.Write8(0)  // cpr2Size
-       if objabi.GOMIPS == "softfloat" {
+       if buildcfg.GOMIPS == "softfloat" {
                ctxt.Out.Write8(MIPS_FPABI_SOFT) // fpAbi
        } else {
                // Go cannot make sure non odd-number-fpr is used (ie, in load a double from memory).
@@ -1557,7 +1558,7 @@ func (ctxt *Link) doelf() {
                gnuattributes.AddUint8(1)                 // 1:file, 2: section, 3: symbol, 1 here
                gnuattributes.AddUint32(ctxt.Arch, 7)     // tag length, including tag, 7 here
                gnuattributes.AddUint8(4)                 // 4 for FP, 8 for MSA
-               if objabi.GOMIPS == "softfloat" {
+               if buildcfg.GOMIPS == "softfloat" {
                        gnuattributes.AddUint8(MIPS_FPABI_SOFT)
                } else {
                        // Note: MIPS_FPABI_ANY is bad naming: in fact it is MIPS I style FPR usage.
@@ -1743,14 +1744,14 @@ func asmbElf(ctxt *Link) {
                sh.Flags = uint64(elf.SHF_ALLOC)
                sh.Addralign = 1
 
-               if interpreter == "" && objabi.GO_LDSO != "" {
-                       interpreter = objabi.GO_LDSO
+               if interpreter == "" && buildcfg.GO_LDSO != "" {
+                       interpreter = buildcfg.GO_LDSO
                }
 
                if interpreter == "" {
                        switch ctxt.HeadType {
                        case objabi.Hlinux:
-                               if objabi.GOOS == "android" {
+                               if buildcfg.GOOS == "android" {
                                        interpreter = thearch.Androiddynld
                                        if interpreter == "" {
                                                Exitf("ELF interpreter not set")
index b709569103320a42c9fd2b44e366f1d49a0c8aed..b814a277e6b39b5ec7541e868e8060249b5e64a6 100644 (file)
@@ -49,6 +49,7 @@ import (
        "encoding/base64"
        "encoding/binary"
        "fmt"
+       "internal/buildcfg"
        exec "internal/execabs"
        "io"
        "io/ioutil"
@@ -379,7 +380,7 @@ func libinit(ctxt *Link) {
                suffix = "msan"
        }
 
-       Lflag(ctxt, filepath.Join(objabi.GOROOT, "pkg", fmt.Sprintf("%s_%s%s%s", objabi.GOOS, objabi.GOARCH, suffixsep, suffix)))
+       Lflag(ctxt, filepath.Join(buildcfg.GOROOT, "pkg", fmt.Sprintf("%s_%s%s%s", buildcfg.GOOS, buildcfg.GOARCH, suffixsep, suffix)))
 
        mayberemoveoutfile()
 
@@ -390,9 +391,9 @@ func libinit(ctxt *Link) {
        if *flagEntrySymbol == "" {
                switch ctxt.BuildMode {
                case BuildModeCShared, BuildModeCArchive:
-                       *flagEntrySymbol = fmt.Sprintf("_rt0_%s_%s_lib", objabi.GOARCH, objabi.GOOS)
+                       *flagEntrySymbol = fmt.Sprintf("_rt0_%s_%s_lib", buildcfg.GOARCH, buildcfg.GOOS)
                case BuildModeExe, BuildModePIE:
-                       *flagEntrySymbol = fmt.Sprintf("_rt0_%s_%s", objabi.GOARCH, objabi.GOOS)
+                       *flagEntrySymbol = fmt.Sprintf("_rt0_%s_%s", buildcfg.GOARCH, buildcfg.GOOS)
                case BuildModeShared, BuildModePlugin:
                        // No *flagEntrySymbol for -buildmode=shared and plugin
                default:
@@ -495,7 +496,7 @@ func (ctxt *Link) loadlib() {
        default:
                log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups)
        }
-       if !objabi.Experiment.RegabiWrappers || ctxt.linkShared {
+       if !buildcfg.Experiment.RegabiWrappers || ctxt.linkShared {
                // Use ABI aliases if ABI wrappers are not used.
                // TODO: for now we still use ABI aliases in shared linkage, even if
                // the wrapper is enabled.
@@ -543,7 +544,7 @@ func (ctxt *Link) loadlib() {
        // We now have enough information to determine the link mode.
        determineLinkMode(ctxt)
 
-       if ctxt.LinkMode == LinkExternal && !iscgo && !(objabi.GOOS == "darwin" && ctxt.BuildMode != BuildModePlugin && ctxt.Arch.Family == sys.AMD64) {
+       if ctxt.LinkMode == LinkExternal && !iscgo && !(buildcfg.GOOS == "darwin" && ctxt.BuildMode != BuildModePlugin && ctxt.Arch.Family == sys.AMD64) {
                // This indicates a user requested -linkmode=external.
                // The startup code uses an import of runtime/cgo to decide
                // whether to initialize the TLS.  So give it one. This could
@@ -705,7 +706,7 @@ func (ctxt *Link) linksetup() {
                }
        }
 
-       if ctxt.LinkMode == LinkExternal && ctxt.Arch.Family == sys.PPC64 && objabi.GOOS != "aix" {
+       if ctxt.LinkMode == LinkExternal && ctxt.Arch.Family == sys.PPC64 && buildcfg.GOOS != "aix" {
                toc := ctxt.loader.LookupOrCreateSym(".TOC.", 0)
                sb := ctxt.loader.MakeSymbolUpdater(toc)
                sb.SetType(sym.SDYNIMPORT)
@@ -714,7 +715,7 @@ func (ctxt *Link) linksetup() {
        // The Android Q linker started to complain about underalignment of the our TLS
        // section. We don't actually use the section on android, so don't
        // generate it.
-       if objabi.GOOS != "android" {
+       if buildcfg.GOOS != "android" {
                tlsg := ctxt.loader.LookupOrCreateSym("runtime.tlsg", 0)
                sb := ctxt.loader.MakeSymbolUpdater(tlsg)
 
@@ -755,7 +756,7 @@ func (ctxt *Link) linksetup() {
                        sb := ctxt.loader.MakeSymbolUpdater(goarm)
                        sb.SetType(sym.SDATA)
                        sb.SetSize(0)
-                       sb.AddUint8(uint8(objabi.GOARM))
+                       sb.AddUint8(uint8(buildcfg.GOARM))
                }
 
                // Set runtime.disableMemoryProfiling bool if
@@ -1248,7 +1249,7 @@ func (ctxt *Link) hostlink() {
                        // -headerpad is incompatible with -fembed-bitcode.
                        argv = append(argv, "-Wl,-headerpad,1144")
                }
-               if ctxt.DynlinkingGo() && objabi.GOOS != "ios" {
+               if ctxt.DynlinkingGo() && buildcfg.GOOS != "ios" {
                        // -flat_namespace is deprecated on iOS.
                        // It is useful for supporting plugins. We don't support plugins on iOS.
                        argv = append(argv, "-Wl,-flat_namespace")
@@ -1366,12 +1367,12 @@ func (ctxt *Link) hostlink() {
                // from the beginning of the section (like sym.STYPE).
                argv = append(argv, "-Wl,-znocopyreloc")
 
-               if objabi.GOOS == "android" {
+               if buildcfg.GOOS == "android" {
                        // Use lld to avoid errors from default linker (issue #38838)
                        altLinker = "lld"
                }
 
-               if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && objabi.GOOS == "linux" {
+               if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && buildcfg.GOOS == "linux" {
                        // On ARM, the GNU linker will generate COPY relocations
                        // even with -znocopyreloc set.
                        // https://sourceware.org/bugzilla/show_bug.cgi?id=19962
@@ -1393,7 +1394,7 @@ func (ctxt *Link) hostlink() {
                        }
                }
        }
-       if ctxt.Arch.Family == sys.ARM64 && objabi.GOOS == "freebsd" {
+       if ctxt.Arch.Family == sys.ARM64 && buildcfg.GOOS == "freebsd" {
                // Switch to ld.bfd on freebsd/arm64.
                altLinker = "bfd"
 
@@ -1420,7 +1421,7 @@ func (ctxt *Link) hostlink() {
        // only want to do this when producing a Windows output file
        // on a Windows host.
        outopt := *flagOutfile
-       if objabi.GOOS == "windows" && runtime.GOOS == "windows" && filepath.Ext(outopt) == "" {
+       if buildcfg.GOOS == "windows" && runtime.GOOS == "windows" && filepath.Ext(outopt) == "" {
                outopt += "."
        }
        argv = append(argv, "-o")
@@ -1737,7 +1738,7 @@ func hostlinkArchArgs(arch *sys.Arch) []string {
        case sys.I386:
                return []string{"-m32"}
        case sys.AMD64:
-               if objabi.GOOS == "darwin" {
+               if buildcfg.GOOS == "darwin" {
                        return []string{"-arch", "x86_64", "-m64"}
                }
                return []string{"-m64"}
@@ -1746,7 +1747,7 @@ func hostlinkArchArgs(arch *sys.Arch) []string {
        case sys.ARM:
                return []string{"-marm"}
        case sys.ARM64:
-               if objabi.GOOS == "darwin" {
+               if buildcfg.GOOS == "darwin" {
                        return []string{"-arch", "arm64"}
                }
        case sys.MIPS64:
@@ -1754,7 +1755,7 @@ func hostlinkArchArgs(arch *sys.Arch) []string {
        case sys.MIPS:
                return []string{"-mabi=32"}
        case sys.PPC64:
-               if objabi.GOOS == "aix" {
+               if buildcfg.GOOS == "aix" {
                        return []string{"-maix64"}
                } else {
                        return []string{"-m64"}
@@ -1862,7 +1863,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
        }
 
        // First, check that the basic GOOS, GOARCH, and Version match.
-       t := fmt.Sprintf("%s %s %s ", objabi.GOOS, objabi.GOARCH, objabi.Version)
+       t := fmt.Sprintf("%s %s %s ", buildcfg.GOOS, buildcfg.GOARCH, buildcfg.Version)
 
        line = strings.TrimRight(line, "\n")
        if !strings.HasPrefix(line[10:]+" ", t) && !*flagF {
@@ -2084,7 +2085,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
 
        // collect text symbol ABI versions.
        symabi := make(map[string]int) // map (unmangled) symbol name to version
-       if objabi.Experiment.RegabiWrappers {
+       if buildcfg.Experiment.RegabiWrappers {
                for _, elfsym := range syms {
                        if elf.ST_TYPE(elfsym.Info) != elf.STT_FUNC {
                                continue
@@ -2112,7 +2113,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
                symname := elfsym.Name // (unmangled) symbol name
                if elf.ST_TYPE(elfsym.Info) == elf.STT_FUNC && strings.HasPrefix(elfsym.Name, "type.") {
                        ver = sym.SymVerABIInternal
-               } else if objabi.Experiment.RegabiWrappers && elf.ST_TYPE(elfsym.Info) == elf.STT_FUNC {
+               } else if buildcfg.Experiment.RegabiWrappers && elf.ST_TYPE(elfsym.Info) == elf.STT_FUNC {
                        if strings.HasSuffix(elfsym.Name, ".abiinternal") {
                                ver = sym.SymVerABIInternal
                                symname = strings.TrimSuffix(elfsym.Name, ".abiinternal")
@@ -2162,7 +2163,7 @@ func ldshlibsyms(ctxt *Link, shlib string) {
                // mangle Go function names in the .so to include the
                // ABI.
                if elf.ST_TYPE(elfsym.Info) == elf.STT_FUNC && ver == 0 {
-                       if objabi.Experiment.RegabiWrappers {
+                       if buildcfg.Experiment.RegabiWrappers {
                                if _, ok := symabi[symname]; ok {
                                        continue // only use alias for functions w/o ABI wrappers
                                }
@@ -2234,7 +2235,7 @@ func (ctxt *Link) dostkcheck() {
        // of non-splitting functions.
        var ch chain
        ch.limit = objabi.StackLimit - callsize(ctxt)
-       if objabi.GOARCH == "arm64" {
+       if buildcfg.GOARCH == "arm64" {
                // need extra 8 bytes below SP to save FP
                ch.limit -= 8
        }
index 4c55c5761fe36d83f50f0b1601f8af90b631ed73..98c9a32f4dcc338a45546abb33c27dbda28b588c 100644 (file)
@@ -15,6 +15,7 @@ import (
        "debug/macho"
        "encoding/binary"
        "fmt"
+       "internal/buildcfg"
        "io"
        "os"
        "sort"
@@ -945,12 +946,12 @@ func collectmachosyms(ctxt *Link) {
                        if machoPlatform == PLATFORM_MACOS {
                                switch n := ldr.SymExtname(s); n {
                                case "fdopendir":
-                                       switch objabi.GOARCH {
+                                       switch buildcfg.GOARCH {
                                        case "amd64":
                                                ldr.SetSymExtname(s, n+"$INODE64")
                                        }
                                case "readdir_r", "getfsstat":
-                                       switch objabi.GOARCH {
+                                       switch buildcfg.GOARCH {
                                        case "amd64":
                                                ldr.SetSymExtname(s, n+"$INODE64")
                                        }
index 1e3c3bdff7817880aec6a316d0a062ea02fb2b31..7ab9ca7d10c898952d8cd53926ee526cd6e8b204 100644 (file)
@@ -37,6 +37,7 @@ import (
        "cmd/internal/sys"
        "cmd/link/internal/benchmark"
        "flag"
+       "internal/buildcfg"
        "log"
        "os"
        "runtime"
@@ -118,14 +119,14 @@ func Main(arch *sys.Arch, theArch Arch) {
        addstrdata1(ctxt, "runtime.defaultGOROOT="+final)
        addstrdata1(ctxt, "cmd/internal/objabi.defaultGOROOT="+final)
 
-       buildVersion := objabi.Version
-       if goexperiment := objabi.GOEXPERIMENT(); goexperiment != "" {
+       buildVersion := buildcfg.Version
+       if goexperiment := buildcfg.GOEXPERIMENT(); goexperiment != "" {
                buildVersion += " X:" + goexperiment
        }
        addstrdata1(ctxt, "runtime.buildVersion="+buildVersion)
 
        // TODO(matloob): define these above and then check flag values here
-       if ctxt.Arch.Family == sys.AMD64 && objabi.GOOS == "plan9" {
+       if ctxt.Arch.Family == sys.AMD64 && buildcfg.GOOS == "plan9" {
                flag.BoolVar(&flag8, "8", false, "use 64-bit addresses in symbol table")
        }
        flagHeadType := flag.String("H", "", "set header `type`")
@@ -159,7 +160,7 @@ func Main(arch *sys.Arch, theArch Arch) {
                }
        }
        if ctxt.HeadType == objabi.Hunknown {
-               ctxt.HeadType.Set(objabi.GOOS)
+               ctxt.HeadType.Set(buildcfg.GOOS)
        }
 
        if !*flagAslr && ctxt.BuildMode != BuildModeCShared {
@@ -255,7 +256,7 @@ func Main(arch *sys.Arch, theArch Arch) {
 
        bench.Start("dostrdata")
        ctxt.dostrdata()
-       if objabi.Experiment.FieldTrack {
+       if buildcfg.Experiment.FieldTrack {
                bench.Start("fieldtrack")
                fieldtrack(ctxt.Arch, ctxt.loader)
        }
index 61b64f4f5a1fd5f19566e073428b9b3015265027..79ad9d73e9a5f3bd830e96d0f91d7abfbefebf22 100644 (file)
@@ -11,6 +11,7 @@ import (
        "cmd/link/internal/loader"
        "cmd/link/internal/sym"
        "fmt"
+       "internal/buildcfg"
        "os"
        "path/filepath"
 )
@@ -879,7 +880,7 @@ func (ctxt *Link) pclntab(container loader.Bitmap) *pclntab {
 }
 
 func gorootFinal() string {
-       root := objabi.GOROOT
+       root := buildcfg.GOROOT
        if final := os.Getenv("GOROOT_FINAL"); final != "" {
                root = final
        }
index 3ed8943828f7e72990e8f8833b880d3705fa37c9..729b6b2443ee3821ed416b5a40bc02c6e82cae5e 100644 (file)
@@ -15,6 +15,7 @@ import (
        "debug/pe"
        "encoding/binary"
        "fmt"
+       "internal/buildcfg"
        "sort"
        "strconv"
        "strings"
@@ -481,9 +482,9 @@ func (f *peFile) addInitArray(ctxt *Link) *peSection {
        // that this will need to grow in the future.
        var size int
        var alignment uint32
-       switch objabi.GOARCH {
+       switch buildcfg.GOARCH {
        default:
-               Exitf("peFile.addInitArray: unsupported GOARCH=%q\n", objabi.GOARCH)
+               Exitf("peFile.addInitArray: unsupported GOARCH=%q\n", buildcfg.GOARCH)
        case "386", "arm":
                size = 4
                alignment = IMAGE_SCN_ALIGN_4BYTES
@@ -499,7 +500,7 @@ func (f *peFile) addInitArray(ctxt *Link) *peSection {
 
        init_entry := ctxt.loader.Lookup(*flagEntrySymbol, 0)
        addr := uint64(ctxt.loader.SymValue(init_entry)) - ctxt.loader.SymSect(init_entry).Vaddr
-       switch objabi.GOARCH {
+       switch buildcfg.GOARCH {
        case "386", "arm":
                ctxt.Out.Write32(uint32(addr))
        case "amd64", "arm64":
@@ -610,9 +611,9 @@ dwarfLoop:
                dottext := ldr.Lookup(".text", 0)
                ctxt.Out.Write32(0)
                ctxt.Out.Write32(uint32(ldr.SymDynid(dottext)))
-               switch objabi.GOARCH {
+               switch buildcfg.GOARCH {
                default:
-                       ctxt.Errorf(dottext, "unknown architecture for PE: %q\n", objabi.GOARCH)
+                       ctxt.Errorf(dottext, "unknown architecture for PE: %q\n", buildcfg.GOARCH)
                case "386":
                        ctxt.Out.Write16(IMAGE_REL_I386_DIR32)
                case "amd64":
index 75489720cc750823ae61786f0a545da908f9adf5..72639962e2ffa6b76a5a40a1219f61c183ef9a3a 100644 (file)
@@ -36,6 +36,7 @@ import (
        "cmd/internal/sys"
        "cmd/link/internal/loader"
        "cmd/link/internal/sym"
+       "internal/buildcfg"
        "log"
        "runtime"
 )
@@ -53,8 +54,8 @@ func linknew(arch *sys.Arch) *Link {
                generatorSyms: make(map[loader.Sym]generatorFunc),
        }
 
-       if objabi.GOARCH != arch.Name {
-               log.Fatalf("invalid objabi.GOARCH %s (want %s)", objabi.GOARCH, arch.Name)
+       if buildcfg.GOARCH != arch.Name {
+               log.Fatalf("invalid buildcfg.GOARCH %s (want %s)", buildcfg.GOARCH, arch.Name)
        }
 
        AtExit(func() {
index dcb9d7eb484dedb65f4f34c392dd83f0fe147961..013f7b55b64dee4c79798295b64acecd422cbd8f 100644 (file)
@@ -37,6 +37,7 @@ import (
        "cmd/link/internal/sym"
        "debug/elf"
        "fmt"
+       "internal/buildcfg"
        "path/filepath"
        "strings"
 )
@@ -844,7 +845,7 @@ func mangleABIName(ldr *loader.Loader, x loader.Sym, name string) string {
        // TODO: avoid the ldr.Lookup calls below by instead using an aux
        // sym or marker relocation to associate the wrapper with the
        // wrapped function.
-       if !objabi.Experiment.RegabiWrappers {
+       if !buildcfg.Experiment.RegabiWrappers {
                return name
        }
 
index f20597c0f51e6dc97b6b21359419e3331c32794c..5ca75825293fb93459d871672bbb3d94df740da1 100644 (file)
@@ -34,11 +34,12 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/sys"
        "cmd/link/internal/ld"
+       "internal/buildcfg"
 )
 
 func Init() (*sys.Arch, ld.Arch) {
        arch := sys.ArchMIPS
-       if objabi.GOARCH == "mipsle" {
+       if buildcfg.GOARCH == "mipsle" {
                arch = sys.ArchMIPSLE
        }
 
index 01d89a209cabab6b45d44110c2f14149368dd70b..544e1ef7bedc448bee626b2ff0d01fff953223c3 100644 (file)
@@ -34,11 +34,12 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/sys"
        "cmd/link/internal/ld"
+       "internal/buildcfg"
 )
 
 func Init() (*sys.Arch, ld.Arch) {
        arch := sys.ArchMIPS64
-       if objabi.GOARCH == "mips64le" {
+       if buildcfg.GOARCH == "mips64le" {
                arch = sys.ArchMIPS64LE
        }
 
index ef4393f48935b6505d2c42b5f463392d2e183421..54d4606487bb0d05cc3481505c44ffe7be625e4b 100644 (file)
@@ -34,11 +34,12 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/sys"
        "cmd/link/internal/ld"
+       "internal/buildcfg"
 )
 
 func Init() (*sys.Arch, ld.Arch) {
        arch := sys.ArchPPC64
-       if objabi.GOARCH == "ppc64le" {
+       if buildcfg.GOARCH == "ppc64le" {
                arch = sys.ArchPPC64LE
        }
 
index 31851fbb56775259c5a882911621f806c0070e3e..5bdfdbaee63e9bc42626d7057124dd18d108dd1c 100644 (file)
@@ -10,6 +10,7 @@ import (
        "cmd/link/internal/ld"
        "cmd/link/internal/loader"
        "cmd/link/internal/sym"
+       "internal/buildcfg"
        "io"
        "regexp"
 )
@@ -506,15 +507,15 @@ func writeProducerSec(ctxt *ld.Link) {
 
        writeUleb128(ctxt.Out, 2) // number of fields
 
-       writeName(ctxt.Out, "language")     // field name
-       writeUleb128(ctxt.Out, 1)           // number of values
-       writeName(ctxt.Out, "Go")           // value: name
-       writeName(ctxt.Out, objabi.Version) // value: version
+       writeName(ctxt.Out, "language")       // field name
+       writeUleb128(ctxt.Out, 1)             // number of values
+       writeName(ctxt.Out, "Go")             // value: name
+       writeName(ctxt.Out, buildcfg.Version) // value: version
 
        writeName(ctxt.Out, "processed-by")   // field name
        writeUleb128(ctxt.Out, 1)             // number of values
        writeName(ctxt.Out, "Go cmd/compile") // value: name
-       writeName(ctxt.Out, objabi.Version)   // value: version
+       writeName(ctxt.Out, buildcfg.Version) // value: version
 
        writeSecSize(ctxt, sizeOffset)
 }
index 917bd9e8a3c140f575dde9b5aae6151cfc28eeef..9a4430c162b99de9b56985856b123d306e976619 100644 (file)
@@ -10,8 +10,8 @@ package main
 
 import (
        "bytes"
-       "cmd/internal/objabi"
        "fmt"
+       "internal/buildcfg"
        "internal/testenv"
        "io/ioutil"
        "os/exec"
@@ -19,8 +19,8 @@ import (
 )
 
 func TestLargeText(t *testing.T) {
-       if testing.Short() || (objabi.GOARCH != "ppc64le" && objabi.GOARCH != "ppc64" && objabi.GOARCH != "arm") {
-               t.Skipf("Skipping large text section test in short mode or on %s", objabi.GOARCH)
+       if testing.Short() || (buildcfg.GOARCH != "ppc64le" && buildcfg.GOARCH != "ppc64" && buildcfg.GOARCH != "arm") {
+               t.Skipf("Skipping large text section test in short mode or on %s", buildcfg.GOARCH)
        }
        testenv.MustHaveGoBuild(t)
 
@@ -42,7 +42,7 @@ func TestLargeText(t *testing.T) {
                "ppc64le": "\tMOVD\tR0,R3\n",
                "arm":     "\tMOVW\tR0,R1\n",
        }
-       inst := instOnArch[objabi.GOARCH]
+       inst := instOnArch[buildcfg.GOARCH]
        for j := 0; j < FN; j++ {
                testname := fmt.Sprintf("bigfn%d", j)
                fmt.Fprintf(&w, "TEXT ยท%s(SB),$0\n", testname)
index 6b4ca9706d016e7ddd384bbd7f04b9f4a8b016b9..d92478e61e236858995765665f753fdb19abc36b 100644 (file)
@@ -5,7 +5,6 @@
 package main
 
 import (
-       "cmd/internal/objabi"
        "cmd/internal/sys"
        "cmd/link/internal/amd64"
        "cmd/link/internal/arm"
@@ -19,6 +18,7 @@ import (
        "cmd/link/internal/wasm"
        "cmd/link/internal/x86"
        "fmt"
+       "internal/buildcfg"
        "os"
 )
 
@@ -40,9 +40,10 @@ func main() {
        var arch *sys.Arch
        var theArch ld.Arch
 
-       switch objabi.GOARCH {
+       buildcfg.Check()
+       switch buildcfg.GOARCH {
        default:
-               fmt.Fprintf(os.Stderr, "link: unknown architecture %q\n", objabi.GOARCH)
+               fmt.Fprintf(os.Stderr, "link: unknown architecture %q\n", buildcfg.GOARCH)
                os.Exit(2)
        case "386":
                arch, theArch = x86.Init()
index a1ed834c7150f135a8ce13fd509400da7aec6b66..1b93348edb1968972e80a9a4bd54a43622b6be2d 100644 (file)
@@ -297,7 +297,10 @@ var depsRules = `
        container/heap, go/constant, go/parser, regexp
        < go/types;
 
-       go/build/constraint, go/doc, go/parser, internal/goroot, internal/goversion
+       FMT, internal/goexperiment
+       < internal/buildcfg;
+
+       go/build/constraint, go/doc, go/parser, internal/buildcfg, internal/goroot, internal/goversion
        < go/build;
 
        DEBUG, go/build, go/types, text/scanner
diff --git a/src/internal/buildcfg/cfg.go b/src/internal/buildcfg/cfg.go
new file mode 100644 (file)
index 0000000..9fe7f21
--- /dev/null
@@ -0,0 +1,136 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package buildcfg provides access to the build configuration
+// described by the current environment. It is for use by build tools
+// such as cmd/go or cmd/compile and for setting up go/build's Default context.
+//
+// Note that it does NOT provide access to the build configuration used to
+// build the currently-running binary. For that, use runtime.GOOS etc
+// as well as internal/goexperiment.
+package buildcfg
+
+import (
+       "fmt"
+       "os"
+       "path/filepath"
+       "strings"
+)
+
+var (
+       defaultGOROOT string // set by linker
+
+       GOROOT   = envOr("GOROOT", defaultGOROOT)
+       GOARCH   = envOr("GOARCH", defaultGOARCH)
+       GOOS     = envOr("GOOS", defaultGOOS)
+       GO386    = envOr("GO386", defaultGO386)
+       GOARM    = goarm()
+       GOMIPS   = gomips()
+       GOMIPS64 = gomips64()
+       GOPPC64  = goppc64()
+       GOWASM   = gowasm()
+       GO_LDSO  = defaultGO_LDSO
+       Version  = version
+)
+
+// Error is one of the errors found (if any) in the build configuration.
+var Error error
+
+// Check exits the program with a fatal error if Error is non-nil.
+func Check() {
+       if Error != nil {
+               fmt.Fprintf(os.Stderr, "%s: %v\n", filepath.Base(os.Args[0]), Error)
+               os.Exit(2)
+       }
+}
+
+func envOr(key, value string) string {
+       if x := os.Getenv(key); x != "" {
+               return x
+       }
+       return value
+}
+
+func goarm() int {
+       def := defaultGOARM
+       if GOOS == "android" && GOARCH == "arm" {
+               // Android arm devices always support GOARM=7.
+               def = "7"
+       }
+       switch v := envOr("GOARM", def); v {
+       case "5":
+               return 5
+       case "6":
+               return 6
+       case "7":
+               return 7
+       }
+       Error = fmt.Errorf("invalid GOARM: must be 5, 6, 7")
+       return int(def[0] - '0')
+}
+
+func gomips() string {
+       switch v := envOr("GOMIPS", defaultGOMIPS); v {
+       case "hardfloat", "softfloat":
+               return v
+       }
+       Error = fmt.Errorf("invalid GOMIPS: must be hardfloat, softfloat")
+       return defaultGOMIPS
+}
+
+func gomips64() string {
+       switch v := envOr("GOMIPS64", defaultGOMIPS64); v {
+       case "hardfloat", "softfloat":
+               return v
+       }
+       Error = fmt.Errorf("invalid GOMIPS64: must be hardfloat, softfloat")
+       return defaultGOMIPS64
+}
+
+func goppc64() int {
+       switch v := envOr("GOPPC64", defaultGOPPC64); v {
+       case "power8":
+               return 8
+       case "power9":
+               return 9
+       }
+       Error = fmt.Errorf("invalid GOPPC64: must be power8, power9")
+       return int(defaultGOPPC64[len("power")] - '0')
+}
+
+type gowasmFeatures struct {
+       SignExt bool
+       SatConv bool
+}
+
+func (f gowasmFeatures) String() string {
+       var flags []string
+       if f.SatConv {
+               flags = append(flags, "satconv")
+       }
+       if f.SignExt {
+               flags = append(flags, "signext")
+       }
+       return strings.Join(flags, ",")
+}
+
+func gowasm() (f gowasmFeatures) {
+       for _, opt := range strings.Split(envOr("GOWASM", ""), ",") {
+               switch opt {
+               case "satconv":
+                       f.SatConv = true
+               case "signext":
+                       f.SignExt = true
+               case "":
+                       // ignore
+               default:
+                       Error = fmt.Errorf("invalid GOWASM: no such feature %q", opt)
+               }
+       }
+       return
+}
+
+func Getgoextlinkenabled() string {
+       return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
+}
similarity index 94%
rename from src/cmd/internal/objabi/exp.go
rename to src/internal/buildcfg/exp.go
index 3371c6c8f86751a307dbbb8f009e95e451ef4ce0..dc0adb0963175f8c6a3866cd556bb98154d2ed1c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package objabi
+package buildcfg
 
 import (
        "fmt"
@@ -23,7 +23,7 @@ var Experiment goexperiment.Flags = parseExperiments()
 // experimentBaseline specifies the experiment flags that are enabled by
 // default in the current toolchain. This is, in effect, the "control"
 // configuration and any variation from this is an experiment.
-var experimentBaseline goexperiment.Flags
+var experimentBaseline = goexperiment.Flags{}
 
 // FramePointerEnabled enables the use of platform conventions for
 // saving frame pointers.
@@ -149,3 +149,9 @@ func GOEXPERIMENT() string {
 func EnabledExperiments() []string {
        return expList(&Experiment, nil, false)
 }
+
+// AllExperiments returns a list of all experiment settings.
+// Disabled experiments appear in the list prefixed by "no".
+func AllExperiments() []string {
+       return expList(&Experiment, nil, true)
+}
index 932df10ded175fd5f924951c019f7b2feea68b44..e77734caa4cba7442ad16deddc843eec33c03194 100644 (file)
 // and "go version <binary>" if it differs from the default experiments.
 //
 // For the set of experiments supported by the current toolchain, see
-// go doc internal/experiment.Flags.
+// "go doc goexperiment.Flags".
+//
+// Note that this package defines the set of experiments (in Flags)
+// and records the experiments that were enabled when the package
+// was compiled (as boolean and integer constants).
+//
+// Note especially that this package does not itself change behavior
+// at run time based on the GOEXPERIMENT variable.
+// The code used in builds to interpret the GOEXPERIMENT variable
+// is in the separate package internal/buildcfg.
 package goexperiment
 
 //go:generate go run mkconsts.go