// predefine installs the macros set by the -D flag on the command line.
func predefine(defines flags.MultiFlag) map[string]*Macro {
macros := make(map[string]*Macro)
+
+ if *flags.CompilingRuntime && objabi.Regabi_enabled != 0 {
+ const name = "GOEXPERIMENT_REGABI"
+ macros[name] = &Macro{
+ name: name,
+ args: nil,
+ tokens: Tokenize("1"),
+ }
+ }
+
for _, name := range defines {
value := "1"
i := strings.IndexRune(name, '=')
goextlinkenabled string
gogcflags string // For running built compiler
goldflags string
+ goexperiment string
workdir string
tooldir string
oldgoos string
goextlinkenabled = b
}
+ goexperiment = os.Getenv("GOEXPERIMENT")
+ // TODO(mdempsky): Validate known experiments?
+
gogcflags = os.Getenv("BOOT_GO_GCFLAGS")
goldflags = os.Getenv("BOOT_GO_LDFLAGS")
goasmh := pathf("%s/go_asm.h", workdir)
if IsRuntimePackagePath(pkg) {
asmArgs = append(asmArgs, "-compiling-runtime")
- if os.Getenv("GOEXPERIMENT") == "regabi" {
- // In order to make it easier to port runtime assembly
- // to the register ABI, we introduce a macro
- // indicating the experiment is enabled.
- //
- // Note: a similar change also appears in
- // cmd/go/internal/work/gc.go.
- //
- // TODO(austin): Remove this once we commit to the
- // register ABI (#40724).
- asmArgs = append(asmArgs, "-D=GOEXPERIMENT_REGABI=1")
- }
}
// Collect symabis from assembly code.
// package sys
//
// const TheVersion = <version>
-// const Goexperiment = <goexperiment>
// const StackGuardMultiplier = <multiplier value>
//
func mkzversion(dir, file string) {
fmt.Fprintf(&buf, "package sys\n")
fmt.Fprintln(&buf)
fmt.Fprintf(&buf, "const TheVersion = `%s`\n", findgoversion())
- fmt.Fprintf(&buf, "const Goexperiment = `%s`\n", os.Getenv("GOEXPERIMENT"))
fmt.Fprintf(&buf, "const StackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault())
writefile(buf.String(), file, writeSkipSame)
// 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>
-// const goexperiment = <goexperiment>
//
// The use of runtime.GOOS and runtime.GOARCH makes sure that
// a cross-compiled compiler expects to compile for its own target
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 stackGuardMultiplierDefault = %d\n", stackGuardMultiplierDefault())
- fmt.Fprintf(&buf, "const goexperiment = `%s`\n", os.Getenv("GOEXPERIMENT"))
writefile(buf.String(), file, writeSkipSame)
}
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(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))
+ GOEXPERIMENT = envOr("GOEXPERIMENT", objabi.GOEXPERIMENT)
GOPROXY = envOr("GOPROXY", "https://proxy.golang.org,direct")
GOSUMDB = envOr("GOSUMDB", "sum.golang.org")
key, val := cfg.GetArchEnv()
fmt.Fprintf(h, "%s=%s\n", key, val)
+ if exp := cfg.Getenv("GOEXPERIMENT"); exp != "" {
+ fmt.Fprintf(h, "GOEXPERIMENT=%q\n", exp)
+ }
+
// TODO(rsc): Convince compiler team not to add more magic environment variables,
// or perhaps restrict the environment variables passed to subprocesses.
// Because these are clumsy, undocumented special-case hacks
key, val := cfg.GetArchEnv()
fmt.Fprintf(h, "%s=%s\n", key, val)
+ if exp := cfg.Getenv("GOEXPERIMENT"); exp != "" {
+ fmt.Fprintf(h, "GOEXPERIMENT=%q\n", exp)
+ }
+
// The linker writes source file paths that say GOROOT_FINAL, but
// only if -trimpath is not specified (see ld() in gc.go).
gorootFinal := cfg.GOROOT_FINAL
}
if objabi.IsRuntimePackagePath(pkgpath) {
args = append(args, "-compiling-runtime")
- if objabi.Regabi_enabled != 0 {
- // In order to make it easier to port runtime assembly
- // to the register ABI, we introduce a macro
- // indicating the experiment is enabled.
- //
- // Note: a similar change also appears in
- // cmd/dist/build.go.
- //
- // TODO(austin): Remove this once we commit to the
- // register ABI (#40724).
- args = append(args, "-D=GOEXPERIMENT_REGABI=1")
- }
}
if cfg.Goarch == "mips" || cfg.Goarch == "mipsle" {
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
+ GOROOT = envOr("GOROOT", defaultGOROOT)
+ GOARCH = envOr("GOARCH", defaultGOARCH)
+ GOOS = envOr("GOOS", defaultGOOS)
+ GOEXPERIMENT = envOr("GOEXPERIMENT", defaultGOEXPERIMENT)
+ GO386 = envOr("GO386", defaultGO386)
+ GOARM = goarm()
+ GOMIPS = gomips()
+ GOMIPS64 = gomips64()
+ GOPPC64 = goppc64()
+ GOWASM = gowasm()
+ GO_LDSO = defaultGO_LDSO
+ Version = version
)
const (
}
func init() {
- for _, f := range strings.Split(goexperiment, ",") {
+ for _, f := range strings.Split(GOEXPERIMENT, ",") {
if f != "" {
addexp(f)
}
addstrdata1(ctxt, "runtime.defaultGOROOT="+final)
addstrdata1(ctxt, "cmd/internal/objabi.defaultGOROOT="+final)
+ addstrdata1(ctxt, "runtime/internal/sys.GOEXPERIMENT="+objabi.GOEXPERIMENT)
+
// TODO(matloob): define these above and then check flag values here
if ctxt.Arch.Family == sys.AMD64 && objabi.GOOS == "plan9" {
flag.BoolVar(&flag8, "8", false, "use 64-bit addresses in symbol table")
GOCACHE
GOENV
GOEXE
+ GOEXPERIMENT
GOFLAGS
GOGCCFLAGS
GOHOSTARCH
dumpint(uint64(arenaStart))
dumpint(uint64(arenaEnd))
dumpstr(sys.GOARCH)
- dumpstr(sys.Goexperiment)
+ dumpstr(sys.GOEXPERIMENT)
dumpint(uint64(ncpu))
}
// StackAlign is the required alignment of the SP register.
// The stack must be at least word aligned, but some architectures require more.
const StackAlign = _StackAlign
+
+var GOEXPERIMENT string // set by cmd/link
}
func haveexperiment(name string) bool {
- x := sys.Goexperiment
+ x := sys.GOEXPERIMENT
for x != "" {
xname := ""
i := bytealg.IndexByteString(x, ',')