summaryrefslogtreecommitdiff
path: root/libgo/go/cmd/go/internal/work/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/cmd/go/internal/work/init.go')
-rw-r--r--libgo/go/cmd/go/internal/work/init.go54
1 files changed, 47 insertions, 7 deletions
diff --git a/libgo/go/cmd/go/internal/work/init.go b/libgo/go/cmd/go/internal/work/init.go
index c2beb3be6e7..de0cd4282b3 100644
--- a/libgo/go/cmd/go/internal/work/init.go
+++ b/libgo/go/cmd/go/internal/work/init.go
@@ -9,13 +9,16 @@ package work
import (
"cmd/go/internal/base"
"cmd/go/internal/cfg"
+ "cmd/go/internal/load"
"flag"
"fmt"
"os"
"path/filepath"
+ "strings"
)
func BuildInit() {
+ load.ModInit()
instrumentInit()
buildModeInit()
@@ -39,15 +42,20 @@ func instrumentInit() {
fmt.Fprintf(os.Stderr, "go %s: may not use -race and -msan simultaneously\n", flag.Args()[0])
os.Exit(2)
}
- if cfg.BuildMSan && (cfg.Goos != "linux" || cfg.Goarch != "amd64") {
+ if cfg.BuildMSan && (cfg.Goos != "linux" || cfg.Goarch != "amd64" && cfg.Goarch != "arm64") {
fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
os.Exit(2)
}
- if cfg.Goarch != "amd64" || cfg.Goos != "linux" && cfg.Goos != "freebsd" && cfg.Goos != "darwin" && cfg.Goos != "windows" {
- fmt.Fprintf(os.Stderr, "go %s: -race and -msan are only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
- os.Exit(2)
+ if cfg.BuildRace {
+ platform := cfg.Goos + "/" + cfg.Goarch
+ switch platform {
+ default:
+ fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
+ os.Exit(2)
+ case "linux/amd64", "linux/ppc64le", "freebsd/amd64", "netbsd/amd64", "darwin/amd64", "windows/amd64":
+ // race supported on these platforms
+ }
}
-
mode := "race"
if cfg.BuildMSan {
mode = "msan"
@@ -83,6 +91,9 @@ func buildModeInit() {
default:
switch cfg.Goos {
case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
+ if platform == "linux/ppc64" {
+ base.Fatalf("-buildmode=c-archive not supported on %s\n", platform)
+ }
// Use -shared so that the result is
// suitable for inclusion in a PIE or
// shared library.
@@ -101,7 +112,8 @@ func buildModeInit() {
} else {
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/ppc64le", "linux/s390x",
- "android/amd64", "android/arm", "android/arm64", "android/386":
+ "android/amd64", "android/arm", "android/arm64", "android/386",
+ "freebsd/amd64":
codegenArg = "-shared"
case "darwin/amd64", "darwin/386":
case "windows/amd64", "windows/386":
@@ -144,7 +156,8 @@ func buildModeInit() {
} else {
switch platform {
case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",
- "android/amd64", "android/arm", "android/arm64", "android/386":
+ "android/amd64", "android/arm", "android/arm64", "android/386",
+ "freebsd/amd64":
codegenArg = "-shared"
case "darwin/amd64":
codegenArg = "-shared"
@@ -220,4 +233,31 @@ func buildModeInit() {
cfg.BuildContext.InstallSuffix += codegenArg[1:]
}
}
+
+ switch cfg.BuildMod {
+ case "":
+ // ok
+ case "readonly", "vendor":
+ if load.ModLookup == nil && !inGOFLAGS("-mod") {
+ base.Fatalf("build flag -mod=%s only valid when using modules", cfg.BuildMod)
+ }
+ default:
+ base.Fatalf("-mod=%s not supported (can be '', 'readonly', or 'vendor')", cfg.BuildMod)
+ }
+}
+
+func inGOFLAGS(flag string) bool {
+ for _, goflag := range base.GOFLAGS() {
+ name := goflag
+ if strings.HasPrefix(name, "--") {
+ name = name[1:]
+ }
+ if i := strings.Index(name, "="); i >= 0 {
+ name = name[:i]
+ }
+ if name == flag {
+ return true
+ }
+ }
+ return false
}