mirror of
https://github.com/golang/go
synced 2024-11-26 06:38:00 -07:00
[dev.typeparams] internal/goarch,internal/goos: explode runtime/internal/sys into pieces
This change extracts the GOOS and GOARCH specific constants from runtime/internal/sys into packages that are available to the entire standard library. This change does not yet update the runtime and associated packages to use them, and instead adds constants to runtime/internal/sys to forward the constants defined by these new packages. Change-Id: I14d574b8d7bfe599ad25da29dc1b39716e35a734 Reviewed-on: https://go-review.googlesource.com/c/go/+/328336 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
804ecc2581
commit
122f5e16d6
@ -29,6 +29,18 @@ import (
|
|||||||
// The 'path' used for GOROOT_FINAL when -trimpath is specified
|
// The 'path' used for GOROOT_FINAL when -trimpath is specified
|
||||||
const trimPathGoRootFinal = "go"
|
const trimPathGoRootFinal = "go"
|
||||||
|
|
||||||
|
var runtimePackages = map[string]struct{}{
|
||||||
|
"internal/abi": struct{}{},
|
||||||
|
"internal/bytealg": struct{}{},
|
||||||
|
"internal/cpu": struct{}{},
|
||||||
|
"internal/goarch": struct{}{},
|
||||||
|
"internal/goos": struct{}{},
|
||||||
|
"runtime": struct{}{},
|
||||||
|
"runtime/internal/atomic": struct{}{},
|
||||||
|
"runtime/internal/math": struct{}{},
|
||||||
|
"runtime/internal/sys": struct{}{},
|
||||||
|
}
|
||||||
|
|
||||||
// The Go toolchain.
|
// The Go toolchain.
|
||||||
|
|
||||||
type gcToolchain struct{}
|
type gcToolchain struct{}
|
||||||
@ -88,11 +100,8 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg, embedcfg
|
|||||||
if p.Standard {
|
if p.Standard {
|
||||||
gcargs = append(gcargs, "-std")
|
gcargs = append(gcargs, "-std")
|
||||||
}
|
}
|
||||||
compilingRuntime := p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal"))
|
_, compilingRuntime := runtimePackages[p.ImportPath]
|
||||||
// The runtime package imports a couple of general internal packages.
|
compilingRuntime = compilingRuntime && p.Standard
|
||||||
if p.Standard && (p.ImportPath == "internal/cpu" || p.ImportPath == "internal/bytealg" || p.ImportPath == "internal/abi") {
|
|
||||||
compilingRuntime = true
|
|
||||||
}
|
|
||||||
if compilingRuntime {
|
if compilingRuntime {
|
||||||
// runtime compiles with a special gc flag to check for
|
// runtime compiles with a special gc flag to check for
|
||||||
// memory allocations that are invalid in the runtime package,
|
// memory allocations that are invalid in the runtime package,
|
||||||
|
@ -71,7 +71,8 @@ var depsRules = `
|
|||||||
# No dependencies allowed for any of these packages.
|
# No dependencies allowed for any of these packages.
|
||||||
NONE
|
NONE
|
||||||
< container/list, container/ring,
|
< container/list, container/ring,
|
||||||
internal/cfg, internal/cpu, internal/goexperiment,
|
internal/cfg, internal/cpu, internal/goarch,
|
||||||
|
internal/goexperiment, internal/goos,
|
||||||
internal/goversion, internal/nettrace,
|
internal/goversion, internal/nettrace,
|
||||||
unicode/utf8, unicode/utf16, unicode,
|
unicode/utf8, unicode/utf16, unicode,
|
||||||
unsafe;
|
unsafe;
|
||||||
@ -81,7 +82,8 @@ var depsRules = `
|
|||||||
< internal/abi;
|
< internal/abi;
|
||||||
|
|
||||||
# RUNTIME is the core runtime group of packages, all of them very light-weight.
|
# RUNTIME is the core runtime group of packages, all of them very light-weight.
|
||||||
internal/abi, internal/cpu, internal/goexperiment, unsafe
|
internal/abi, internal/cpu, internal/goarch,
|
||||||
|
internal/goexperiment, internal/goos, unsafe
|
||||||
< internal/bytealg
|
< internal/bytealg
|
||||||
< internal/itoa
|
< internal/itoa
|
||||||
< internal/unsafeheader
|
< internal/unsafeheader
|
||||||
|
59
src/internal/goarch/gengoarch.go
Normal file
59
src/internal/goarch/gengoarch.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
//go:build ignore
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var goarches []string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
data, err := os.ReadFile("../../go/build/syslist.go")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
const goarchPrefix = `const goarchList = `
|
||||||
|
for _, line := range strings.Split(string(data), "\n") {
|
||||||
|
if strings.HasPrefix(line, goarchPrefix) {
|
||||||
|
text, err := strconv.Unquote(strings.TrimPrefix(line, goarchPrefix))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("parsing goarchList: %v", err)
|
||||||
|
}
|
||||||
|
goarches = strings.Fields(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, target := range goarches {
|
||||||
|
if target == "amd64p32" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n")
|
||||||
|
fmt.Fprintf(&buf, "//go:build %s\n", target)
|
||||||
|
fmt.Fprintf(&buf, "// +build %s\n\n", target) // must explicitly include target for bootstrapping purposes
|
||||||
|
fmt.Fprintf(&buf, "package goarch\n\n")
|
||||||
|
fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
|
||||||
|
for _, goarch := range goarches {
|
||||||
|
value := 0
|
||||||
|
if goarch == target {
|
||||||
|
value = 1
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&buf, "const Goarch%s = %d\n", strings.Title(goarch), value)
|
||||||
|
}
|
||||||
|
err := os.WriteFile("zgoarch_"+target+".go", buf.Bytes(), 0666)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,15 @@
|
|||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
// package goarch contains GOARCH-specific constants.
|
||||||
|
package goarch
|
||||||
|
|
||||||
|
// The next line makes 'go generate' write the zgoarch*.go files with
|
||||||
|
// per-arch information, including constants named Goarch$GOARCH for every
|
||||||
|
// GOARCH. The constant is 1 on the current system, 0 otherwise; multiplying
|
||||||
|
// by them is useful for defining GOARCH-specific constants.
|
||||||
|
//go:generate go run gengoarch.go
|
||||||
|
|
||||||
type ArchFamilyType int
|
type ArchFamilyType int
|
||||||
|
|
||||||
@ -23,9 +30,6 @@ const (
|
|||||||
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
|
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
|
||||||
const PtrSize = 4 << (^uintptr(0) >> 63)
|
const PtrSize = 4 << (^uintptr(0) >> 63)
|
||||||
|
|
||||||
// AIX requires a larger stack for syscalls.
|
|
||||||
const StackGuardMultiplier = StackGuardMultiplierDefault*(1-GoosAix) + 2*GoosAix
|
|
||||||
|
|
||||||
// ArchFamily is the architecture family (AMD64, ARM, ...)
|
// ArchFamily is the architecture family (AMD64, ARM, ...)
|
||||||
const ArchFamily ArchFamilyType = _ArchFamily
|
const ArchFamily ArchFamilyType = _ArchFamily
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = I386
|
_ArchFamily = I386
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = AMD64
|
_ArchFamily = AMD64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = ARM
|
_ArchFamily = ARM
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = ARM64
|
_ArchFamily = ARM64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = MIPS
|
_ArchFamily = MIPS
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = MIPS64
|
_ArchFamily = MIPS64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = MIPS64
|
_ArchFamily = MIPS64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = MIPS
|
_ArchFamily = MIPS
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = PPC64
|
_ArchFamily = PPC64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = PPC64
|
_ArchFamily = PPC64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = RISCV64
|
_ArchFamily = RISCV64
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = S390X
|
_ArchFamily = S390X
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_ArchFamily = WASM
|
_ArchFamily = WASM
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build 386
|
//go:build 386
|
||||||
// +build 386
|
// +build 386
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `386`
|
const GOARCH = `386`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build amd64
|
//go:build amd64
|
||||||
// +build amd64
|
// +build amd64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `amd64`
|
const GOARCH = `amd64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build arm
|
//go:build arm
|
||||||
// +build arm
|
// +build arm
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `arm`
|
const GOARCH = `arm`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build arm64
|
//go:build arm64
|
||||||
// +build arm64
|
// +build arm64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `arm64`
|
const GOARCH = `arm64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build arm64be
|
//go:build arm64be
|
||||||
// +build arm64be
|
// +build arm64be
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `arm64be`
|
const GOARCH = `arm64be`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build armbe
|
//go:build armbe
|
||||||
// +build armbe
|
// +build armbe
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `armbe`
|
const GOARCH = `armbe`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mips
|
//go:build mips
|
||||||
// +build mips
|
// +build mips
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mips`
|
const GOARCH = `mips`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mips64
|
//go:build mips64
|
||||||
// +build mips64
|
// +build mips64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mips64`
|
const GOARCH = `mips64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mips64le
|
//go:build mips64le
|
||||||
// +build mips64le
|
// +build mips64le
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mips64le`
|
const GOARCH = `mips64le`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mips64p32
|
//go:build mips64p32
|
||||||
// +build mips64p32
|
// +build mips64p32
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mips64p32`
|
const GOARCH = `mips64p32`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mips64p32le
|
//go:build mips64p32le
|
||||||
// +build mips64p32le
|
// +build mips64p32le
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mips64p32le`
|
const GOARCH = `mips64p32le`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build mipsle
|
//go:build mipsle
|
||||||
// +build mipsle
|
// +build mipsle
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `mipsle`
|
const GOARCH = `mipsle`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build ppc
|
//go:build ppc
|
||||||
// +build ppc
|
// +build ppc
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `ppc`
|
const GOARCH = `ppc`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build ppc64
|
//go:build ppc64
|
||||||
// +build ppc64
|
// +build ppc64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `ppc64`
|
const GOARCH = `ppc64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build ppc64le
|
//go:build ppc64le
|
||||||
// +build ppc64le
|
// +build ppc64le
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `ppc64le`
|
const GOARCH = `ppc64le`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build riscv
|
//go:build riscv
|
||||||
// +build riscv
|
// +build riscv
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `riscv`
|
const GOARCH = `riscv`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build riscv64
|
//go:build riscv64
|
||||||
// +build riscv64
|
// +build riscv64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `riscv64`
|
const GOARCH = `riscv64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build s390
|
//go:build s390
|
||||||
// +build s390
|
// +build s390
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `s390`
|
const GOARCH = `s390`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build s390x
|
//go:build s390x
|
||||||
// +build s390x
|
// +build s390x
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `s390x`
|
const GOARCH = `s390x`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build sparc
|
//go:build sparc
|
||||||
// +build sparc
|
// +build sparc
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `sparc`
|
const GOARCH = `sparc`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build sparc64
|
//go:build sparc64
|
||||||
// +build sparc64
|
// +build sparc64
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `sparc64`
|
const GOARCH = `sparc64`
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
//go:build wasm
|
//go:build wasm
|
||||||
// +build wasm
|
// +build wasm
|
||||||
|
|
||||||
package sys
|
package goarch
|
||||||
|
|
||||||
const GOARCH = `wasm`
|
const GOARCH = `wasm`
|
||||||
|
|
@ -16,17 +16,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var gooses, goarches []string
|
var gooses []string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
data, err := os.ReadFile("../../../go/build/syslist.go")
|
data, err := os.ReadFile("../../go/build/syslist.go")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
const (
|
const goosPrefix = `const goosList = `
|
||||||
goosPrefix = `const goosList = `
|
|
||||||
goarchPrefix = `const goarchList = `
|
|
||||||
)
|
|
||||||
for _, line := range strings.Split(string(data), "\n") {
|
for _, line := range strings.Split(string(data), "\n") {
|
||||||
if strings.HasPrefix(line, goosPrefix) {
|
if strings.HasPrefix(line, goosPrefix) {
|
||||||
text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
|
text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
|
||||||
@ -35,13 +32,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
gooses = strings.Fields(text)
|
gooses = strings.Fields(text)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(line, goarchPrefix) {
|
|
||||||
text, err := strconv.Unquote(strings.TrimPrefix(line, goarchPrefix))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("parsing goarchList: %v", err)
|
|
||||||
}
|
|
||||||
goarches = strings.Fields(text)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range gooses {
|
for _, target := range gooses {
|
||||||
@ -63,7 +53,7 @@ func main() {
|
|||||||
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
|
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
|
||||||
fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
|
fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
|
||||||
fmt.Fprintf(&buf, "// +build %s\n\n", strings.Join(tags, ","))
|
fmt.Fprintf(&buf, "// +build %s\n\n", strings.Join(tags, ","))
|
||||||
fmt.Fprintf(&buf, "package sys\n\n")
|
fmt.Fprintf(&buf, "package goos\n\n")
|
||||||
fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
|
fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
|
||||||
for _, goos := range gooses {
|
for _, goos := range gooses {
|
||||||
value := 0
|
value := 0
|
||||||
@ -77,27 +67,4 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range goarches {
|
|
||||||
if target == "amd64p32" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var buf bytes.Buffer
|
|
||||||
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
|
|
||||||
fmt.Fprintf(&buf, "//go:build %s\n", target)
|
|
||||||
fmt.Fprintf(&buf, "// +build %s\n\n", target) // must explicitly include target for bootstrapping purposes
|
|
||||||
fmt.Fprintf(&buf, "package sys\n\n")
|
|
||||||
fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
|
|
||||||
for _, goarch := range goarches {
|
|
||||||
value := 0
|
|
||||||
if goarch == target {
|
|
||||||
value = 1
|
|
||||||
}
|
|
||||||
fmt.Fprintf(&buf, "const Goarch%s = %d\n", strings.Title(goarch), value)
|
|
||||||
}
|
|
||||||
err := os.WriteFile("zgoarch_"+target+".go", buf.Bytes(), 0666)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
12
src/internal/goos/goos.go
Normal file
12
src/internal/goos/goos.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2015 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 goos contains GOOS-specific constants.
|
||||||
|
package goos
|
||||||
|
|
||||||
|
// The next line makes 'go generate' write the zgoos*.go files with
|
||||||
|
// per-OS information, including constants named Goos$GOOS for every
|
||||||
|
// known GOOS. The constant is 1 on the current system, 0 otherwise;
|
||||||
|
// multiplying by them is useful for defining GOOS-specific constants.
|
||||||
|
//go:generate go run gengoos.go
|
@ -3,7 +3,7 @@
|
|||||||
//go:build aix
|
//go:build aix
|
||||||
// +build aix
|
// +build aix
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `aix`
|
const GOOS = `aix`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build android
|
//go:build android
|
||||||
// +build android
|
// +build android
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `android`
|
const GOOS = `android`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build !ios && darwin
|
//go:build !ios && darwin
|
||||||
// +build !ios,darwin
|
// +build !ios,darwin
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `darwin`
|
const GOOS = `darwin`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build dragonfly
|
//go:build dragonfly
|
||||||
// +build dragonfly
|
// +build dragonfly
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `dragonfly`
|
const GOOS = `dragonfly`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
// +build freebsd
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `freebsd`
|
const GOOS = `freebsd`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build hurd
|
//go:build hurd
|
||||||
// +build hurd
|
// +build hurd
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `hurd`
|
const GOOS = `hurd`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build illumos
|
//go:build illumos
|
||||||
// +build illumos
|
// +build illumos
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `illumos`
|
const GOOS = `illumos`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build ios
|
//go:build ios
|
||||||
// +build ios
|
// +build ios
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `ios`
|
const GOOS = `ios`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build js
|
//go:build js
|
||||||
// +build js
|
// +build js
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `js`
|
const GOOS = `js`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build !android && linux
|
//go:build !android && linux
|
||||||
// +build !android,linux
|
// +build !android,linux
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `linux`
|
const GOOS = `linux`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build netbsd
|
//go:build netbsd
|
||||||
// +build netbsd
|
// +build netbsd
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `netbsd`
|
const GOOS = `netbsd`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
// +build openbsd
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `openbsd`
|
const GOOS = `openbsd`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build plan9
|
//go:build plan9
|
||||||
// +build plan9
|
// +build plan9
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `plan9`
|
const GOOS = `plan9`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build !illumos && solaris
|
//go:build !illumos && solaris
|
||||||
// +build !illumos,solaris
|
// +build !illumos,solaris
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `solaris`
|
const GOOS = `solaris`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `windows`
|
const GOOS = `windows`
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
//go:build zos
|
//go:build zos
|
||||||
// +build zos
|
// +build zos
|
||||||
|
|
||||||
package sys
|
package goos
|
||||||
|
|
||||||
const GOOS = `zos`
|
const GOOS = `zos`
|
||||||
|
|
109
src/runtime/internal/sys/consts.go
Normal file
109
src/runtime/internal/sys/consts.go
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
// Copyright 2014 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 sys
|
||||||
|
|
||||||
|
import (
|
||||||
|
"internal/goarch"
|
||||||
|
"internal/goos"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ArchFamilyType = goarch.ArchFamilyType
|
||||||
|
|
||||||
|
const (
|
||||||
|
AMD64 = goarch.AMD64
|
||||||
|
ARM = goarch.ARM
|
||||||
|
ARM64 = goarch.ARM64
|
||||||
|
I386 = goarch.I386
|
||||||
|
MIPS = goarch.MIPS
|
||||||
|
MIPS64 = goarch.MIPS64
|
||||||
|
PPC64 = goarch.PPC64
|
||||||
|
RISCV64 = goarch.RISCV64
|
||||||
|
S390X = goarch.S390X
|
||||||
|
WASM = goarch.WASM
|
||||||
|
)
|
||||||
|
|
||||||
|
// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
|
||||||
|
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
|
||||||
|
const PtrSize = goarch.PtrSize
|
||||||
|
|
||||||
|
// ArchFamily is the architecture family (AMD64, ARM, ...)
|
||||||
|
const ArchFamily ArchFamilyType = goarch.ArchFamily
|
||||||
|
|
||||||
|
// AIX requires a larger stack for syscalls.
|
||||||
|
const StackGuardMultiplier = StackGuardMultiplierDefault*(1-goos.GoosAix) + 2*goos.GoosAix
|
||||||
|
|
||||||
|
// BigEndian reports whether the architecture is big-endian.
|
||||||
|
const BigEndian = goarch.BigEndian
|
||||||
|
|
||||||
|
// DefaultPhysPageSize is the default physical page size.
|
||||||
|
const DefaultPhysPageSize = goarch.DefaultPhysPageSize
|
||||||
|
|
||||||
|
// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
|
||||||
|
// The various PC tables record PC deltas pre-divided by PCQuantum.
|
||||||
|
const PCQuantum = goarch.PCQuantum
|
||||||
|
|
||||||
|
// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
|
||||||
|
const Int64Align = goarch.PtrSize
|
||||||
|
|
||||||
|
// MinFrameSize is the size of the system-reserved words at the bottom
|
||||||
|
// of a frame (just above the architectural stack pointer).
|
||||||
|
// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
|
||||||
|
// On PowerPC it is larger, to cover three more reserved words:
|
||||||
|
// the compiler word, the link editor word, and the TOC save word.
|
||||||
|
const MinFrameSize = goarch.MinFrameSize
|
||||||
|
|
||||||
|
// StackAlign is the required alignment of the SP register.
|
||||||
|
// The stack must be at least word aligned, but some architectures require more.
|
||||||
|
const StackAlign = goarch.StackAlign
|
||||||
|
|
||||||
|
const GOARCH = goarch.GOARCH
|
||||||
|
|
||||||
|
const (
|
||||||
|
Goarch386 = goarch.Goarch386
|
||||||
|
GoarchAmd64 = goarch.GoarchAmd64
|
||||||
|
GoarchAmd64p32 = goarch.GoarchAmd64p32
|
||||||
|
GoarchArm = goarch.GoarchArm
|
||||||
|
GoarchArmbe = goarch.GoarchArmbe
|
||||||
|
GoarchArm64 = goarch.GoarchArm64
|
||||||
|
GoarchArm64be = goarch.GoarchArm64be
|
||||||
|
GoarchPpc64 = goarch.GoarchPpc64
|
||||||
|
GoarchPpc64le = goarch.GoarchPpc64le
|
||||||
|
GoarchMips = goarch.GoarchMips
|
||||||
|
GoarchMipsle = goarch.GoarchMipsle
|
||||||
|
GoarchMips64 = goarch.GoarchMips64
|
||||||
|
GoarchMips64le = goarch.GoarchMips64le
|
||||||
|
GoarchMips64p32 = goarch.GoarchMips64p32
|
||||||
|
GoarchMips64p32le = goarch.GoarchMips64p32le
|
||||||
|
GoarchPpc = goarch.GoarchPpc
|
||||||
|
GoarchRiscv = goarch.GoarchRiscv
|
||||||
|
GoarchRiscv64 = goarch.GoarchRiscv64
|
||||||
|
GoarchS390 = goarch.GoarchS390
|
||||||
|
GoarchS390x = goarch.GoarchS390x
|
||||||
|
GoarchSparc = goarch.GoarchSparc
|
||||||
|
GoarchSparc64 = goarch.GoarchSparc64
|
||||||
|
GoarchWasm = goarch.GoarchWasm
|
||||||
|
)
|
||||||
|
|
||||||
|
const GOOS = goos.GOOS
|
||||||
|
|
||||||
|
const (
|
||||||
|
GoosAix = goos.GoosAix
|
||||||
|
GoosAndroid = goos.GoosAndroid
|
||||||
|
GoosDarwin = goos.GoosDarwin
|
||||||
|
GoosDragonfly = goos.GoosDragonfly
|
||||||
|
GoosFreebsd = goos.GoosFreebsd
|
||||||
|
GoosHurd = goos.GoosHurd
|
||||||
|
GoosIllumos = goos.GoosIllumos
|
||||||
|
GoosIos = goos.GoosIos
|
||||||
|
GoosJs = goos.GoosJs
|
||||||
|
GoosLinux = goos.GoosLinux
|
||||||
|
GoosNacl = goos.GoosNacl
|
||||||
|
GoosNetbsd = goos.GoosNetbsd
|
||||||
|
GoosOpenbsd = goos.GoosOpenbsd
|
||||||
|
GoosPlan9 = goos.GoosPlan9
|
||||||
|
GoosSolaris = goos.GoosSolaris
|
||||||
|
GoosWindows = goos.GoosWindows
|
||||||
|
GoosZos = goos.GoosZos
|
||||||
|
)
|
@ -5,11 +5,3 @@
|
|||||||
// package sys contains system- and configuration- and architecture-specific
|
// package sys contains system- and configuration- and architecture-specific
|
||||||
// constants used by the runtime.
|
// constants used by the runtime.
|
||||||
package sys
|
package sys
|
||||||
|
|
||||||
// The next line makes 'go generate' write the zgo*.go files with
|
|
||||||
// per-OS and per-arch information, including constants
|
|
||||||
// named Goos$GOOS and Goarch$GOARCH for every
|
|
||||||
// known GOOS and GOARCH. The constant is 1 on the
|
|
||||||
// current system, 0 otherwise; multiplying by them is
|
|
||||||
// useful for defining GOOS- or GOARCH-specific constants.
|
|
||||||
//go:generate go run gengoos.go
|
|
||||||
|
Loading…
Reference in New Issue
Block a user