diff --git a/src/cmd/internal/objabi/util.go b/src/cmd/internal/objabi/util.go index c2f1b204b9..a3e1242f59 100644 --- a/src/cmd/internal/objabi/util.go +++ b/src/cmd/internal/objabi/util.go @@ -22,5 +22,12 @@ const ( // 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", buildcfg.GOOS, buildcfg.GOARCH, buildcfg.Version, strings.Join(buildcfg.Experiment.Enabled(), ",")) + archExtra := "" + if k, v := buildcfg.GOGOARCH(); k != "" && v != "" { + archExtra = " " + k + "=" + v + } + return fmt.Sprintf("go object %s %s %s%s X:%s\n", + buildcfg.GOOS, buildcfg.GOARCH, + buildcfg.Version, archExtra, + strings.Join(buildcfg.Experiment.Enabled(), ",")) } diff --git a/src/internal/buildcfg/cfg.go b/src/internal/buildcfg/cfg.go index e8553e8500..a0736aaf74 100644 --- a/src/internal/buildcfg/cfg.go +++ b/src/internal/buildcfg/cfg.go @@ -172,6 +172,28 @@ func experimentTags() []string { return list } +// GOGOARCH returns the name and value of the GO$GOARCH setting. +// For example, if GOARCH is "amd64" it might return "GOAMD64", "v2". +func GOGOARCH() (name, value string) { + switch GOARCH { + case "386": + return "GO386", GO386 + case "amd64": + return "GOAMD64", fmt.Sprintf("v%d", GOAMD64) + case "arm": + return "GOARM", fmt.Sprintf("%d", GOARM) + case "mips", "mipsle": + return "GOMIPS", GOMIPS + case "mips64", "mips64le": + return "GOMIPS64", GOMIPS64 + case "ppc64", "ppc64le": + return "GOPPC64", fmt.Sprintf("power%d", GOPPC64) + case "wasm": + return "GOWASM", GOWASM.String() + } + return "", "" +} + func gogoarchTags() []string { switch GOARCH { case "386":