"fmt"
"internal/buildcfg"
"internal/coverage"
+ "internal/platform"
"log"
"os"
"reflect"
registerFlags()
objabi.Flagparse(usage)
- if Flag.MSan && !sys.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) {
+ if Flag.MSan && !platform.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) {
log.Fatalf("%s/%s does not support -msan", buildcfg.GOOS, buildcfg.GOARCH)
}
- if Flag.ASan && !sys.ASanSupported(buildcfg.GOOS, buildcfg.GOARCH) {
+ if Flag.ASan && !platform.ASanSupported(buildcfg.GOOS, buildcfg.GOARCH) {
log.Fatalf("%s/%s does not support -asan", buildcfg.GOOS, buildcfg.GOARCH)
}
- if Flag.Race && !sys.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) {
+ if Flag.Race && !platform.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) {
"internal/pkgbits",
"internal/race",
"internal/saferio",
+ "internal/platform",
"internal/unsafeheader",
"internal/xcoff",
"math/big",
}
// raceDetectorSupported is a copy of the function
-// cmd/internal/sys.RaceDetectorSupported, which can't be used here
+// internal/platform.RaceDetectorSupported, which can't be used here
// because cmd/dist has to be buildable by Go 1.4.
// The race detector only supports 48-bit VMA on arm64. But we don't have
// a good solution to check VMA size(See https://golang.org/issue/29948)
"fmt"
"go/format"
"internal/godebug"
+ "internal/platform"
"internal/testenv"
"io"
"io/fs"
}
testGOCACHE = strings.TrimSpace(string(out))
- canMSan = canCgo && sys.MSanSupported(runtime.GOOS, runtime.GOARCH)
- canASan = canCgo && sys.ASanSupported(runtime.GOOS, runtime.GOARCH)
- canRace = canCgo && sys.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH)
+ canMSan = canCgo && platform.MSanSupported(runtime.GOOS, runtime.GOARCH)
+ canASan = canCgo && platform.ASanSupported(runtime.GOOS, runtime.GOARCH)
+ canRace = canCgo && platform.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH)
// The race detector doesn't work on Alpine Linux:
// golang.org/issue/14481
// gccgo does not support the race detector.
if isAlpineLinux() || runtime.Compiler == "gccgo" {
canRace = false
}
- canFuzz = sys.FuzzSupported(runtime.GOOS, runtime.GOARCH)
- fuzzInstrumented = sys.FuzzInstrumented(runtime.GOOS, runtime.GOARCH)
+ canFuzz = platform.FuzzSupported(runtime.GOOS, runtime.GOARCH)
+ fuzzInstrumented = platform.FuzzInstrumented(runtime.GOOS, runtime.GOARCH)
}
// Don't let these environment variables confuse the test.
"go/build"
"go/scanner"
"go/token"
+ "internal/platform"
"io/fs"
"os"
"os/exec"
"cmd/go/internal/trace"
"cmd/go/internal/vcs"
"cmd/internal/pkgpattern"
- "cmd/internal/sys"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
// -ldflags=-linkmode=external. External linking mode forces
// an import of runtime/cgo.
// If there are multiple -linkmode options, the last one wins.
- pieCgo := cfg.BuildBuildmode == "pie" && !sys.InternalLinkPIESupported(cfg.BuildContext.GOOS, cfg.BuildContext.GOARCH)
+ pieCgo := cfg.BuildBuildmode == "pie" && !platform.InternalLinkPIESupported(cfg.BuildContext.GOOS, cfg.BuildContext.GOARCH)
linkmodeExternal := false
if p != nil {
ldflags := BuildLdflags.For(p)
"context"
"errors"
"fmt"
+ "internal/platform"
"io"
"io/fs"
"os"
"cmd/go/internal/str"
"cmd/go/internal/trace"
"cmd/go/internal/work"
- "cmd/internal/sys"
"cmd/internal/test2json"
"golang.org/x/mod/module"
base.Fatalf("cannot use -o flag with multiple packages")
}
if testFuzz != "" {
- if !sys.FuzzSupported(cfg.Goos, cfg.Goarch) {
+ if !platform.FuzzSupported(cfg.Goos, cfg.Goarch) {
base.Fatalf("-fuzz flag is not supported on %s/%s", cfg.Goos, cfg.Goarch)
}
if len(pkgs) != 1 {
"bufio"
"bytes"
"fmt"
+ "internal/platform"
"io"
"log"
"os"
"cmd/go/internal/str"
"cmd/internal/objabi"
"cmd/internal/quoted"
- "cmd/internal/sys"
"crypto/sha1"
)
// linker's build id, which will cause our build id to not
// match the next time the tool is built.
// Rely on the external build id instead.
- if !sys.MustLinkExternal(cfg.Goos, cfg.Goarch) {
+ if !platform.MustLinkExternal(cfg.Goos, cfg.Goarch) {
ldflags = append(ldflags, "-X=cmd/internal/objabi.buildID="+root.buildID)
}
}
"cmd/go/internal/fsys"
"cmd/go/internal/modload"
"cmd/internal/quoted"
- "cmd/internal/sys"
"fmt"
+ "internal/platform"
"os"
"os/exec"
"path/filepath"
// instrumentation is added. 'go test -fuzz' still works without coverage,
// but it generates random inputs without guidance, so it's much less effective.
func fuzzInstrumentFlags() []string {
- if !sys.FuzzInstrumented(cfg.Goos, cfg.Goarch) {
+ if !platform.FuzzInstrumented(cfg.Goos, cfg.Goarch) {
return nil
}
return []string{"-d=libfuzzer"}
base.SetExitStatus(2)
base.Exit()
}
- if cfg.BuildMSan && !sys.MSanSupported(cfg.Goos, cfg.Goarch) {
+ if cfg.BuildMSan && !platform.MSanSupported(cfg.Goos, cfg.Goarch) {
fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
base.SetExitStatus(2)
base.Exit()
}
- if cfg.BuildRace && !sys.RaceDetectorSupported(cfg.Goos, cfg.Goarch) {
+ if cfg.BuildRace && !platform.RaceDetectorSupported(cfg.Goos, cfg.Goarch) {
fmt.Fprintf(os.Stderr, "-race is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
base.SetExitStatus(2)
base.Exit()
}
- if cfg.BuildASan && !sys.ASanSupported(cfg.Goos, cfg.Goarch) {
+ if cfg.BuildASan && !platform.ASanSupported(cfg.Goos, cfg.Goarch) {
fmt.Fprintf(os.Stderr, "-asan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
base.SetExitStatus(2)
base.Exit()
base.Fatalf("buildmode=%s not supported", cfg.BuildBuildmode)
}
- if !sys.BuildModeSupported(cfg.BuildToolchainName, cfg.BuildBuildmode, cfg.Goos, cfg.Goarch) {
+ if !platform.BuildModeSupported(cfg.BuildToolchainName, cfg.BuildBuildmode, cfg.Goos, cfg.Goarch) {
base.Fatalf("-buildmode=%s not supported on %s/%s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch)
}
if cfg.BuildLinkshared {
- if !sys.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) {
+ if !platform.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) {
base.Fatalf("-linkshared not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
}
if gccgo {
"fmt"
"go/build"
"internal/buildcfg"
+ "internal/platform"
"internal/testenv"
"internal/txtar"
"io/fs"
"cmd/go/internal/par"
"cmd/go/internal/robustio"
"cmd/go/internal/work"
- "cmd/internal/sys"
)
var testSum = flag.String("testsum", "", `may be tidy, listm, or listall. If set, TestScript generates a go.sum file at the beginning of each test and updates test files if they pass.`)
break
}
if value, found := strings.CutPrefix(cond.tag, "buildmode:"); found {
- ok = sys.BuildModeSupported(runtime.Compiler, value, runtime.GOOS, runtime.GOARCH)
+ ok = platform.BuildModeSupported(runtime.Compiler, value, runtime.GOOS, runtime.GOARCH)
break
}
if strings.HasPrefix(cond.tag, "GOEXPERIMENT:") {
+++ /dev/null
-// Copyright 2020 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/testenv"
- "runtime"
- "testing"
-)
-
-func TestMustLinkExternalMatchesTestenv(t *testing.T) {
- // MustLinkExternal and testenv.CanInternalLink are the exact opposite.
- if b := MustLinkExternal(runtime.GOOS, runtime.GOARCH); b != !testenv.CanInternalLink() {
- t.Fatalf("MustLinkExternal() == %v, testenv.CanInternalLink() == %v, don't match", b, testenv.CanInternalLink())
- }
-}
import (
"debug/elf"
"fmt"
+ "internal/platform"
"internal/testenv"
"os"
"os/exec"
"sync"
"testing"
"text/template"
-
- "cmd/internal/sys"
)
func getCCAndCCFLAGS(t *testing.T, env []string) (string, []string) {
// always skip the test if cgo is not supported.
testenv.MustHaveCGO(t)
- if !sys.BuildModeSupported(runtime.Compiler, "pie", runtime.GOOS, runtime.GOARCH) {
+ if !platform.BuildModeSupported(runtime.Compiler, "pie", runtime.GOOS, runtime.GOARCH) {
t.Skip("-buildmode=pie not supported")
}
"cmd/internal/sys"
"fmt"
"internal/buildcfg"
+ "internal/platform"
)
// A BuildMode indicates the sort of object we are building.
}()
}
- if sys.MustLinkExternal(buildcfg.GOOS, buildcfg.GOARCH) {
+ if platform.MustLinkExternal(buildcfg.GOOS, buildcfg.GOARCH) {
return true, fmt.Sprintf("%s/%s requires external linking", buildcfg.GOOS, buildcfg.GOARCH)
}
"bytes"
"debug/macho"
"internal/buildcfg"
+ "internal/platform"
"internal/testenv"
"os"
"os/exec"
"runtime"
"strings"
"testing"
-
- "cmd/internal/sys"
)
var AuthorPaidByTheColumnInch struct {
func TestIssue42396(t *testing.T) {
testenv.MustHaveGoBuild(t)
- if !sys.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) {
+ if !platform.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) {
t.Skip("no race detector support")
}
import (
"cmd/internal/notsha256"
- "cmd/internal/sys"
"flag"
"fmt"
"go/build"
+ "internal/platform"
"internal/testenv"
"os"
"os/exec"
}
func TestDisasmPIE(t *testing.T) {
- if !sys.BuildModeSupported("gc", "pie", runtime.GOOS, runtime.GOARCH) {
+ if !platform.BuildModeSupported("gc", "pie", runtime.GOOS, runtime.GOARCH) {
t.Skipf("skipping on %s/%s, PIE buildmode not supported", runtime.GOOS, runtime.GOARCH)
}
t.Parallel()
internal/coverage/uleb128, internal/coverage/calloc,
internal/cpu, internal/goarch,
internal/goexperiment, internal/goos,
- internal/goversion, internal/nettrace,
+ internal/goversion, internal/nettrace, internal/platform,
unicode/utf8, unicode/utf16, unicode,
unsafe;
internal/fuzz, internal/testlog, runtime/pprof, regexp
< testing/internal/testdeps;
- OS, flag, testing, internal/cfg
+ OS, flag, testing, internal/cfg, internal/platform
< internal/testenv;
OS, encoding/base64
// the instrumentation is OS specific, but only amd64 and arm64 are
// supported in the runtime. See src/runtime/libfuzzer*.
//
-// If you update this constraint, also update cmd/internal/sys.FuzzInstrumeted.
+// If you update this constraint, also update internal/platform.FuzzInstrumeted.
//
//go:build !((darwin || linux || windows || freebsd) && (amd64 || arm64))
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// If you update this constraint, also update cmd/internal/sys.FuzzSupported.
+// If you update this constraint, also update internal/platform.FuzzSupported.
//
//go:build !darwin && !freebsd && !linux && !windows
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package sys
+package platform
// RaceDetectorSupported reports whether goos/goarch supports the race
// detector. There is a copy of this function in cmd/dist/test.go.
}
// MustLinkExternal reports whether goos/goarch requires external linking.
-// (This is the opposite of internal/testenv.CanInternalLink. Keep them in sync.)
func MustLinkExternal(goos, goarch string) bool {
switch goos {
case "android":
"flag"
"fmt"
"internal/cfg"
+ "internal/platform"
"os"
"os/exec"
"path/filepath"
// CanInternalLink reports whether the current system can link programs with
// internal linking.
-// (This is the opposite of cmd/internal/sys.MustLinkExternal. Keep them in sync.)
func CanInternalLink() bool {
- switch runtime.GOOS {
- case "android":
- if runtime.GOARCH != "arm64" {
- return false
- }
- case "ios":
- if runtime.GOARCH == "arm64" {
- return false
- }
- }
- return true
+ return !platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH)
}
// MustInternalLink checks that the current system can link programs with internal