The new "unix" build tag matches any Unix or Unix-like system.
This is only recognized on go:build lines, not in file names.
For #20322
Fixes #51572
Change-Id: I3a991f9e69353b25e259bc6462709cdcd83640fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/389934
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
return pathf("%s/pkg/%s_%s/%s.a", goroot, goos, goarch, pkg)
}
+// unixOS is the set of GOOS values matched by the "unix" build tag.
+// This is the same list as in go/build/syslist.go.
+var unixOS = map[string]bool{
+ "aix": true,
+ "android": true,
+ "darwin": true,
+ "dragonfly": true,
+ "freebsd": true,
+ "hurd": true,
+ "illumos": true,
+ "ios": true,
+ "linux": true,
+ "netbsd": true,
+ "openbsd": true,
+ "solaris": true,
+}
+
// matchtag reports whether the tag matches this build.
func matchtag(tag string) bool {
- return tag == "gc" || tag == goos || tag == goarch || tag == "cmd_go_bootstrap" || tag == "go1.1" ||
- (goos == "android" && tag == "linux") ||
- (goos == "illumos" && tag == "solaris") ||
- (goos == "ios" && tag == "darwin")
+ switch tag {
+ case "gc", "cmd_go_bootstrap", "go1.1":
+ return true
+ case "linux":
+ return goos == "linux" || goos == "android"
+ case "solaris":
+ return goos == "solaris" || goos == "illumos"
+ case "darwin":
+ return goos == "darwin" || goos == "ios"
+ case goos, goarch:
+ return true
+ case "unix":
+ return unixOS[goos]
+ default:
+ return false
+ }
}
// shouldbuild reports whether we should build this file.
// GOOS environment variable.
// - the target architecture, as spelled by runtime.GOARCH, set with the
// GOARCH environment variable.
+// - "unix", if GOOS is a Unix or Unix-like system.
// - the compiler being used, either "gc" or "gccgo"
// - "cgo", if the cgo command is supported (see CGO_ENABLED in
// 'go help environment').
GOOS environment variable.
- the target architecture, as spelled by runtime.GOARCH, set with the
GOARCH environment variable.
+ - "unix", if GOOS is a Unix or Unix-like system.
- the compiler being used, either "gc" or "gccgo"
- "cgo", if the cgo command is supported (see CGO_ENABLED in
'go help environment').
if ctxt.GOOS == "ios" && name == "darwin" {
return true
}
+ if name == "unix" && unixOS[ctxt.GOOS] {
+ return true
+ }
// other tags
for _, tag := range ctxt.BuildTags {
package build
-// Past, present, and future known GOOS and GOARCH values.
-// Do not remove from this list, as these are used for go/build filename matching.
-
+// knownOS is the list of past, present, and future known GOOS values.
+// Do not remove from this list, as it is used for filename matching.
+// If you add an entry to this list, look at unixOS, below.
var knownOS = map[string]bool{
"aix": true,
"android": true,
"windows": true,
"zos": true,
}
+
+// unixOS is the set of GOOS values matched by the "unix" build tag.
+// This is not used for filename matching.
+// This list also appears in cmd/dist/build.go.
+var unixOS = map[string]bool{
+ "aix": true,
+ "android": true,
+ "darwin": true,
+ "dragonfly": true,
+ "freebsd": true,
+ "hurd": true,
+ "illumos": true,
+ "ios": true,
+ "linux": true,
+ "netbsd": true,
+ "openbsd": true,
+ "solaris": true,
+}
+
+// knownArch is the list of past, present, and future known GOARCH values.
+// Do not remove from this list, as it is used for filename matching.
var knownArch = map[string]bool{
"386": true,
"amd64": true,