// The 'path' used for GOROOT_FINAL when -trimpath is specified
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.
type gcToolchain struct{}
if p.Standard {
gcargs = append(gcargs, "-std")
}
- compilingRuntime := p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal"))
- // The runtime package imports a couple of general internal packages.
- if p.Standard && (p.ImportPath == "internal/cpu" || p.ImportPath == "internal/bytealg" || p.ImportPath == "internal/abi") {
- compilingRuntime = true
- }
+ _, compilingRuntime := runtimePackages[p.ImportPath]
+ compilingRuntime = compilingRuntime && p.Standard
if compilingRuntime {
// runtime compiles with a special gc flag to check for
// memory allocations that are invalid in the runtime package,
# No dependencies allowed for any of these packages.
NONE
< container/list, container/ring,
- internal/cfg, internal/cpu, internal/goexperiment,
+ internal/cfg, internal/cpu, internal/goarch,
+ internal/goexperiment, internal/goos,
internal/goversion, internal/nettrace,
unicode/utf8, unicode/utf16, unicode,
unsafe;
< internal/abi;
# 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/itoa
< internal/unsafeheader
--- /dev/null
+// 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)
+ }
+ }
+}
-// 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
// 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
// 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)
-// AIX requires a larger stack for syscalls.
-const StackGuardMultiplier = StackGuardMultiplierDefault*(1-GoosAix) + 2*GoosAix
-
// ArchFamily is the architecture family (AMD64, ARM, ...)
const ArchFamily ArchFamilyType = _ArchFamily
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = I386
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = AMD64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = ARM
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = ARM64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = MIPS
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = MIPS64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = MIPS64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = MIPS
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = PPC64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = PPC64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = RISCV64
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = S390X
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package goarch
const (
_ArchFamily = WASM
-// 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
// +build 386
-package sys
+package goarch
const GOARCH = `386`
-// 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
// +build amd64
-package sys
+package goarch
const GOARCH = `amd64`
-// 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
// +build arm
-package sys
+package goarch
const GOARCH = `arm`
-// 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
// +build arm64
-package sys
+package goarch
const GOARCH = `arm64`
-// 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
// +build arm64be
-package sys
+package goarch
const GOARCH = `arm64be`
-// 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
// +build armbe
-package sys
+package goarch
const GOARCH = `armbe`
-// 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
// +build mips
-package sys
+package goarch
const GOARCH = `mips`
-// 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
// +build mips64
-package sys
+package goarch
const GOARCH = `mips64`
-// 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
// +build mips64le
-package sys
+package goarch
const GOARCH = `mips64le`
-// 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
// +build mips64p32
-package sys
+package goarch
const GOARCH = `mips64p32`
-// 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
// +build mips64p32le
-package sys
+package goarch
const GOARCH = `mips64p32le`
-// 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
// +build mipsle
-package sys
+package goarch
const GOARCH = `mipsle`
-// 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
// +build ppc
-package sys
+package goarch
const GOARCH = `ppc`
-// 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
// +build ppc64
-package sys
+package goarch
const GOARCH = `ppc64`
-// 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
// +build ppc64le
-package sys
+package goarch
const GOARCH = `ppc64le`
-// 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
// +build riscv
-package sys
+package goarch
const GOARCH = `riscv`
-// 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
// +build riscv64
-package sys
+package goarch
const GOARCH = `riscv64`
-// 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
// +build s390
-package sys
+package goarch
const GOARCH = `s390`
-// 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
// +build s390x
-package sys
+package goarch
const GOARCH = `s390x`
-// 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
// +build sparc
-package sys
+package goarch
const GOARCH = `sparc`
-// 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
// +build sparc64
-package sys
+package goarch
const GOARCH = `sparc64`
-// 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
// +build wasm
-package sys
+package goarch
const GOARCH = `wasm`
"strings"
)
-var gooses, goarches []string
+var gooses []string
func main() {
- data, err := os.ReadFile("../../../go/build/syslist.go")
+ data, err := os.ReadFile("../../go/build/syslist.go")
if err != nil {
log.Fatal(err)
}
- const (
- goosPrefix = `const goosList = `
- goarchPrefix = `const goarchList = `
- )
+ const goosPrefix = `const goosList = `
for _, line := range strings.Split(string(data), "\n") {
if strings.HasPrefix(line, goosPrefix) {
text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
}
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 {
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, "// +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)
for _, goos := range gooses {
value := 0
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)
- }
- }
}
--- /dev/null
+// 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
//go:build aix
// +build aix
-package sys
+package goos
const GOOS = `aix`
//go:build android
// +build android
-package sys
+package goos
const GOOS = `android`
//go:build !ios && darwin
// +build !ios,darwin
-package sys
+package goos
const GOOS = `darwin`
//go:build dragonfly
// +build dragonfly
-package sys
+package goos
const GOOS = `dragonfly`
//go:build freebsd
// +build freebsd
-package sys
+package goos
const GOOS = `freebsd`
//go:build hurd
// +build hurd
-package sys
+package goos
const GOOS = `hurd`
//go:build illumos
// +build illumos
-package sys
+package goos
const GOOS = `illumos`
//go:build ios
// +build ios
-package sys
+package goos
const GOOS = `ios`
//go:build js
// +build js
-package sys
+package goos
const GOOS = `js`
//go:build !android && linux
// +build !android,linux
-package sys
+package goos
const GOOS = `linux`
//go:build netbsd
// +build netbsd
-package sys
+package goos
const GOOS = `netbsd`
//go:build openbsd
// +build openbsd
-package sys
+package goos
const GOOS = `openbsd`
//go:build plan9
// +build plan9
-package sys
+package goos
const GOOS = `plan9`
//go:build !illumos && solaris
// +build !illumos,solaris
-package sys
+package goos
const GOOS = `solaris`
//go:build windows
// +build windows
-package sys
+package goos
const GOOS = `windows`
//go:build zos
// +build zos
-package sys
+package goos
const GOOS = `zos`
--- /dev/null
+// 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
+)
// package sys contains system- and configuration- and architecture-specific
// constants used by the runtime.
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