golang.org/x/build@v0.0.0-20240506185731-218518f32b70/dashboard/builders.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package dashboard contains shared configuration and logic used by various
     6  // pieces of the Go continuous build system.
     7  package dashboard
     8  
     9  import (
    10  	"fmt"
    11  	"os"
    12  	"sort"
    13  	"strconv"
    14  	"strings"
    15  	"time"
    16  
    17  	"golang.org/x/build/buildenv"
    18  	"golang.org/x/build/internal/gophers"
    19  	"golang.org/x/build/maintner/maintnerd/maintapi/version"
    20  	"golang.org/x/build/types"
    21  )
    22  
    23  // slowBotAliases maps short names from TRY= comments to which builder to run.
    24  //
    25  // TODO: we'll likely expand this, or move it, or change the matching
    26  // syntax entirely. This is a first draft.
    27  var slowBotAliases = map[string]string{
    28  	// Known missing builders:
    29  	"ios-amd64": "", // There is no builder for the iOS Simulator. See issues 42100 and 42177.
    30  
    31  	// Fully ported to LUCI and stopped in the coordinator.
    32  	"js":                    "",
    33  	"wasip1":                "",
    34  	"wasm":                  "",
    35  	"js-wasm":               "",
    36  	"wasip1-wasm":           "",
    37  	"ppc64":                 "",
    38  	"ppc64p10":              "",
    39  	"ppc64le":               "",
    40  	"ppc64lep9":             "",
    41  	"ppc64lep10":            "",
    42  	"linux-ppc64":           "",
    43  	"linux-ppc64-power10":   "",
    44  	"linux-ppc64le":         "",
    45  	"linux-ppc64le-power9":  "",
    46  	"linux-ppc64le-power10": "",
    47  
    48  	"386":             "linux-386",
    49  	"aix":             "aix-ppc64",
    50  	"amd64":           "linux-amd64",
    51  	"android":         "android-amd64-emu",
    52  	"android-386":     "android-386-emu",
    53  	"android-amd64":   "android-amd64-emu",
    54  	"android-arm":     "android-arm-corellium",
    55  	"android-arm64":   "android-arm64-corellium",
    56  	"arm":             "linux-arm-aws",
    57  	"arm64":           "linux-arm64",
    58  	"boringcrypto":    "linux-amd64-boringcrypto",
    59  	"darwin":          "darwin-amd64-13",
    60  	"darwin-amd64":    "darwin-amd64-13",
    61  	"darwin-arm64":    "darwin-arm64-12",
    62  	"ios-arm64":       "ios-arm64-corellium",
    63  	"dragonfly":       "dragonfly-amd64-622",
    64  	"dragonfly-amd64": "dragonfly-amd64-622",
    65  	"freebsd":         "freebsd-amd64-13_0",
    66  	"freebsd-386":     "freebsd-386-13_0",
    67  	"freebsd-amd64":   "freebsd-amd64-13_0",
    68  	"freebsd-arm":     "freebsd-arm-paulzhol",
    69  	"freebsd-arm64":   "freebsd-arm64-dmgk",
    70  	"freebsd-riscv64": "freebsd-riscv64-unmatched",
    71  	"illumos":         "illumos-amd64",
    72  	"ios":             "ios-arm64-corellium",
    73  	"linux":           "linux-amd64",
    74  	"linux-arm":       "linux-arm-aws",
    75  	"linux-loong64":   "linux-loong64-3a5000",
    76  	"linux-mips":      "linux-mips-rtrk",
    77  	"linux-mips64":    "linux-mips64-rtrk",
    78  	"linux-mips64le":  "linux-mips64le-rtrk",
    79  	"linux-mipsle":    "linux-mipsle-rtrk",
    80  	"linux-riscv64":   "linux-riscv64-unmatched",
    81  	"linux-s390x":     "linux-s390x-ibm",
    82  	"longtest":        "linux-amd64-longtest",
    83  	"loong64":         "linux-loong64-3a5000",
    84  	"mips":            "linux-mips-rtrk",
    85  	"mips64":          "linux-mips64-rtrk",
    86  	"mips64le":        "linux-mips64le-rtrk",
    87  	"mipsle":          "linux-mipsle-rtrk",
    88  	"netbsd":          "netbsd-amd64-9_3",
    89  	"netbsd-386":      "netbsd-386-9_3",
    90  	"netbsd-amd64":    "netbsd-amd64-9_3",
    91  	"netbsd-arm":      "netbsd-arm-bsiegert",
    92  	"netbsd-arm64":    "netbsd-arm64-bsiegert",
    93  	"nocgo":           "linux-amd64-nocgo",
    94  	"openbsd":         "openbsd-amd64-72",
    95  	"openbsd-386":     "openbsd-386-72",
    96  	"openbsd-amd64":   "openbsd-amd64-72",
    97  	"openbsd-arm":     "openbsd-arm-jsing",
    98  	"openbsd-arm64":   "openbsd-arm64-jsing",
    99  	"openbsd-mips64":  "openbsd-mips64-jsing",
   100  	"openbsd-ppc64":   "openbsd-ppc64-n2vi",
   101  	"openbsd-riscv64": "openbsd-riscv64-jsing",
   102  	"plan9":           "plan9-arm",
   103  	"plan9-386":       "plan9-386-0intro",
   104  	"plan9-amd64":     "plan9-amd64-0intro",
   105  	"riscv64":         "linux-riscv64-unmatched",
   106  	"s390x":           "linux-s390x-ibm",
   107  	"solaris":         "solaris-amd64-oraclerel",
   108  	"solaris-amd64":   "solaris-amd64-oraclerel",
   109  	"windows":         "windows-amd64-2016",
   110  	"windows-386":     "windows-386-2016",
   111  	"windows-amd64":   "windows-amd64-2016",
   112  	"windows-arm":     "windows-arm-zx2c4",
   113  	"windows-arm64":   "windows-arm64-11",
   114  }
   115  
   116  // Builders are the different build configurations.
   117  // The keys are like "darwin-amd64" or "linux-386-387".
   118  // This map should not be modified by other packages.
   119  // Initialization happens below, via calls to addBuilder.
   120  var Builders = map[string]*BuildConfig{}
   121  
   122  // GoBootstrap is the bootstrap Go version.
   123  //
   124  // For bootstrap versions prior to Go 1.21.0,
   125  // bootstrap Go builds with this name must be in the buildlet bucket,
   126  // usually uploaded by 'genbootstrap -upload all'.
   127  const GoBootstrap = "go1.20.6"
   128  
   129  // Hosts contains the names and configs of all the types of
   130  // buildlets. They can be VMs, containers, or dedicated machines.
   131  //
   132  // Please keep table sorted by map key.
   133  var Hosts = map[string]*HostConfig{
   134  	"host-aix-ppc64-osuosl": {
   135  		Notes:     "AIX 7.2 VM on OSU; run by Tony Reix",
   136  		Owners:    []*gophers.Person{gh("trex58")},
   137  		IsReverse: true,
   138  		ExpectNum: 1,
   139  	},
   140  	"host-android-arm64-corellium-android": {
   141  		Notes:       "Virtual Android devices hosted by Zenly on Corellium; see issues 31722 and 40523",
   142  		Owners:      []*gophers.Person{gh("steeve"), gh("changkun")}, // See https://groups.google.com/g/golang-dev/c/oiuIE7qrWp0.
   143  		IsReverse:   true,
   144  		ExpectNum:   3,
   145  		GoBootstrap: "none", // image has Go 1.15.3 (go.dev/issue/54246); cannot access storage.googleapis.com
   146  		env: []string{
   147  			"GOROOT_BOOTSTRAP=/data/data/com.termux/files/home/go-android-arm64-bootstrap",
   148  			// Only run one job at a time to avoid the OOM killer.
   149  			// Issue 50084.
   150  			"GOMAXPROCS=1",
   151  		},
   152  	},
   153  	"host-darwin-amd64-10_15-aws": {
   154  		IsReverse:       true,
   155  		ExpectNum:       2,
   156  		Notes:           "AWS macOS Catalina (10.15) VM under QEMU",
   157  		SSHUsername:     "gopher",
   158  		HermeticReverse: true, // we destroy the VM when done & recreate
   159  		GoogleReverse:   true,
   160  	},
   161  	"host-darwin-amd64-11-aws": {
   162  		IsReverse:       true,
   163  		ExpectNum:       2,
   164  		Notes:           "AWS macOS Big Sur (11) VM under QEMU",
   165  		SSHUsername:     "gopher",
   166  		HermeticReverse: true, // we destroy the VM when done & recreate
   167  		GoogleReverse:   true,
   168  	},
   169  	"host-darwin-amd64-12-aws": {
   170  		IsReverse:       true,
   171  		ExpectNum:       6,
   172  		Notes:           "AWS macOS Monterey (12) VM under QEMU",
   173  		SSHUsername:     "gopher",
   174  		HermeticReverse: true, // we destroy the VM when done & recreate
   175  		GoogleReverse:   true,
   176  	},
   177  	"host-darwin-amd64-13-aws": {
   178  		IsReverse:       true,
   179  		ExpectNum:       2,
   180  		Notes:           "AWS macOS Ventura (13) VM under QEMU",
   181  		SSHUsername:     "gopher",
   182  		HermeticReverse: true, // we destroy the VM when done & recreate
   183  		GoogleReverse:   true,
   184  	},
   185  	"host-darwin-arm64-11": {
   186  		IsReverse:     true,
   187  		Notes:         "macOS Big Sur (11) ARM64 (M1) on Mac minis in a Google office",
   188  		ExpectNum:     3,
   189  		SSHUsername:   "gopher",
   190  		GoogleReverse: true,
   191  	},
   192  	"host-darwin-arm64-12": {
   193  		IsReverse:     true,
   194  		ExpectNum:     3,
   195  		Notes:         "macOS Monterey (12) ARM64 (M1) on Mac minis in a Google office",
   196  		SSHUsername:   "gopher",
   197  		GoogleReverse: true,
   198  	},
   199  	"host-dragonfly-amd64-622": {
   200  		Notes:       "DragonFly BSD 6.2.2 on GCE, built from build/env/dragonfly-amd64",
   201  		VMImage:     "dragonfly-amd64-622",
   202  		SSHUsername: "root",
   203  	},
   204  	"host-freebsd-amd64-12_3": {
   205  		VMImage:     "freebsd-amd64-123-stable-20211230",
   206  		Notes:       "FreeBSD 12.3; GCE VM, built from build/env/freebsd-amd64",
   207  		SSHUsername: "gopher",
   208  	},
   209  	"host-freebsd-amd64-13_0": {
   210  		VMImage:     "freebsd-amd64-130-stable-20211230",
   211  		Notes:       "FreeBSD 13.0; GCE VM, built from build/env/freebsd-amd64",
   212  		SSHUsername: "gopher",
   213  	},
   214  	"host-freebsd-arm-paulzhol": {
   215  		IsReverse: true,
   216  		ExpectNum: 1,
   217  		Notes:     "Raspberry Pi 3 Model B, FreeBSD 13.1-RELEASE with SCHED_4BSD",
   218  		Owners:    []*gophers.Person{gh("paulzhol")},
   219  	},
   220  	"host-freebsd-arm64-dmgk": {
   221  		IsReverse: true,
   222  		ExpectNum: 1,
   223  		Notes:     "AWS EC2 a1.large 2 vCPU 4GiB RAM, FreeBSD 12.1-STABLE",
   224  		Owners:    []*gophers.Person{gh("dmgk")},
   225  	},
   226  	"host-freebsd-riscv64-unmatched": {
   227  		IsReverse:   true,
   228  		ExpectNum:   1,
   229  		Notes:       "SiFive HiFive Unmatched RISC-V board. 16 GB RAM. FreeBSD 13.1-RELEASE",
   230  		Owners:      []*gophers.Person{gh("mengzhuo")},
   231  		GoBootstrap: "none",
   232  		env: []string{
   233  			"GOROOT_BOOTSTRAP=/home/gopher/go-freebsd-riscv64-bootstrap",
   234  		},
   235  	},
   236  	"host-illumos-amd64-jclulow": {
   237  		Notes:       "SmartOS base64@19.1.0 zone",
   238  		Owners:      []*gophers.Person{gh("jclulow")},
   239  		IsReverse:   true,
   240  		ExpectNum:   1,
   241  		SSHUsername: "gobuild",
   242  	},
   243  	"host-ios-arm64-corellium-ios": {
   244  		Notes:       "Virtual iOS devices hosted by Zenly on Corellium; see issues 31722 and 40523",
   245  		Owners:      []*gophers.Person{gh("steeve"), gh("changkun")}, // See https://groups.google.com/g/golang-dev/c/oiuIE7qrWp0.
   246  		IsReverse:   true,
   247  		ExpectNum:   3,
   248  		GoBootstrap: "none", // image has devel d6c4583ad4 (pre-Go 1.18) Dec 2021 (go.dev/issue/54246); cannot access storage.googleapis.com
   249  		env: []string{
   250  			"GOROOT_BOOTSTRAP=/var/root/go-ios-arm64-bootstrap",
   251  		},
   252  	},
   253  	"host-linux-amd64-alpine": {
   254  		Notes:          "Alpine container",
   255  		ContainerImage: "linux-x86-alpine:latest",
   256  		SSHUsername:    "root",
   257  	},
   258  	"host-linux-amd64-androidemu": {
   259  		Notes:          "Debian Bullseye w/ Android SDK + emulator (use nested virt)",
   260  		ContainerImage: "android-amd64-emu:bff27c0c9263",
   261  		KonletVMImage:  "android-amd64-emu-bullseye",
   262  		NestedVirt:     true,
   263  		SSHUsername:    "root",
   264  	},
   265  	"host-linux-amd64-bookworm": {
   266  		Notes:          "Debian Bookworm",
   267  		ContainerImage: "linux-x86-bookworm:latest",
   268  		SSHUsername:    "root",
   269  	},
   270  	"host-linux-amd64-bullseye": {
   271  		Notes:          "Debian Bullseye",
   272  		ContainerImage: "linux-x86-bullseye:latest",
   273  		SSHUsername:    "root",
   274  	},
   275  	"host-linux-amd64-bullseye-vmx": {
   276  		Notes:          "Debian Bullseye w/ Nested Virtualization (VMX CPU bit) enabled",
   277  		ContainerImage: "linux-x86-bullseye:latest",
   278  		NestedVirt:     true,
   279  		SSHUsername:    "root",
   280  	},
   281  	"host-linux-amd64-buster": {
   282  		Notes:          "Debian Buster",
   283  		ContainerImage: "linux-x86-buster:latest",
   284  		SSHUsername:    "root",
   285  	},
   286  	"host-linux-amd64-clang": {
   287  		Notes:          "Container with clang.",
   288  		ContainerImage: "linux-x86-clang:latest",
   289  		SSHUsername:    "root",
   290  	},
   291  	"host-linux-amd64-fedora": {
   292  		Notes:          "Fedora 30",
   293  		ContainerImage: "linux-x86-fedora:latest",
   294  		SSHUsername:    "root",
   295  	},
   296  	"host-linux-amd64-js-wasm-node18": {
   297  		Notes:          "Container with Node.js 18 for testing js/wasm.",
   298  		ContainerImage: "js-wasm-node18:latest",
   299  		SSHUsername:    "root",
   300  	},
   301  	"host-linux-amd64-localdev": {
   302  		IsReverse:   true,
   303  		ExpectNum:   0,
   304  		Notes:       "for localhost development of buildlets/gomote/coordinator only",
   305  		SSHUsername: os.Getenv("USER"),
   306  	},
   307  	"host-linux-amd64-perf": {
   308  		Notes:               "Cascade Lake performance testing machines",
   309  		machineType:         "c2-standard-8", // C2 has precisely defined, consistent server architecture.
   310  		ContainerImage:      "linux-x86-bullseye:latest",
   311  		SSHUsername:         "root",
   312  		CustomDeleteTimeout: 12 * time.Hour,
   313  	},
   314  	"host-linux-amd64-s390x-cross": {
   315  		Notes:          "Container with s390x cross-compiler.",
   316  		ContainerImage: "linux-s390x-cross:latest",
   317  	},
   318  	"host-linux-amd64-sid": {
   319  		Notes:          "Debian sid, updated occasionally.",
   320  		ContainerImage: "linux-x86-sid:latest",
   321  		SSHUsername:    "root",
   322  	},
   323  	"host-linux-amd64-wasip1-wasm-wasmedge": {
   324  		Notes:          "Container with wasmedge for testing wasip1/wasm.",
   325  		ContainerImage: "wasip1-wasm-wasmedge:latest",
   326  		SSHUsername:    "root",
   327  	},
   328  	"host-linux-amd64-wasip1-wasm-wasmer": {
   329  		Notes:          "Container with wasmer for testing wasip1/wasm.",
   330  		ContainerImage: "wasip1-wasm-wasmer:latest",
   331  		SSHUsername:    "root",
   332  	},
   333  	"host-linux-amd64-wasip1-wasm-wasmtime": {
   334  		Notes:          "Container with wasmtime for testing wasip1/wasm.",
   335  		ContainerImage: "wasip1-wasm-wasmtime:latest",
   336  		SSHUsername:    "root",
   337  	},
   338  	"host-linux-amd64-wasip1-wasm-wazero": {
   339  		Notes:          "Container with Wazero for testing wasip1/wasm.",
   340  		ContainerImage: "wasip1-wasm-wazero:latest",
   341  		SSHUsername:    "root",
   342  	},
   343  	"host-linux-amd64-wsl": {
   344  		Notes:     "Windows 10 WSL2 Ubuntu",
   345  		Owners:    []*gophers.Person{gh("mengzhuo")},
   346  		IsReverse: true,
   347  		ExpectNum: 2,
   348  	},
   349  	"host-linux-arm-aws": {
   350  		Notes:          "Debian Buster, EC2 arm instance. See x/build/env/linux-arm/aws",
   351  		VMImage:        "ami-07409163bccd5ac4d",
   352  		ContainerImage: "gobuilder-arm-aws:latest",
   353  		machineType:    "m6g.xlarge",
   354  		IsEC2:          true,
   355  		SSHUsername:    "root",
   356  	},
   357  	"host-linux-arm64-bullseye": {
   358  		Notes:           "Debian Bullseye",
   359  		ContainerImage:  "linux-arm64-bullseye:latest",
   360  		machineType:     "t2a",
   361  		SSHUsername:     "root",
   362  		cosArchitecture: CosArchARM64,
   363  	},
   364  	"host-linux-arm64-bullseye-high-disk": {
   365  		Notes:           "Debian Bullseye, larger boot disk size",
   366  		ContainerImage:  "linux-arm64-bullseye:latest",
   367  		machineType:     "t2a",
   368  		SSHUsername:     "root",
   369  		cosArchitecture: CosArchARM64,
   370  		RootDriveSizeGB: 20,
   371  	},
   372  	"host-linux-loong64-3a5000": {
   373  		Notes:       "Loongson 3A5000 Box hosted by Loongson; loong64 is the short name of LoongArch 64 bit version",
   374  		Owners:      []*gophers.Person{gh("XiaodongLoong"), gh("abner-chenc")},
   375  		IsReverse:   true,
   376  		ExpectNum:   5,
   377  		GoBootstrap: "none",
   378  		env: []string{
   379  			"GOROOT_BOOTSTRAP=/usr/lib/go-linux-loong64-bootstrap",
   380  		},
   381  	},
   382  	"host-linux-mips64-rtrk": {
   383  		Notes:     "cavium,rhino_utm8 board hosted at RT-RK.com; quad-core cpu, 8GB of ram and 240GB ssd disks.",
   384  		Owners:    []*gophers.Person{gh("draganmladjenovic")}, // See https://github.com/golang/go/issues/53574#issuecomment-1169891255.
   385  		IsReverse: true,
   386  		ExpectNum: 1,
   387  	},
   388  	"host-linux-mips64le-rtrk": {
   389  		Notes:     "cavium,rhino_utm8 board hosted at RT-RK.com; quad-core cpu, 8GB of ram and 240GB ssd disks.",
   390  		Owners:    []*gophers.Person{gh("draganmladjenovic")}, // See https://github.com/golang/go/issues/53574#issuecomment-1169891255.
   391  		IsReverse: true,
   392  		ExpectNum: 1,
   393  	},
   394  	"host-linux-ppc64-sid": {
   395  		Notes:           "Debian sid; run by Go team on osuosl.org",
   396  		Owners:          []*gophers.Person{gh("pmur")},
   397  		IsReverse:       true,
   398  		ExpectNum:       5,
   399  		SSHUsername:     "root",
   400  		HermeticReverse: true,
   401  	},
   402  	"host-linux-ppc64-sid-power10": {
   403  		Notes:           "debian sid; run by Go team on osuosl.org; see x/build/env/linux-ppc64le/osuosl",
   404  		Owners:          []*gophers.Person{gh("pmur")},
   405  		IsReverse:       true,
   406  		env:             []string{"GOPPC64=power10"},
   407  		ExpectNum:       5,
   408  		SSHUsername:     "root",
   409  		HermeticReverse: true,
   410  	},
   411  	"host-linux-ppc64le-osu": {
   412  		Notes:           "Ubuntu 20.04; run by Go team on osuosl.org; see x/build/env/linux-ppc64le/osuosl",
   413  		Owners:          []*gophers.Person{gh("pmur")},
   414  		IsReverse:       true,
   415  		ExpectNum:       5,
   416  		SSHUsername:     "root",
   417  		HermeticReverse: true,
   418  	},
   419  	"host-linux-ppc64le-power10-osu": {
   420  		Notes:           "Ubuntu 22.04; run by Go team on osuosl.org; see x/build/env/linux-ppc64le/osuosl",
   421  		Owners:          []*gophers.Person{gh("pmur")},
   422  		IsReverse:       true,
   423  		env:             []string{"GOPPC64=power10"},
   424  		SSHUsername:     "root",
   425  		HermeticReverse: true,
   426  	},
   427  	"host-linux-ppc64le-power9-osu": {
   428  		Notes:           "Ubuntu 20.04; run by Go team on osuosl.org; see x/build/env/linux-ppc64le/osuosl",
   429  		Owners:          []*gophers.Person{gh("pmur")},
   430  		IsReverse:       true,
   431  		env:             []string{"GOPPC64=power9"},
   432  		SSHUsername:     "root",
   433  		HermeticReverse: true,
   434  	},
   435  	"host-linux-riscv64-joelsing": {
   436  		Notes:     "SiFive HiFive Unleashed RISC-V board. 8 GB RAM, 4 cores.",
   437  		IsReverse: true,
   438  		ExpectNum: 1,
   439  		Owners:    []*gophers.Person{gh("4a6f656c")},
   440  	},
   441  	"host-linux-riscv64-unmatched": {
   442  		Notes:     "SiFive HiFive Unmatched RISC-V board. 16 GB RAM, 4 cores.",
   443  		IsReverse: true,
   444  		ExpectNum: 2,
   445  		Owners:    []*gophers.Person{gh("mengzhuo")},
   446  
   447  		// Use go1.20.7 (slightly newer than the default go1.20.6 on 2023-08-18)
   448  		// for https://go.dev/issue/62104#issuecomment-1683207172.
   449  		GoBootstrap: "go1.20.7",
   450  	},
   451  	"host-linux-s390x": {
   452  		Notes:     "run by IBM",
   453  		Owners:    []*gophers.Person{gh("Vishwanatha-HD"), gh("srinivas-pokala")},
   454  		IsReverse: true,
   455  		ExpectNum: 2, // See https://github.com/golang/go/issues/49557#issuecomment-969148789.
   456  	},
   457  	"host-netbsd-386-9_3": {
   458  		VMImage:     "netbsd-i386-9-3-202211120320",
   459  		Notes:       "NetBSD 9.3; GCE VM is built from script in build/env/netbsd-386",
   460  		machineType: "n2", // force Intel; see go.dev/issue/49209
   461  		SSHUsername: "root",
   462  	},
   463  	"host-netbsd-amd64-9_3": {
   464  		VMImage:     "netbsd-amd64-9-3-202211120320v2",
   465  		Notes:       "NetBSD 9.3; GCE VM is built from script in build/env/netbsd-amd64",
   466  		machineType: "n2", // force Intel; see go.dev/issue/49209
   467  		SSHUsername: "root",
   468  	},
   469  	"host-netbsd-arm-bsiegert": {
   470  		IsReverse: true,
   471  		ExpectNum: 1,
   472  		Owners:    []*gophers.Person{gh("bsiegert")},
   473  	},
   474  	"host-netbsd-arm64-bsiegert": {
   475  		IsReverse: true,
   476  		ExpectNum: 1,
   477  		Owners:    []*gophers.Person{gh("bsiegert")},
   478  	},
   479  	"host-openbsd-386-72": {
   480  		VMImage:     "openbsd-386-72",
   481  		machineType: "n2", // force Intel; see go.dev/issue/49209
   482  		Notes:       "OpenBSD 7.2; GCE VM, built from build/env/openbsd-386",
   483  		SSHUsername: "gopher",
   484  	},
   485  	"host-openbsd-amd64-72": {
   486  		VMImage:     "openbsd-amd64-72",
   487  		machineType: "n2", // force Intel; see go.dev/issue/49209
   488  		Notes:       "OpenBSD 7.2; GCE VM, built from build/env/openbsd-amd64",
   489  		SSHUsername: "gopher",
   490  	},
   491  	"host-openbsd-arm-joelsing": {
   492  		IsReverse: true,
   493  		ExpectNum: 1,
   494  		Owners:    []*gophers.Person{gh("4a6f656c")},
   495  	},
   496  	"host-openbsd-arm64-joelsing": {
   497  		IsReverse: true,
   498  		ExpectNum: 1,
   499  		Owners:    []*gophers.Person{gh("4a6f656c")},
   500  	},
   501  	"host-openbsd-mips64-joelsing": {
   502  		IsReverse: true,
   503  		ExpectNum: 1,
   504  		Owners:    []*gophers.Person{gh("4a6f656c")},
   505  	},
   506  	"host-openbsd-ppc64-n2vi": {
   507  		IsReverse:   true,
   508  		ExpectNum:   1,
   509  		Owners:      []*gophers.Person{gh("n2vi")},
   510  		Notes:       "TalosII T2P9D01 (dual Power9 32GB) OpenBSD-current",
   511  		GoBootstrap: "none",
   512  		env: []string{
   513  			"GOROOT_BOOTSTRAP=/home/gopher/go-openbsd-ppc64-bootstrap",
   514  		},
   515  	},
   516  	"host-openbsd-riscv64-joelsing": {
   517  		IsReverse:   true,
   518  		ExpectNum:   1,
   519  		Owners:      []*gophers.Person{gh("4a6f656c")},
   520  		GoBootstrap: "none",
   521  		env: []string{
   522  			"GOROOT_BOOTSTRAP=/home/gopher/go-openbsd-riscv64-bootstrap",
   523  		},
   524  	},
   525  	"host-plan9-386-0intro": {
   526  		IsReverse: true,
   527  		ExpectNum: 1,
   528  		Notes:     "QEMU VM, Plan 9 from Bell Labs",
   529  		Owners:    []*gophers.Person{gh("0intro")},
   530  	},
   531  	"host-plan9-386-gce": {
   532  		VMImage: "plan9-386-v7",
   533  		Notes:   "Plan 9 from 0intro; GCE VM, built from build/env/plan9-386",
   534  		env:     []string{"GO_TEST_TIMEOUT_SCALE=3"},
   535  	},
   536  	"host-plan9-amd64-0intro": {
   537  		IsReverse: true,
   538  		ExpectNum: 1,
   539  		Notes:     "QEMU VM, Plan 9 from Bell Labs, 9k kernel",
   540  		Owners:    []*gophers.Person{gh("0intro")},
   541  	},
   542  	"host-plan9-arm-0intro": {
   543  		IsReverse: true,
   544  		ExpectNum: 1,
   545  		Notes:     "Raspberry Pi 3 Model B, Plan 9 from Bell Labs",
   546  		Owners:    []*gophers.Person{gh("0intro")},
   547  	},
   548  	"host-solaris-oracle-amd64-oraclerel": {
   549  		Notes:     "Oracle Solaris amd64 Release System",
   550  		HostArch:  "solaris-amd64",
   551  		Owners:    []*gophers.Person{gh("rorth")}, // https://github.com/golang/go/issues/15581#issuecomment-550368581
   552  		IsReverse: true,
   553  		ExpectNum: 1,
   554  	},
   555  	"host-windows-amd64-2016": {
   556  		VMImage:     "windows-amd64-server-2016-v9",
   557  		SSHUsername: "gopher",
   558  	},
   559  	"host-windows-amd64-2016-big": {
   560  		VMImage:     "windows-amd64-server-2016-v9",
   561  		machineType: "e2-standard-16",
   562  		SSHUsername: "gopher",
   563  	},
   564  	"host-windows-arm64-zx2c4": {
   565  		IsReverse: true,
   566  		ExpectNum: 0,
   567  		Owners:    []*gophers.Person{gh("zx2c4")},
   568  	},
   569  	"host-windows11-arm64-azure": { // host name known to cmd/buildlet/stage0, cannot change
   570  		Notes:     "Azure windows 11 arm64 VMs",
   571  		HostArch:  "windows-arm64",
   572  		IsReverse: true,
   573  		ExpectNum: 2,
   574  	},
   575  }
   576  
   577  func gh(githubUsername string) *gophers.Person {
   578  	p := gophers.GetPerson("@" + githubUsername)
   579  	if p == nil {
   580  		panic("person with GitHub username " + githubUsername + " does not exist in the golang.org/x/build/internal/gophers package")
   581  	}
   582  	return p
   583  }
   584  
   585  func init() {
   586  	for key, c := range Hosts {
   587  		if key == "" {
   588  			panic("empty string key in Hosts")
   589  		}
   590  		if c.HostType == "" {
   591  			c.HostType = key
   592  		}
   593  		if c.HostType != key {
   594  			panic(fmt.Sprintf("HostType %q != key %q", c.HostType, key))
   595  		}
   596  		if c.HostArch == "" {
   597  			f := strings.Split(c.HostType, "-")
   598  			if len(f) < 3 {
   599  				panic(fmt.Sprintf("invalid HostType %q", c.HostType))
   600  			}
   601  			c.HostArch = f[1] + "-" + f[2] // "linux-amd64"
   602  			if f[2] == "arm" {
   603  				c.HostArch += "-7" // assume newer ARM
   604  			}
   605  		}
   606  		if c.GoBootstrap == "" {
   607  			c.GoBootstrap = GoBootstrap
   608  		}
   609  		nSet := 0
   610  		if c.VMImage != "" {
   611  			nSet++
   612  		}
   613  		if c.ContainerImage != "" && !c.IsEC2 {
   614  			nSet++
   615  		}
   616  		if c.IsReverse {
   617  			nSet++
   618  		}
   619  		if nSet != 1 {
   620  			panic(fmt.Sprintf("exactly one of VMImage, ContainerImage, IsReverse must be set for host %q; got %v", key, nSet))
   621  		}
   622  	}
   623  }
   624  
   625  // CosArch defines the different COS images types used.
   626  type CosArch string
   627  
   628  const (
   629  	// TODO(59418,59419): The kernel in COS release 105 likely breaks ASAN and MSAN for both
   630  	// gcc and clang. Pin to 101, the previous release.
   631  	CosArchAMD64 CosArch = "cos-101-lts"      // COS image for AMD64 architecture
   632  	CosArchARM64         = "cos-arm64-stable" // COS image for ARM64 architecture
   633  )
   634  
   635  // A HostConfig describes the available ways to obtain buildlets of
   636  // different types. Some host configs can serve multiple
   637  // builders. For example, a host config of "host-linux-amd64-bullseye" can
   638  // serve linux-amd64, linux-amd64-race, linux-386, linux-386-387, etc.
   639  type HostConfig struct {
   640  	// HostType is the unique name of this host config. It is also
   641  	// the key in the Hosts map.
   642  	HostType string
   643  
   644  	// HostArch is a string identifying the host architecture, to decide which binaries to run on it.
   645  	// If unset, it is derived in func init from the HostType
   646  	// (for example, host-linux-amd64-foo has HostArch "linux-amd64").
   647  	// For clarity, the HostArch for 32-bit arm always ends in -5 or -7
   648  	// to specify the GOARM value; implicit HostArch always use -7.
   649  	// (This specificity is necessary because there is no one value that
   650  	// works on all 32-bit ARM chips on non-Linux operating systems.)
   651  	//
   652  	// If set explicitly, HostArch should have the form "GOOS-GOARCH-suffix",
   653  	// where suffix is the GO$GOARCH setting (that is, GOARM for GOARCH=arm).
   654  	// For example "openbsd-arm-5" for GOOS=openbsd GOARCH=arm GOARM=5.
   655  	//
   656  	// (See the BuildletBinaryURL and GoBootstrapURL methods.)
   657  	HostArch string
   658  
   659  	// GoBootstrap is the version of Go to use for bootstrap.
   660  	// If unset, it is set in func init to GoBootstrap (the global constant).
   661  	//
   662  	// If GoBootstrap is set to "none", it means this buildlet is not given a new bootstrap
   663  	// toolchain for each build, typically because it cannot download from
   664  	// storage.googleapis.com.
   665  	//
   666  	// For bootstrap versions prior to Go 1.21.0,
   667  	// a bootstrap toolchain built with that version must be in the buildlet bucket,
   668  	// usually uploaded by 'genbootstrap -upload all'.
   669  	//
   670  	// (See the GoBootstrapURL method.)
   671  	GoBootstrap string
   672  
   673  	// Exactly 1 of these must be set (with the exception of EC2 instances).
   674  	// An EC2 instance may run a container inside a VM. In that case, a VMImage
   675  	// and ContainerImage will both be set.
   676  	VMImage        string // e.g. "openbsd-amd64-60"
   677  	ContainerImage string // e.g. "linux-buildlet-std:latest" (suffix after "gcr.io/<PROJ>/")
   678  	IsReverse      bool   // if true, only use the reverse buildlet pool
   679  
   680  	// GCE options, if VMImage != "" || ContainerImage != ""
   681  	machineType     string  // optional GCE instance type ("n2-standard-4") or instance class ("n2")
   682  	RegularDisk     bool    // if true, use spinning disk instead of SSD
   683  	MinCPUPlatform  string  // optional. e2 instances are not supported. see https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform.
   684  	cosArchitecture CosArch // optional. GCE instances which use COS need the architecture set. Default: CosArchAMD64
   685  
   686  	// EC2 options
   687  	IsEC2 bool // if true, the instance is configured to run on EC2
   688  
   689  	// GCE or EC2 options:
   690  	//
   691  	// CustomDeleteTimeout is an optional custom timeout after which the VM is forcibly destroyed and the build is retried.
   692  	// Zero duration defers decision to internal/coordinator/pool package, which is enough for longtest post-submit builds.
   693  	// (This is generally an internal implementation detail, currently left behind only for the -perf builder.)
   694  	CustomDeleteTimeout time.Duration
   695  
   696  	// Reverse options
   697  	ExpectNum       int  // expected number of reverse buildlets of this type
   698  	HermeticReverse bool // whether reverse buildlet has fresh env per conn
   699  	GoogleReverse   bool // whether this reverse builder is owned by Google
   700  
   701  	// Container image options, if ContainerImage != "":
   702  	NestedVirt    bool   // container requires VMX nested virtualization. e2 and n2d instances are not supported.
   703  	KonletVMImage string // optional VM image (containing konlet) to use instead of default
   704  
   705  	// Optional base env.
   706  	env []string
   707  
   708  	Owners []*gophers.Person // owners; empty means golang-dev
   709  	Notes  string            // notes for humans
   710  
   711  	SSHUsername string // username to ssh as, empty means not supported
   712  
   713  	RootDriveSizeGB int64 // optional, GCE instance root size in base-2 GB. Default: default size for instance type.
   714  }
   715  
   716  // CosArchitecture returns the COS architecture to use with the host. The default is CosArchAMD64.
   717  func (hc *HostConfig) CosArchitecture() CosArch {
   718  	if hc.cosArchitecture == CosArch("") {
   719  		return CosArchAMD64
   720  	}
   721  	return hc.cosArchitecture
   722  }
   723  
   724  // A BuildConfig describes how to run a builder.
   725  type BuildConfig struct {
   726  	// Name is the unique name of the builder, in the form of
   727  	// "GOOS-GOARCH" or "GOOS-GOARCH-suffix". For example,
   728  	// "darwin-386", "linux-386-387", "linux-amd64-race". Some
   729  	// suffixes are well-known and carry special meaning, such as
   730  	// "-race".
   731  	Name string
   732  
   733  	// HostType is the required key into the Hosts map, describing
   734  	// the type of host this build will run on.
   735  	// For example, "host-linux-amd64-bullseye".
   736  	HostType string
   737  
   738  	// KnownIssues is a slice of non-zero go.dev/issue/nnn numbers for a
   739  	// builder that may fail due to a known issue, such as because it is a new
   740  	// builder still in development/testing, or because the feature
   741  	// or port that it's meant to test hasn't been added yet, etc.
   742  	//
   743  	// A non-zero value here means that failures on this builder should not
   744  	// be considered a serious regression and don't need investigation beyond
   745  	// what is already in scope of the listed issues.
   746  	KnownIssues []int
   747  
   748  	Notes string // notes for humans
   749  
   750  	// tryBot optionally specifies a policy func for whether trybots are enabled.
   751  	// nil means off. Even if tryBot returns true, BuildConfig.buildsRepoAtAll must
   752  	// also return true. See the implementation of BuildConfig.BuildsRepoTryBot.
   753  	// The proj is "go", "net", etc. The branch is proj's branch.
   754  	// The goBranch is the same as branch for proj "go", else it's the go branch
   755  	// ("master, "release-branch.go1.12", etc).
   756  	tryBot  func(proj, branch, goBranch string) bool
   757  	tryOnly bool // only used for trybots, and not regular builds
   758  
   759  	// CompileOnly indicates that tests should only be compiled but not run.
   760  	// Note that this will not prevent the test binary from running for tests
   761  	// for the main Go repo, so this flag is insufficient for disabling
   762  	// tests in a cross-compiled setting. See #58297.
   763  	//
   764  	// For subrepo tests however, this flag is sufficient to ensure that test
   765  	// binaries will only be built, not executed.
   766  	CompileOnly bool
   767  
   768  	// FlakyNet indicates that network tests are flaky on this builder.
   769  	// The builder will try to run the tests anyway, but will ignore some of the
   770  	// failures.
   771  	FlakyNet bool
   772  
   773  	// buildsRepo optionally specifies whether this builder does
   774  	// builds (of any type) for the given repo ("go", "net", etc.)
   775  	// and its branch ("master", "release-branch.go1.12", "dev.link", etc.).
   776  	// goBranch is the branch of "go" to build against. If repo == "go",
   777  	// goBranch == branch.
   778  	//
   779  	// If nil, a default set of repos as reported by buildRepoByDefault
   780  	// is built. See buildsRepoAtAll method for details.
   781  	//
   782  	// To implement a minor change to the default policy, create a
   783  	// function that uses buildRepoByDefault. For example:
   784  	//
   785  	// 	buildsRepo: func(repo, branch, goBranch string) bool {
   786  	// 		b := buildRepoByDefault(repo)
   787  	// 		// ... modify b from the default value as needed ...
   788  	// 		return b
   789  	// 	}
   790  	//
   791  	buildsRepo func(repo, branch, goBranch string) bool
   792  
   793  	// RunBench enables benchmarking of the toolchain using x/benchmarks.
   794  	// This only applies when building x/benchmarks.
   795  	RunBench bool
   796  
   797  	// MinimumGoVersion optionally specifies the minimum Go version
   798  	// this builder is allowed to use. It can be useful for skipping
   799  	// builders that are too new and no longer support some supported
   800  	// Go versions. It doesn't need to be set for builders that support
   801  	// all supported Go versions.
   802  	//
   803  	// Note: This field currently has effect on trybot runs only.
   804  	//
   805  	// TODO: unexport this and make buildsRepoAtAll return false on too-old
   806  	// of repos. The callers in coordinator will need updating.
   807  	MinimumGoVersion types.MajorMinor
   808  
   809  	// SkipSnapshot, if true, means to not fetch a tarball
   810  	// snapshot of the world post-make.bash from the buildlet (and
   811  	// thus to not write it to Google Cloud Storage). This is
   812  	// incompatible with sharded tests, and should only be used
   813  	// for very slow builders or networks, unable to transfer
   814  	// the tarball in under ~5 minutes.
   815  	SkipSnapshot bool
   816  
   817  	// StopAfterMake causes the build to stop after the make
   818  	// script completes, returning its result as the result of the
   819  	// whole build. It does not run or compile any of the tests,
   820  	// nor does it write a snapshot of the world to cloud
   821  	// storage.
   822  	StopAfterMake bool
   823  
   824  	// privateGoProxy for builder has it's own Go proxy instead of
   825  	// proxy.golang.org, pre-set in GOPROXY on the builder.
   826  	privateGoProxy bool
   827  
   828  	// InstallRacePackages controls which packages to "go install
   829  	// -race <pkgs>" after running make.bash (or equivalent).  If
   830  	// the builder ends in "-race", the default if non-nil is just
   831  	// "std".
   832  	InstallRacePackages []string
   833  
   834  	// GoDeps is a list of of git sha1 commits that must be in the
   835  	// commit to be tested's history. If absent, this builder is
   836  	// not run for that commit.
   837  	GoDeps []string
   838  
   839  	// distTestAdjust optionally specifies a function that can
   840  	// adjust the cmd/dist test policy for this builder.
   841  	//
   842  	// The BuildConfig.ShouldRunDistTest method implements the
   843  	// default cmd/dist test policy, and then calls distTestAdjust
   844  	// to adjust that decision further, if distTestAdjust is not nil.
   845  	//
   846  	// The initial value of the run parameter is what the default
   847  	// policy said. The returned value from distTestAdjust is what
   848  	// BuildConfig.ShouldRunDistTest reports to the caller.
   849  	//
   850  	// For example:
   851  	//
   852  	// 	distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
   853  	// 		// ... modify run from the initial value as needed ...
   854  	// 		return run
   855  	// 	}
   856  	//
   857  	// distTestAdjust works with dist test names expressed in the Go 1.20 format.
   858  	// See ShouldRunDistTest for details.
   859  	//
   860  	distTestAdjust func(run bool, distTest string, isNormalTry bool) bool
   861  
   862  	// numTestHelpers is the number of _additional_ buildlets
   863  	// past the first one to help out with sharded tests.
   864  	// For TryBots and SlowBots, the numTryHelpers value is used,
   865  	// unless it's zero, in which case numTestHelpers is used.
   866  	numTestHelpers    int
   867  	numTryTestHelpers int // For TryBots/SlowBots. If 0, numTestHelpers is used.
   868  
   869  	env            []string // extra environment ("key=value") pairs
   870  	makeScriptArgs []string // extra args to pass to the make.bash-equivalent script
   871  	allScriptArgs  []string // extra args to pass to the all.bash-equivalent script
   872  
   873  	TestHostConf *HostConfig // override HostConfig for testing, at least for now
   874  
   875  	// isRestricted marks if a builder should be restricted to a subset of users.
   876  	isRestricted bool
   877  }
   878  
   879  // Env returns the environment variables this builder should run with.
   880  func (c *BuildConfig) Env() []string {
   881  	env := []string{"GO_BUILDER_NAME=" + c.Name}
   882  	if c.FlakyNet {
   883  		env = append(env, "GO_BUILDER_FLAKY_NET=1")
   884  	}
   885  	if c.IsLongTest() {
   886  		// Set a private hook in cmd/dist to run main Go repository tests
   887  		// without the default -short flag. See go.dev/issue/12508.
   888  		env = append(env, "GO_TEST_SHORT=0")
   889  	}
   890  	env = append(env, c.HostConfig().env...)
   891  	return append(env, c.env...)
   892  }
   893  
   894  func (c *BuildConfig) IsReverse() bool { return c.HostConfig().IsReverse }
   895  
   896  func (c *BuildConfig) IsGCE() bool { return !c.HostConfig().IsReverse && !c.HostConfig().IsEC2 }
   897  
   898  func (c *BuildConfig) IsContainer() bool { return c.HostConfig().IsContainer() }
   899  func (c *HostConfig) IsContainer() bool  { return c.ContainerImage != "" }
   900  
   901  func (c *BuildConfig) IsVM() bool { return c.HostConfig().IsVM() }
   902  
   903  // IsVM reports whether the instance running the job is ultimately a VM. Hosts where
   904  // a VM is used only to initiate a container are considered a container, not a VM.
   905  // EC2 instances may be configured to run in containers that are running
   906  // on custom AMIs.
   907  func (c *HostConfig) IsVM() bool {
   908  	if c.IsEC2 {
   909  		return c.VMImage != "" && c.ContainerImage == ""
   910  	}
   911  	return c.VMImage != ""
   912  }
   913  
   914  func (c *BuildConfig) GOOS() string { return c.Name[:strings.Index(c.Name, "-")] }
   915  
   916  func (c *BuildConfig) GOARCH() string {
   917  	arch := c.Name[strings.Index(c.Name, "-")+1:]
   918  	i := strings.Index(arch, "-")
   919  	if i == -1 {
   920  		return arch
   921  	}
   922  	return arch[:i]
   923  }
   924  
   925  // MatchesSlowBotTerm reports whether some provided term from a
   926  // TRY=... comment on a Run-TryBot+1 vote on Gerrit should match this
   927  // build config.
   928  func (c *BuildConfig) MatchesSlowBotTerm(term string) bool {
   929  	return term != "" && (term == c.Name || slowBotAliases[term] == c.Name)
   930  }
   931  
   932  // FilePathJoin is mostly like filepath.Join (without the cleaning) except
   933  // it uses the path separator of c.GOOS instead of the host system's.
   934  func (c *BuildConfig) FilePathJoin(x ...string) string {
   935  	if c.GOOS() == "windows" {
   936  		return strings.Join(x, "\\")
   937  	}
   938  	return strings.Join(x, "/")
   939  }
   940  
   941  func (c *BuildConfig) IsRestricted() bool {
   942  	return c.isRestricted
   943  }
   944  
   945  // DistTestsExecTimeout returns how long the coordinator should wait
   946  // for a cmd/dist test execution to run the provided dist test names.
   947  //
   948  // The dist test names are expressed in the Go 1.20 format, even for
   949  // newer Go versions. See go120DistTestNames.
   950  func (c *BuildConfig) DistTestsExecTimeout(distTests []string) time.Duration {
   951  	// TODO: consider using distTests? We never did before, but
   952  	// now we have the TestStats in the coordinator. Pass in a
   953  	// *buildstats.TestStats and use historical data times some
   954  	// fudge factor? For now just use the old 20 minute limit
   955  	// we've used since 2014, but scale it by the
   956  	// GO_TEST_TIMEOUT_SCALE for the super slow builders which
   957  	// struggle with, say, the cgo tests. (which should be broken
   958  	// up into separate dist tests or shards, like the test/ dir
   959  	// was)
   960  	d := 20 * time.Minute
   961  	d *= time.Duration(c.GoTestTimeoutScale())
   962  	return d
   963  }
   964  
   965  // GoTestTimeoutScale returns this builder's GO_TEST_TIMEOUT_SCALE value, or 1.
   966  func (c *BuildConfig) GoTestTimeoutScale() int {
   967  	const pfx = "GO_TEST_TIMEOUT_SCALE="
   968  	for _, env := range [][]string{c.env, c.HostConfig().env} {
   969  		for _, kv := range env {
   970  			if strings.HasPrefix(kv, pfx) {
   971  				if n, err := strconv.Atoi(kv[len(pfx):]); err == nil && n > 0 {
   972  					return n
   973  				}
   974  			}
   975  		}
   976  	}
   977  	return 1
   978  }
   979  
   980  // HostConfig returns the host configuration of c.
   981  func (c *BuildConfig) HostConfig() *HostConfig {
   982  	if c.TestHostConf != nil {
   983  		return c.TestHostConf
   984  	}
   985  	if c, ok := Hosts[c.HostType]; ok {
   986  		return c
   987  	}
   988  	panic(fmt.Sprintf("missing buildlet config for buildlet %q", c.Name))
   989  }
   990  
   991  // GoBootstrapURL returns the URL of a built Go 1.4+ tar.gz for the
   992  // build configuration type c, or empty string if there isn't one.
   993  func (c *BuildConfig) GoBootstrapURL(e *buildenv.Environment) string {
   994  	hc := c.HostConfig()
   995  	if hc.GoBootstrap == "none" {
   996  		return ""
   997  	}
   998  	if x, ok := version.Go1PointX(hc.GoBootstrap); ok && x < 21 {
   999  		return "https://storage.googleapis.com/" + e.BuildletBucket +
  1000  			"/gobootstrap-" + hc.HostArch + "-" + hc.GoBootstrap + ".tar.gz"
  1001  	}
  1002  	if c.GOOS() == "windows" {
  1003  		// Can't use Windows downloads from go.dev/dl, they're in .zip
  1004  		// format but the buildlet API accepts only the .tar.gz format.
  1005  		//
  1006  		// Since all this will be replaced by LUCI fairly soon,
  1007  		// keep using the bootstrap bucket for Windows for now.
  1008  		return "https://storage.googleapis.com/" + e.BuildletBucket +
  1009  			"/gobootstrap-" + hc.HostArch + "-" + hc.GoBootstrap + ".tar.gz"
  1010  	}
  1011  	return "https://go.dev/dl/" + hc.GoBootstrap + "." + hc.HostArch + ".tar.gz"
  1012  }
  1013  
  1014  // BuildletBinaryURL returns the public URL of this builder's buildlet.
  1015  func (c *HostConfig) BuildletBinaryURL(e *buildenv.Environment) string {
  1016  	return "https://storage.googleapis.com/" + e.BuildletBucket + "/buildlet." + c.HostArch
  1017  }
  1018  
  1019  // IsRace reports whether this is a race builder.
  1020  // A race builder runs tests without the -short flag.
  1021  //
  1022  // A builder is considered to be a race builder
  1023  // if and only if it one of the components of the builder
  1024  // name is "race" (components are delimited by "-").
  1025  func (c *BuildConfig) IsRace() bool {
  1026  	for _, s := range strings.Split(c.Name, "-") {
  1027  		if s == "race" {
  1028  			return true
  1029  		}
  1030  	}
  1031  	return false
  1032  }
  1033  
  1034  // IsLongTest reports whether this is a longtest builder.
  1035  // A longtest builder runs tests without the -short flag.
  1036  //
  1037  // A builder is considered to be a longtest builder
  1038  // if and only if it one of the components of the builder
  1039  // name is "longtest" (components are delimited by "-").
  1040  func (c *BuildConfig) IsLongTest() bool {
  1041  	for _, s := range strings.Split(c.Name, "-") {
  1042  		if s == "longtest" {
  1043  			return true
  1044  		}
  1045  	}
  1046  	return false
  1047  }
  1048  
  1049  // TargetArch returns the build target architecture.
  1050  //
  1051  // It starts from the host arch, then applies any environment
  1052  // variables that would override either GOOS, GOARCH, or GOARM.
  1053  func (c *BuildConfig) TargetArch() string {
  1054  	var goos, goarch, goarm string
  1055  	hostArch := c.HostConfig().HostArch
  1056  	h := strings.Split(hostArch, "-")
  1057  	switch len(h) {
  1058  	case 3:
  1059  		goarm = h[2]
  1060  		fallthrough
  1061  	case 2:
  1062  		goos = h[0]
  1063  		goarch = h[1]
  1064  	default:
  1065  		panic("bad host arch " + hostArch)
  1066  	}
  1067  	for _, v := range c.Env() {
  1068  		if strings.HasPrefix(v, "GOOS=") {
  1069  			goos = v[len("GOOS="):]
  1070  		}
  1071  		if strings.HasPrefix(v, "GOARCH=") {
  1072  			goarch = v[len("GOARCH="):]
  1073  		}
  1074  		if strings.HasPrefix(v, "GOARM=") {
  1075  			goarm = v[len("GOARM="):]
  1076  		}
  1077  	}
  1078  	if goarch == "arm" && goarm == "" {
  1079  		goarm = "7"
  1080  	}
  1081  	targetArch := goos + "-" + goarch
  1082  	if goarm != "" {
  1083  		targetArch += "-" + goarm
  1084  	}
  1085  	return targetArch
  1086  }
  1087  
  1088  // IsCrossCompileOnly indicates that this builder configuration
  1089  // cross-compiles for some platform other than the host, and that
  1090  // it does not run any tests.
  1091  //
  1092  // TODO(#58297): Remove this and make c.CompileOnly sufficient.
  1093  func (c *BuildConfig) IsCrossCompileOnly() bool {
  1094  	return c.TargetArch() != c.HostConfig().HostArch && c.CompileOnly
  1095  }
  1096  
  1097  // OutboundNetworkAllowed reports whether this builder should be
  1098  // allowed to make outbound network requests. This is only enforced
  1099  // on some builders. (Currently most Linux ones)
  1100  func (c *BuildConfig) OutboundNetworkAllowed() bool {
  1101  	return c.IsLongTest()
  1102  }
  1103  
  1104  func (c *BuildConfig) GoInstallRacePackages() []string {
  1105  	if c.InstallRacePackages != nil {
  1106  		return append([]string(nil), c.InstallRacePackages...)
  1107  	}
  1108  	if c.IsRace() {
  1109  		return []string{"std"}
  1110  	}
  1111  	return nil
  1112  }
  1113  
  1114  // AllScript returns the relative path to the operating system's script to
  1115  // do the build and run its standard set of tests.
  1116  // Example values are "src/all.bash", "src/all.bat", "src/all.rc".
  1117  func (c *BuildConfig) AllScript() string {
  1118  	if c.Name == "" {
  1119  		panic("bogus BuildConfig")
  1120  	}
  1121  	if c.IsRace() {
  1122  		if strings.HasPrefix(c.Name, "windows-") {
  1123  			return "src/race.bat"
  1124  		}
  1125  		return "src/race.bash"
  1126  	}
  1127  	if strings.HasPrefix(c.Name, "windows-") {
  1128  		return "src/all.bat"
  1129  	}
  1130  	if strings.HasPrefix(c.Name, "plan9-") {
  1131  		return "src/all.rc"
  1132  	}
  1133  	if c.IsCrossCompileOnly() {
  1134  		return "src/make.bash"
  1135  	}
  1136  	return "src/all.bash"
  1137  }
  1138  
  1139  func (c *BuildConfig) IsTryOnly() bool { return c.tryOnly }
  1140  
  1141  // PrivateGoProxy for builder has it's own Go proxy instead of proxy.golang.org
  1142  func (c *BuildConfig) PrivateGoProxy() bool { return c.privateGoProxy }
  1143  
  1144  // BuildsRepoPostSubmit reports whether the build configuration type c
  1145  // should build the given repo ("go", "net", etc) and branch
  1146  // ("master", "release-branch.go1.12") as a post-submit build
  1147  // that shows up on https://build.golang.org/.
  1148  func (c *BuildConfig) BuildsRepoPostSubmit(repo, branch, goBranch string) bool {
  1149  	if c.tryOnly {
  1150  		return false
  1151  	}
  1152  	return c.buildsRepoAtAll(repo, branch, goBranch)
  1153  }
  1154  
  1155  // BuildsRepoTryBot reports whether the build configuration type c
  1156  // should build the given repo ("go", "net", etc) and branch
  1157  // ("master", "release-branch.go1.12") as a trybot.
  1158  func (c *BuildConfig) BuildsRepoTryBot(repo, branch, goBranch string) bool {
  1159  	return c.tryBot != nil && c.tryBot(repo, branch, goBranch) && c.buildsRepoAtAll(repo, branch, goBranch)
  1160  }
  1161  
  1162  // ShouldRunDistTest reports whether the named cmd/dist test should be
  1163  // run for this build config. The dist test name is expressed in the
  1164  // Go 1.20 format, even for newer Go versions. See go120DistTestNames.
  1165  //
  1166  // The isNormalTry parameter specifies whether this is for a normal
  1167  // TryBot build. It's false for SlowBot and post-submit builds.
  1168  //
  1169  // In general, this returns true. When in normal trybot mode,
  1170  // some slow portable tests are only run on the fastest builder.
  1171  //
  1172  // It's possible for individual builders to adjust this policy for their needs,
  1173  // though it is preferable to handle that by adjusting test skips in the tests
  1174  // instead of here. That has the advantage of being easier to maintain over time
  1175  // since both the test and its skips would be in one repository rather than two,
  1176  // and having effect when tests are run locally by developers.
  1177  func (c *BuildConfig) ShouldRunDistTest(distTest string, isNormalTry bool) bool {
  1178  	run := true
  1179  
  1180  	// This section implements the default cmd/dist test policy.
  1181  	// Any changes here will affect test coverage on all builders.
  1182  	if isNormalTry {
  1183  		slowPortableTest := distTest == "api" // Whether a test is slow and has the same behavior everywhere.
  1184  		fastestBuilder := c.Name == "linux-amd64"
  1185  		if slowPortableTest && !fastestBuilder {
  1186  			// Don't run the test on this builder.
  1187  			run = false
  1188  		}
  1189  	}
  1190  
  1191  	// Individual builders have historically sometimes adjusted the cmd/dist test policy.
  1192  	// Over time these can migrate to better ways of doing platform-based or speed-based test skips.
  1193  	if c.distTestAdjust != nil {
  1194  		run = c.distTestAdjust(run, distTest, isNormalTry)
  1195  	}
  1196  
  1197  	return run
  1198  }
  1199  
  1200  // buildsRepoAtAll reports whether we should do builds of the provided
  1201  // repo ("go", "sys", "net", etc). This applies to both post-submit
  1202  // and trybot builds. Use BuildsRepoPostSubmit for only post-submit
  1203  // or BuildsRepoTryBot for trybots.
  1204  //
  1205  // The branch is the branch of repo ("master",
  1206  // "release-branch.go1.12", etc); it is required. The goBranch is the
  1207  // branch of Go itself. It's required if repo != "go". When repo ==
  1208  // "go", the goBranch defaults to the value of branch.
  1209  func (c *BuildConfig) buildsRepoAtAll(repo, branch, goBranch string) bool {
  1210  	if goBranch == "" {
  1211  		if repo == "go" {
  1212  			goBranch = branch
  1213  		} else {
  1214  			panic("missing goBranch")
  1215  		}
  1216  	}
  1217  	if branch == "" {
  1218  		panic("missing branch")
  1219  	}
  1220  	if repo == "" {
  1221  		panic("missing repo")
  1222  	}
  1223  	// Don't build old branches.
  1224  	const minGo1x = 11
  1225  	for _, b := range []string{branch, goBranch} {
  1226  		if bmaj, bmin, ok := version.ParseReleaseBranch(b); ok {
  1227  			if bmaj != 1 || bmin < minGo1x {
  1228  				return false
  1229  			}
  1230  			bmm := types.MajorMinor{Major: bmaj, Minor: bmin}
  1231  			if bmm.Less(c.MinimumGoVersion) {
  1232  				return false
  1233  			}
  1234  			if repo == "exp" {
  1235  				// Don't test exp against release branches; it's experimental.
  1236  				return false
  1237  			}
  1238  		}
  1239  	}
  1240  
  1241  	// Build dev.boringcrypto branches only on linux/amd64 and windows/386 (see go.dev/issue/26791).
  1242  	if repo == "go" && (branch == "dev.boringcrypto" || strings.HasPrefix(branch, "dev.boringcrypto.")) {
  1243  		if c.Name != "linux-amd64" && !strings.HasPrefix(c.Name, "windows-386") {
  1244  			return false
  1245  		}
  1246  	}
  1247  	if p := c.buildsRepo; p != nil {
  1248  		return p(repo, branch, goBranch)
  1249  	}
  1250  	return buildRepoByDefault(repo)
  1251  }
  1252  
  1253  // buildRepoByDefault reports whether builders should do builds
  1254  // for the given repo ("go", "net", etc.) by default.
  1255  //
  1256  // It's used directly by BuildConfig.buildsRepoAtAll method for
  1257  // builders with a nil BuildConfig.buildsRepo value.
  1258  // It's also used by many builders that provide a custom build
  1259  // repo policy (a non-nil BuildConfig.buildsRepo value) as part
  1260  // of making the decision of whether to build a given repo.
  1261  //
  1262  // As a result, it effectively implements the default build repo policy.
  1263  // Any changes here will affect repo coverage of many builders.
  1264  func buildRepoByDefault(repo string) bool {
  1265  	switch repo {
  1266  	case "go":
  1267  		// Build the main Go repository by default.
  1268  		return true
  1269  	case "build", "exp", "mobile", "pkgsite-metrics", "vulndb", "website":
  1270  		// Builders need to explicitly opt-in to build these repos.
  1271  		return false
  1272  	default:
  1273  		// Build all other golang.org/x repositories by default.
  1274  		return true
  1275  	}
  1276  }
  1277  
  1278  var (
  1279  	defaultPlusExp      = defaultPlus("exp")
  1280  	defaultPlusExpBuild = defaultPlus("exp", "build")
  1281  )
  1282  
  1283  // linux-amd64 and linux-amd64-race build all the repos.
  1284  // Many team repos are disabled on other builders because
  1285  // we only run them on servers and don't need to test the
  1286  // many different architectures that Go supports (like ios).
  1287  func linuxAmd64Repos(repo, branch, goBranch string) bool {
  1288  	return true
  1289  }
  1290  
  1291  // defaultPlus returns a buildsRepo policy function that returns true for all
  1292  // all the repos listed, plus the default repos.
  1293  func defaultPlus(repos ...string) func(repo, branch, goBranch string) bool {
  1294  	return func(repo, _, _ string) bool {
  1295  		for _, r := range repos {
  1296  			if r == repo {
  1297  				return true
  1298  			}
  1299  		}
  1300  		return buildRepoByDefault(repo)
  1301  	}
  1302  }
  1303  
  1304  // AllScriptArgs returns the set of arguments that should be passed to the
  1305  // all.bash-equivalent script. Usually empty.
  1306  func (c *BuildConfig) AllScriptArgs() []string {
  1307  	return append([]string(nil), c.allScriptArgs...)
  1308  }
  1309  
  1310  // MakeScript returns the relative path to the operating system's script to
  1311  // do the build.
  1312  // Example values are "src/make.bash", "src/make.bat", "src/make.rc".
  1313  func (c *BuildConfig) MakeScript() string {
  1314  	if strings.HasPrefix(c.Name, "windows-") {
  1315  		return "src/make.bat"
  1316  	}
  1317  	if strings.HasPrefix(c.Name, "plan9-") {
  1318  		return "src/make.rc"
  1319  	}
  1320  	return "src/make.bash"
  1321  }
  1322  
  1323  // MakeScriptArgs returns the set of arguments that should be passed to the
  1324  // make.bash-equivalent script. Usually empty.
  1325  func (c *BuildConfig) MakeScriptArgs() []string {
  1326  	return append([]string(nil), c.makeScriptArgs...)
  1327  }
  1328  
  1329  // GorootFinal returns the default install location for
  1330  // releases for the given GOOS.
  1331  func GorootFinal(goos string) string {
  1332  	if goos == "windows" {
  1333  		return "c:\\go"
  1334  	}
  1335  	return "/usr/local/go"
  1336  }
  1337  
  1338  // MachineType returns the AWS or GCE machine type to use for this builder.
  1339  func (c *HostConfig) MachineType() string {
  1340  	if c.IsEC2 {
  1341  		return c.machineType
  1342  	}
  1343  	typ := c.machineType
  1344  	if typ == "" {
  1345  		if c.NestedVirt || c.MinCPUPlatform != "" {
  1346  			// e2 instances do not support nested virtualization, but n2 instances do.
  1347  			// Same for MinCPUPlatform: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#limitations
  1348  			typ = "n2"
  1349  		} else {
  1350  			typ = "e2"
  1351  		}
  1352  	}
  1353  	if strings.Contains(typ, "-") { // full type like "n2-standard-8"
  1354  		return typ
  1355  	}
  1356  	if c.IsContainer() {
  1357  		// Set a higher default machine size for containers,
  1358  		// so their /workdir tmpfs can be larger. The COS
  1359  		// image has no swap, so we want to make sure the
  1360  		// /workdir fits completely in memory.
  1361  		return typ + "-standard-16" // 16 vCPUs, 64 GB mem
  1362  	}
  1363  	return typ + "-standard-8" // 8 vCPUs, 32 GB mem
  1364  }
  1365  
  1366  // IsEC2 returns true if the machine type is an EC2 arm64 type.
  1367  // PoolName returns a short summary of the builder's host type for the
  1368  // https://farmer.golang.org/builders page.
  1369  func (c *HostConfig) PoolName() string {
  1370  	switch {
  1371  	case c.IsReverse:
  1372  		return "Reverse (dedicated machine/VM)"
  1373  	case c.IsEC2:
  1374  		return "EC2 VM Container"
  1375  	case c.IsVM():
  1376  		return "GCE VM"
  1377  	case c.IsContainer():
  1378  		return "Container"
  1379  	}
  1380  	panic("unknown builder type")
  1381  }
  1382  
  1383  // ContainerVMImage returns the base VM name (not the fully qualified
  1384  // URL resource name of the VM) that starts the konlet program that
  1385  // pulls & runs a container.
  1386  // The empty string means that no particular VM image is required
  1387  // and the caller can run this container in any host.
  1388  //
  1389  // This method is only applicable when c.IsContainer() is true.
  1390  func (c *HostConfig) ContainerVMImage() string {
  1391  	if c.KonletVMImage != "" {
  1392  		return c.KonletVMImage
  1393  	}
  1394  	if c.NestedVirt {
  1395  		return "debian-bullseye-vmx"
  1396  	}
  1397  	if c.IsEC2 && c.ContainerImage != "" {
  1398  		return fmt.Sprintf("gcr.io/%s/%s", buildenv.Production.ProjectName, c.ContainerImage)
  1399  	}
  1400  	return ""
  1401  }
  1402  
  1403  // IsHermetic reports whether this host config gets a fresh
  1404  // environment (including /usr, /var, etc) for each execution. This is
  1405  // true for VMs, GKE, and reverse buildlets running their containers
  1406  // running in Docker, but false on some reverse buildlets.
  1407  func (c *HostConfig) IsHermetic() bool {
  1408  	switch {
  1409  	case c.IsReverse:
  1410  		return c.HermeticReverse
  1411  	case c.IsEC2:
  1412  		return true
  1413  	case c.IsVM():
  1414  		return true
  1415  	case c.IsContainer():
  1416  		return true
  1417  	}
  1418  	panic("unknown builder type")
  1419  }
  1420  
  1421  // IsGoogle reports whether this host is operated by Google,
  1422  // implying that we trust it to be secure and available.
  1423  func (c *HostConfig) IsGoogle() bool {
  1424  	if c.IsContainer() || c.IsVM() {
  1425  		return true
  1426  	}
  1427  	if c.IsReverse && c.GoogleReverse {
  1428  		return true
  1429  	}
  1430  	return false
  1431  }
  1432  
  1433  // NumTestHelpers reports how many additional buildlets
  1434  // past the first one to help out with sharded tests.
  1435  //
  1436  // isTry specifies whether it's for a pre-submit test
  1437  // run (a TryBot or SlowBot) where speed matters more.
  1438  func (c *BuildConfig) NumTestHelpers(isTry bool) int {
  1439  	if isTry && c.numTryTestHelpers != 0 {
  1440  		return c.numTryTestHelpers
  1441  	}
  1442  	return c.numTestHelpers
  1443  }
  1444  
  1445  // defaultTrySet returns a trybot policy function that reports whether
  1446  // a project should use trybots. All the default projects are included,
  1447  // plus any given in extraProj.
  1448  func defaultTrySet(extraProj ...string) func(proj, branch, goBranch string) bool {
  1449  	return func(proj, branch, goBranch string) bool {
  1450  		if proj == "go" {
  1451  			return true
  1452  		}
  1453  		for _, p := range extraProj {
  1454  			if proj == p {
  1455  				return true
  1456  			}
  1457  		}
  1458  		switch proj {
  1459  		case "grpc-review":
  1460  			return false
  1461  		}
  1462  		return true
  1463  	}
  1464  }
  1465  
  1466  // explicitTrySet returns a trybot policy function that reports
  1467  // whether a project should use trybots. Only the provided projects in
  1468  // projs are enabled.
  1469  func explicitTrySet(projs ...string) func(proj, branch, goBranch string) bool {
  1470  	return func(proj, branch, goBranch string) bool {
  1471  		for _, p := range projs {
  1472  			if proj == p {
  1473  				return true
  1474  			}
  1475  		}
  1476  		return false
  1477  	}
  1478  }
  1479  
  1480  // miscCompileBuildSet returns a policy function that reports whether a project
  1481  // should use trybots based on the platform.
  1482  func miscCompileBuildSet(goos, goarch string) func(proj, branch, goBranch string) bool {
  1483  	return func(proj, branch, goBranch string) bool {
  1484  		if proj != "go" && branch != "master" {
  1485  			return false // #58311
  1486  		}
  1487  		switch proj {
  1488  		case "benchmarks":
  1489  			// Failure to build because of a dependency not supported on plan9.
  1490  			// #58306 for loong64.
  1491  			return goos != "plan9" && goarch != "loong64"
  1492  		case "build":
  1493  			return goarch != "riscv64" // #58307
  1494  		case "exp":
  1495  			// exp fails to build most cross-compile platforms, partly because of x/mobile dependencies.
  1496  			return false
  1497  		case "mobile":
  1498  			// mobile fails to build on all cross-compile platforms. This is somewhat expected
  1499  			// given the nature of the repository. Leave this as a blanket policy for now.
  1500  			return false
  1501  		case "pkgsite": // #61341
  1502  			return goos != "plan9" && goos != "wasip1"
  1503  		case "vuln":
  1504  			// Failure to build because of a dependency not supported on plan9.
  1505  			return goos != "plan9"
  1506  		case "vulndb":
  1507  			return goos != "aix" // #58308
  1508  		case "website":
  1509  			// Failure to build because of a dependency not supported on plan9.
  1510  			return goos != "plan9"
  1511  		}
  1512  		return true
  1513  	}
  1514  }
  1515  
  1516  func init() {
  1517  	addBuilder(BuildConfig{
  1518  		Name:     "freebsd-amd64-12_3",
  1519  		HostType: "host-freebsd-amd64-12_3",
  1520  		tryBot:   defaultTrySet("sys"),
  1521  
  1522  		distTestAdjust:    fasterTrybots, // If changing this policy, update TestShouldRunDistTest accordingly.
  1523  		numTryTestHelpers: 4,
  1524  	})
  1525  	addBuilder(BuildConfig{
  1526  		Name:              "freebsd-386-12_3",
  1527  		HostType:          "host-freebsd-amd64-12_3",
  1528  		env:               []string{"GOARCH=386", "GOHOSTARCH=386"},
  1529  		distTestAdjust:    fasterTrybots,
  1530  		numTryTestHelpers: 4,
  1531  	})
  1532  	addBuilder(BuildConfig{
  1533  		Name:     "freebsd-amd64-race",
  1534  		HostType: "host-freebsd-amd64-13_0",
  1535  		env: []string{
  1536  			// Give this builder more time. The default timeout appears to be too small for x/tools
  1537  			// tests (specifically, I/O seems to be slower on this builder). See #64473.
  1538  			"GO_TEST_TIMEOUT_SCALE=2",
  1539  		},
  1540  	})
  1541  	addBuilder(BuildConfig{
  1542  		Name:              "freebsd-amd64-13_0",
  1543  		HostType:          "host-freebsd-amd64-13_0",
  1544  		tryBot:            explicitTrySet("sys"),
  1545  		distTestAdjust:    fasterTrybots, // If changing this policy, update TestShouldRunDistTest accordingly.
  1546  		numTryTestHelpers: 4,
  1547  	})
  1548  	addBuilder(BuildConfig{
  1549  		Name:              "freebsd-386-13_0",
  1550  		HostType:          "host-freebsd-amd64-13_0",
  1551  		tryBot:            explicitTrySet("sys"),
  1552  		env:               []string{"GOARCH=386", "GOHOSTARCH=386"},
  1553  		distTestAdjust:    fasterTrybots,
  1554  		numTryTestHelpers: 4,
  1555  	})
  1556  	addBuilder(BuildConfig{
  1557  		Name:           "linux-386",
  1558  		HostType:       "host-linux-amd64-bullseye",
  1559  		distTestAdjust: fasterTrybots,
  1560  		tryBot:         defaultTrySet(),
  1561  		Notes:          "Debian stable (currently Debian bullseye).",
  1562  		env: []string{
  1563  			"GOARCH=386",
  1564  			"GOHOSTARCH=386",
  1565  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1566  		},
  1567  		numTestHelpers:    1,
  1568  		numTryTestHelpers: 3,
  1569  	})
  1570  	addBuilder(BuildConfig{
  1571  		Name:  "linux-386-softfloat",
  1572  		Notes: "GO386=softfloat",
  1573  		buildsRepo: func(repo, branch, goBranch string) bool {
  1574  			return repo == "go" || repo == "crypto"
  1575  		},
  1576  		HostType: "host-linux-amd64-bullseye",
  1577  		env:      []string{"GOARCH=386", "GOHOSTARCH=386", "GO386=softfloat"},
  1578  	})
  1579  	addBuilder(BuildConfig{
  1580  		Name:       "linux-amd64",
  1581  		HostType:   "host-linux-amd64-bullseye",
  1582  		tryBot:     defaultTrySet(),
  1583  		buildsRepo: linuxAmd64Repos,
  1584  		env: []string{
  1585  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1586  		},
  1587  		numTestHelpers:    1,
  1588  		numTryTestHelpers: 4,
  1589  	})
  1590  	addBuilder(BuildConfig{
  1591  		Name:     "linux-amd64-boringcrypto",
  1592  		HostType: "host-linux-amd64-bullseye",
  1593  		Notes:    "GOEXPERIMENT=boringcrypto",
  1594  		tryBot:   defaultTrySet(),
  1595  		env: []string{
  1596  			"GOEXPERIMENT=boringcrypto",
  1597  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1598  		},
  1599  		numTestHelpers:    1,
  1600  		numTryTestHelpers: 4,
  1601  	})
  1602  	addBuilder(BuildConfig{
  1603  		Name:       "linux-amd64-vmx",
  1604  		HostType:   "host-linux-amd64-bullseye-vmx",
  1605  		buildsRepo: disabledBuilder,
  1606  	})
  1607  	addBuilder(BuildConfig{
  1608  		Name:     "linux-amd64-alpine",
  1609  		HostType: "host-linux-amd64-alpine",
  1610  	})
  1611  
  1612  	// addMiscCompileGo1 adds a misc-compile TryBot that
  1613  	// runs buildall.bash on the specified target ("$goos-$goarch").
  1614  	// If min is non-zero, it specifies the minimum Go 1.x version.
  1615  	addMiscCompileGo1 := func(min int, goos, goarch, extraSuffix string, extraEnv ...string) {
  1616  		var v types.MajorMinor
  1617  		var alsoNote string
  1618  		if min != 0 {
  1619  			v = types.MajorMinor{Major: 1, Minor: min}
  1620  			alsoNote = fmt.Sprintf(" Applies to Go 1.%d and newer.", min)
  1621  		}
  1622  		platform := goos + "-" + goarch + extraSuffix
  1623  		addBuilder(BuildConfig{
  1624  			Name:             "misc-compile-" + platform,
  1625  			HostType:         "host-linux-amd64-bullseye",
  1626  			tryBot:           miscCompileBuildSet(goos, goarch),
  1627  			env:              append(extraEnv, "GO_DISABLE_OUTBOUND_NETWORK=1", "GOOS="+goos, "GOARCH="+goarch),
  1628  			tryOnly:          true,
  1629  			MinimumGoVersion: v,
  1630  			CompileOnly:      true,
  1631  			SkipSnapshot:     true,
  1632  			Notes:            "Runs make.bash (or compile-only go test) for " + platform + ", but doesn't run any tests." + alsoNote,
  1633  		})
  1634  	}
  1635  	// addMiscCompile adds a misc-compile TryBot
  1636  	// for all supported Go versions.
  1637  	addMiscCompile := func(goos, goarch string) { addMiscCompileGo1(0, goos, goarch, "") }
  1638  
  1639  	// To keep things simple, have each misc-compile builder handle exactly one platform.
  1640  	//
  1641  	// This is potentially wasteful as there could be much more VM creation overhead, but
  1642  	// it shouldn't add any latency. It also adds some visual noise. The alternative was
  1643  	// more complex support for subrepos; this keeps things simple by following the same
  1644  	// general principle as all the other builders.
  1645  	//
  1646  	// See https://go.dev/issue/58163 for more details.
  1647  	addMiscCompile("windows", "arm")
  1648  	addMiscCompile("windows", "arm64")
  1649  	addMiscCompile("darwin", "amd64")
  1650  	addMiscCompile("darwin", "arm64")
  1651  	addMiscCompile("linux", "mips")
  1652  	addMiscCompile("linux", "mips64")
  1653  	addMiscCompile("linux", "mipsle")
  1654  	addMiscCompile("linux", "mips64le")
  1655  	addMiscCompile("linux", "ppc64")
  1656  	addMiscCompile("linux", "ppc64le")
  1657  	addMiscCompile("aix", "ppc64")
  1658  	addMiscCompile("freebsd", "386")
  1659  	addMiscCompile("freebsd", "arm")
  1660  	addMiscCompile("freebsd", "arm64")
  1661  	addMiscCompile("freebsd", "riscv64")
  1662  	addMiscCompile("netbsd", "386")
  1663  	addMiscCompile("netbsd", "amd64")
  1664  	addMiscCompile("netbsd", "arm")
  1665  	addMiscCompile("netbsd", "arm64")
  1666  	addMiscCompile("openbsd", "386")
  1667  	// openbsd-mips64 go.dev/issue/58110
  1668  	addMiscCompile("openbsd", "arm")
  1669  	addMiscCompile("openbsd", "arm64")
  1670  	addMiscCompileGo1(22, "openbsd", "ppc64", "-go1.22")
  1671  	addMiscCompileGo1(23, "openbsd", "riscv64", "-go1.23")
  1672  	addMiscCompile("plan9", "386")
  1673  	addMiscCompile("plan9", "amd64")
  1674  	addMiscCompile("plan9", "arm")
  1675  	addMiscCompile("solaris", "amd64")
  1676  	addMiscCompile("illumos", "amd64")
  1677  	addMiscCompile("dragonfly", "amd64")
  1678  	addMiscCompile("linux", "loong64")
  1679  	addMiscCompile("linux", "riscv64")
  1680  	addMiscCompile("linux", "s390x")
  1681  	addMiscCompile("linux", "arm")
  1682  	addMiscCompileGo1(0, "linux", "arm", "-arm5", "GOARM=5")
  1683  
  1684  	// TODO: Issue 25963, get the misc-compile trybots for Android/iOS.
  1685  	// Then consider subrepos too, so "mobile" can at least be included
  1686  	// as a misc-compile for ^android- and ^ios-.
  1687  
  1688  	addBuilder(BuildConfig{
  1689  		Name:     "linux-amd64-nocgo",
  1690  		HostType: "host-linux-amd64-bullseye",
  1691  		Notes:    "cgo disabled",
  1692  		buildsRepo: func(repo, branch, goBranch string) bool {
  1693  			b := buildRepoByDefault(repo)
  1694  			switch repo {
  1695  			case "perf":
  1696  				// Requires sqlite, which requires cgo.
  1697  				b = false
  1698  			case "exp":
  1699  				b = true
  1700  			}
  1701  			return b
  1702  		},
  1703  		env: []string{
  1704  			"CGO_ENABLED=0",
  1705  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1706  			// This USER=root was required for Docker-based builds but probably isn't required
  1707  			// in the VM anymore, since the buildlet probably already has this in its environment.
  1708  			// (It was required because without cgo, it couldn't find the username)
  1709  			"USER=root",
  1710  		},
  1711  	})
  1712  	addBuilder(BuildConfig{
  1713  		Name:       "linux-amd64-noopt",
  1714  		Notes:      "optimizations and inlining disabled",
  1715  		HostType:   "host-linux-amd64-bullseye",
  1716  		buildsRepo: onlyGo,
  1717  		env: []string{
  1718  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1719  			"GO_GCFLAGS=-N -l",
  1720  		},
  1721  	})
  1722  	addBuilder(BuildConfig{
  1723  		Name:        "linux-amd64-ssacheck",
  1724  		HostType:    "host-linux-amd64-bullseye",
  1725  		buildsRepo:  onlyGo,
  1726  		tryBot:      nil, // TODO: add a func to conditionally run this trybot if compiler dirs are touched
  1727  		CompileOnly: true,
  1728  		Notes:       "SSA internal checks enabled",
  1729  		env: []string{
  1730  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1731  			"GO_GCFLAGS=-d=ssa/check/on",
  1732  		},
  1733  	})
  1734  	addBuilder(BuildConfig{
  1735  		Name:     "linux-amd64-staticlockranking",
  1736  		HostType: "host-linux-amd64-bullseye",
  1737  		Notes:    "builder with GOEXPERIMENT=staticlockranking, see go.dev/issue/37937",
  1738  		buildsRepo: func(repo, branch, goBranch string) bool {
  1739  			return repo == "go"
  1740  		},
  1741  		env: []string{
  1742  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1743  			"GOEXPERIMENT=staticlockranking",
  1744  		},
  1745  	})
  1746  	addBuilder(BuildConfig{
  1747  		Name:     "linux-amd64-newinliner",
  1748  		HostType: "host-linux-amd64-bullseye",
  1749  		Notes:    "builder with GOEXPERIMENT=newinliner, see go.dev/issue/61883",
  1750  		tryBot: func(repo, branch, goBranch string) bool {
  1751  			return repo == "go" && goBranch == "master"
  1752  		},
  1753  		buildsRepo: func(repo, branch, goBranch string) bool {
  1754  			return repo == "go" && goBranch == "master"
  1755  		},
  1756  		env: []string{
  1757  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1758  			"GOEXPERIMENT=newinliner",
  1759  		},
  1760  		GoDeps: []string{
  1761  			"fbf9076ee8c8f665f1e8bba08fdc473cc7a2d690", // CL 511555, which added GOEXPERIMENT=newinliner
  1762  		},
  1763  		numTestHelpers:    1,
  1764  		numTryTestHelpers: 4,
  1765  	})
  1766  	addBuilder(BuildConfig{
  1767  		Name:     "linux-amd64-goamd64v3",
  1768  		HostType: "host-linux-amd64-bullseye",
  1769  		Notes:    "builder with GOAMD64=v3, see proposal 45453 and issue 48505",
  1770  		env: []string{
  1771  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1772  			"GOAMD64=v3",
  1773  		},
  1774  	})
  1775  	addBuilder(BuildConfig{
  1776  		Name:                "linux-amd64-racecompile",
  1777  		HostType:            "host-linux-amd64-bullseye",
  1778  		tryBot:              nil, // TODO: add a func to conditionally run this trybot if compiler dirs are touched
  1779  		CompileOnly:         true,
  1780  		SkipSnapshot:        true,
  1781  		StopAfterMake:       true,
  1782  		InstallRacePackages: []string{"cmd/compile", "cmd/link"},
  1783  		Notes:               "race-enabled cmd/compile and cmd/link",
  1784  		env: []string{
  1785  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1786  		},
  1787  	})
  1788  	addBuilder(BuildConfig{
  1789  		Name:              "linux-amd64-race",
  1790  		HostType:          "host-linux-amd64-bullseye",
  1791  		tryBot:            defaultTrySet(),
  1792  		buildsRepo:        linuxAmd64Repos,
  1793  		distTestAdjust:    fasterTrybots,
  1794  		numTestHelpers:    1,
  1795  		numTryTestHelpers: 5,
  1796  		env: []string{
  1797  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1798  		},
  1799  	})
  1800  	addBuilder(BuildConfig{
  1801  		Name:     "linux-386-clang",
  1802  		HostType: "host-linux-amd64-clang",
  1803  		Notes:    "Debian Buster + clang 7.0 instead of gcc",
  1804  		env:      []string{"CC=/usr/bin/clang", "GOHOSTARCH=386"},
  1805  	})
  1806  	addBuilder(BuildConfig{
  1807  		Name:     "linux-amd64-clang",
  1808  		HostType: "host-linux-amd64-clang",
  1809  		Notes:    "Debian Buster + clang 7.0 instead of gcc",
  1810  		env:      []string{"CC=/usr/bin/clang"},
  1811  	})
  1812  	addBuilder(BuildConfig{
  1813  		Name:     "linux-386-sid",
  1814  		HostType: "host-linux-amd64-sid",
  1815  		Notes:    "Debian sid (unstable)",
  1816  		env:      []string{"GOHOSTARCH=386"},
  1817  	})
  1818  	addBuilder(BuildConfig{
  1819  		Name:     "linux-amd64-sid",
  1820  		HostType: "host-linux-amd64-sid",
  1821  		Notes:    "Debian sid (unstable)",
  1822  	})
  1823  	addBuilder(BuildConfig{
  1824  		Name:     "linux-amd64-fedora",
  1825  		HostType: "host-linux-amd64-fedora",
  1826  		Notes:    "Fedora",
  1827  	})
  1828  	addBuilder(BuildConfig{
  1829  		Name:     "linux-amd64-androidemu",
  1830  		HostType: "host-linux-amd64-androidemu",
  1831  		env: []string{
  1832  			"GOARCH=amd64",
  1833  			"GOOS=linux",
  1834  			"CGO_ENABLED=1",
  1835  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1836  		},
  1837  		tryBot: func(repo, branch, goBranch string) bool {
  1838  			// Only for mobile repo for now, not "go":
  1839  			return repo == "mobile" && branch == "master" && goBranch == "master"
  1840  		},
  1841  		buildsRepo: func(repo, branch, goBranch string) bool {
  1842  			return repo == "mobile" && branch == "master" && goBranch == "master"
  1843  		},
  1844  		Notes: "Runs GOOS=linux but with the Android emulator attached, for running x/mobile host tests.",
  1845  	})
  1846  	addBuilder(BuildConfig{
  1847  		Name:     "linux-amd64-bookworm",
  1848  		HostType: "host-linux-amd64-bookworm",
  1849  		Notes:    "Debian Bookworm.",
  1850  		env: []string{
  1851  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1852  		},
  1853  	})
  1854  	addBuilder(BuildConfig{
  1855  		Name:     "linux-amd64-bullseye",
  1856  		HostType: "host-linux-amd64-bullseye",
  1857  		Notes:    "Debian Bullseye.",
  1858  		env: []string{
  1859  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1860  		},
  1861  	})
  1862  	addBuilder(BuildConfig{
  1863  		Name:     "linux-amd64-buster",
  1864  		HostType: "host-linux-amd64-buster",
  1865  		Notes:    "Debian Buster.",
  1866  		env: []string{
  1867  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1868  		},
  1869  	})
  1870  	addBuilder(BuildConfig{
  1871  		Name:     "linux-386-buster",
  1872  		HostType: "host-linux-amd64-buster",
  1873  		Notes:    "Debian Buster, 32-bit builder.",
  1874  		env: []string{
  1875  			"GOARCH=386",
  1876  			"GOHOSTARCH=386",
  1877  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1878  		},
  1879  	})
  1880  	addBuilder(BuildConfig{
  1881  		Name:     "linux-386-bullseye",
  1882  		HostType: "host-linux-amd64-bullseye",
  1883  		Notes:    "Debian Bullseye, 32-bit builder.",
  1884  		env: []string{
  1885  			"GOARCH=386",
  1886  			"GOHOSTARCH=386",
  1887  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1888  		},
  1889  	})
  1890  	addBuilder(BuildConfig{
  1891  		Name:     "linux-amd64-longtest",
  1892  		HostType: "host-linux-amd64-bullseye",
  1893  		Notes:    "Debian Bullseye with go test -short=false",
  1894  		tryBot: func(repo, branch, goBranch string) bool {
  1895  			onReleaseBranch := strings.HasPrefix(branch, "release-branch.")
  1896  			return repo == "go" && onReleaseBranch // See issue 37827.
  1897  		},
  1898  		buildsRepo: func(repo, branch, goBranch string) bool {
  1899  			// Test all repos, ignoring buildRepoByDefault.
  1900  			// For golang.org/x repos, don't test non-latest versions.
  1901  			return repo == "go" || (branch == "master" && goBranch == "master")
  1902  		},
  1903  		env: []string{
  1904  			"GO_TEST_TIMEOUT_SCALE=5", // give them lots of time
  1905  		},
  1906  		numTryTestHelpers: 4, // Target time is < 15 min for go.dev/issue/42661.
  1907  	})
  1908  	addBuilder(BuildConfig{
  1909  		Name:     "linux-amd64-longtest-race",
  1910  		HostType: "host-linux-amd64-bullseye",
  1911  		Notes:    "Debian Bullseye with the race detector enabled and go test -short=false",
  1912  		buildsRepo: func(repo, branch, goBranch string) bool {
  1913  			// Test all repos, ignoring buildRepoByDefault.
  1914  			// For golang.org/x repos, don't test non-latest versions.
  1915  			return repo == "go" || (branch == "master" && goBranch == "master")
  1916  		},
  1917  		env: []string{
  1918  			"GO_TEST_TIMEOUT_SCALE=5", // Inherited from the longtest builder.
  1919  		},
  1920  		numTryTestHelpers: 4, // Target time is < 15 min for go.dev/issue/56907.
  1921  	})
  1922  	addBuilder(BuildConfig{
  1923  		Name:     "linux-386-longtest",
  1924  		HostType: "host-linux-amd64-bullseye",
  1925  		Notes:    "Debian Bullseye with go test -short=false; to get 32-bit coverage",
  1926  		tryBot: func(repo, branch, goBranch string) bool {
  1927  			onReleaseBranch := strings.HasPrefix(branch, "release-branch.")
  1928  			return repo == "go" && onReleaseBranch // See issue 37827.
  1929  		},
  1930  		buildsRepo: func(repo, branch, goBranch string) bool {
  1931  			b := buildRepoByDefault(repo)
  1932  			if repo != "go" && !(branch == "master" && goBranch == "master") {
  1933  				// For golang.org/x repos, don't test non-latest versions.
  1934  				b = false
  1935  			}
  1936  			return b
  1937  		},
  1938  		env: []string{
  1939  			"GOARCH=386",
  1940  			"GOHOSTARCH=386",
  1941  			"GO_TEST_TIMEOUT_SCALE=5", // give them lots of time
  1942  		},
  1943  		numTryTestHelpers: 4, // Target time is < 15 min for go.dev/issue/42661.
  1944  	})
  1945  	addBuilder(BuildConfig{
  1946  		Name:     "js-wasm-node18",
  1947  		HostType: "host-linux-amd64-js-wasm-node18",
  1948  		tryBot:   explicitTrySet("go"),
  1949  		buildsRepo: func(repo, branch, goBranch string) bool {
  1950  			b := buildRepoByDefault(repo) && atLeastGo1(goBranch, 21)
  1951  			switch repo {
  1952  			case "benchmarks", "debug", "perf", "talks", "tools", "tour", "website":
  1953  				// Don't test these golang.org/x repos.
  1954  				b = false
  1955  			}
  1956  			if repo != "go" && !(branch == "master" && goBranch == "master") {
  1957  				// For golang.org/x repos, don't test non-latest versions.
  1958  				b = false
  1959  			}
  1960  			return b
  1961  		},
  1962  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  1963  			if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
  1964  				// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
  1965  				run = false
  1966  			}
  1967  			return run
  1968  		},
  1969  		numTryTestHelpers: 3,
  1970  		env: []string{
  1971  			"GOOS=js", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
  1972  			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
  1973  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  1974  		},
  1975  	})
  1976  	addBuilder(BuildConfig{
  1977  		Name:              "openbsd-amd64-72",
  1978  		HostType:          "host-openbsd-amd64-72",
  1979  		tryBot:            defaultTrySet(),
  1980  		distTestAdjust:    noTestDirAndNoReboot,
  1981  		numTryTestHelpers: 4,
  1982  	})
  1983  	addBuilder(BuildConfig{
  1984  		Name:     "openbsd-386-72",
  1985  		HostType: "host-openbsd-386-72",
  1986  		tryBot:   explicitTrySet("sys"),
  1987  		buildsRepo: func(repo, branch, goBranch string) bool {
  1988  			// https://go.dev/issue/49529: git seems to be too slow on this
  1989  			// platform.
  1990  			return repo != "review" && buildRepoByDefault(repo)
  1991  		},
  1992  		distTestAdjust:    noTestDirAndNoReboot,
  1993  		numTryTestHelpers: 4,
  1994  	})
  1995  	addBuilder(BuildConfig{
  1996  		Name:         "openbsd-arm-jsing",
  1997  		HostType:     "host-openbsd-arm-joelsing",
  1998  		SkipSnapshot: true,
  1999  		FlakyNet:     true,
  2000  		buildsRepo: func(repo, branch, goBranch string) bool {
  2001  			switch repo {
  2002  			case "go", "net", "sys":
  2003  				return branch == "master" && goBranch == "master"
  2004  			default:
  2005  				return false
  2006  			}
  2007  		},
  2008  		distTestAdjust: noTestDirAndNoReboot,
  2009  		tryBot:         nil,
  2010  		env: []string{
  2011  			// The machine is slow.
  2012  			"GO_TEST_TIMEOUT_SCALE=5",
  2013  		},
  2014  	})
  2015  	addBuilder(BuildConfig{
  2016  		Name:         "openbsd-arm64-jsing",
  2017  		HostType:     "host-openbsd-arm64-joelsing",
  2018  		SkipSnapshot: true,
  2019  		FlakyNet:     true,
  2020  		buildsRepo: func(repo, branch, goBranch string) bool {
  2021  			switch repo {
  2022  			case "go", "net", "sys":
  2023  				return branch == "master" && goBranch == "master"
  2024  			default:
  2025  				return false
  2026  			}
  2027  		},
  2028  		distTestAdjust: noTestDirAndNoReboot,
  2029  		tryBot:         nil,
  2030  		env: []string{
  2031  			// The machine is slow.
  2032  			"GO_TEST_TIMEOUT_SCALE=5",
  2033  		},
  2034  	})
  2035  	addBuilder(BuildConfig{
  2036  		Name:         "openbsd-mips64-jsing",
  2037  		HostType:     "host-openbsd-mips64-joelsing",
  2038  		KnownIssues:  []int{36435, 58110, 61546},
  2039  		SkipSnapshot: true,
  2040  		FlakyNet:     true,
  2041  		buildsRepo: func(repo, branch, goBranch string) bool {
  2042  			switch repo {
  2043  			case "go", "net", "sys":
  2044  				return branch == "master" && goBranch == "master"
  2045  			default:
  2046  				return false
  2047  			}
  2048  		},
  2049  		distTestAdjust: noTestDirAndNoReboot,
  2050  		tryBot:         nil,
  2051  		env: []string{
  2052  			// The machine is slow.
  2053  			"GO_TEST_TIMEOUT_SCALE=5",
  2054  		},
  2055  	})
  2056  	addBuilder(BuildConfig{
  2057  		Name:         "openbsd-ppc64-n2vi",
  2058  		HostType:     "host-openbsd-ppc64-n2vi",
  2059  		SkipSnapshot: true,
  2060  		FlakyNet:     true,
  2061  		buildsRepo: func(repo, branch, goBranch string) bool {
  2062  			switch repo {
  2063  			case "go", "net", "sys":
  2064  				return branch == "master" && goBranch == "master"
  2065  			default:
  2066  				return false
  2067  			}
  2068  		},
  2069  		distTestAdjust: noTestDirAndNoReboot,
  2070  		tryBot:         nil,
  2071  	})
  2072  	addBuilder(BuildConfig{
  2073  		Name:         "openbsd-riscv64-jsing",
  2074  		HostType:     "host-openbsd-riscv64-joelsing",
  2075  		SkipSnapshot: true,
  2076  		FlakyNet:     true,
  2077  		buildsRepo: func(repo, branch, goBranch string) bool {
  2078  			switch repo {
  2079  			case "go", "net", "sys":
  2080  				return branch == "master" && goBranch == "master"
  2081  			default:
  2082  				return false
  2083  			}
  2084  		},
  2085  		distTestAdjust: noTestDirAndNoReboot,
  2086  		tryBot:         nil,
  2087  		env: []string{
  2088  			// The machine is slow.
  2089  			"GO_TEST_TIMEOUT_SCALE=3",
  2090  		},
  2091  	})
  2092  	addBuilder(BuildConfig{
  2093  		Name:           "netbsd-386-9_3",
  2094  		HostType:       "host-netbsd-386-9_3",
  2095  		distTestAdjust: noTestDirAndNoReboot,
  2096  	})
  2097  	addBuilder(BuildConfig{
  2098  		Name:           "netbsd-amd64-9_3",
  2099  		HostType:       "host-netbsd-amd64-9_3",
  2100  		distTestAdjust: noTestDirAndNoReboot,
  2101  		tryBot:         explicitTrySet("sys"),
  2102  	})
  2103  	addBuilder(BuildConfig{
  2104  		Name:     "netbsd-arm-bsiegert",
  2105  		HostType: "host-netbsd-arm-bsiegert",
  2106  		buildsRepo: func(repo, branch, goBranch string) bool {
  2107  			if repo == "review" {
  2108  				// https://go.dev/issue/49530: This test seems to be too slow even
  2109  				// with a long scale factor.
  2110  				return false
  2111  			}
  2112  			return buildRepoByDefault(repo)
  2113  		},
  2114  		distTestAdjust: noTestDirAndNoReboot,
  2115  		tryBot:         nil,
  2116  		env: []string{
  2117  			// The machine is slow.
  2118  			"GO_TEST_TIMEOUT_SCALE=10",
  2119  		},
  2120  		FlakyNet: true,
  2121  	})
  2122  	addBuilder(BuildConfig{
  2123  		Name:           "netbsd-arm64-bsiegert",
  2124  		HostType:       "host-netbsd-arm64-bsiegert",
  2125  		distTestAdjust: noTestDirAndNoReboot,
  2126  		tryBot:         nil,
  2127  		env: []string{
  2128  			// The machine is slow.
  2129  			"GO_TEST_TIMEOUT_SCALE=10",
  2130  		},
  2131  		FlakyNet: true,
  2132  	})
  2133  	addBuilder(BuildConfig{
  2134  		Name:           "plan9-386",
  2135  		HostType:       "host-plan9-386-gce",
  2136  		numTestHelpers: 1,
  2137  		tryOnly:        true, // disable it for now; Issue 31261, Issue 29801
  2138  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2139  			switch distTest {
  2140  			case "api",
  2141  				"go_test:cmd/go": // takes over 20 minutes without working SMP
  2142  				return false
  2143  			}
  2144  			return run
  2145  		},
  2146  		buildsRepo:  plan9Default,
  2147  		KnownIssues: []int{29801},
  2148  	})
  2149  	addBuilder(BuildConfig{
  2150  		Name:              "windows-386-2016",
  2151  		HostType:          "host-windows-amd64-2016",
  2152  		env:               []string{"GOARCH=386", "GOHOSTARCH=386"},
  2153  		tryBot:            defaultTrySet(),
  2154  		numTryTestHelpers: 4,
  2155  	})
  2156  	addBuilder(BuildConfig{
  2157  		Name:           "windows-amd64-2016",
  2158  		HostType:       "host-windows-amd64-2016",
  2159  		buildsRepo:     defaultPlusExpBuild,
  2160  		distTestAdjust: fasterTrybots,
  2161  		env: []string{
  2162  			"GOARCH=amd64",
  2163  			"GOHOSTARCH=amd64",
  2164  			// cmd/go takes ~188 seconds on windows-amd64
  2165  			// now, which is over the 180 second default
  2166  			// dist test timeout. So, bump this builder
  2167  			// up:
  2168  			"GO_TEST_TIMEOUT_SCALE=2",
  2169  		},
  2170  		tryBot:            defaultTrySet(),
  2171  		numTryTestHelpers: 5,
  2172  	})
  2173  	addBuilder(BuildConfig{
  2174  		Name:     "windows-amd64-longtest",
  2175  		HostType: "host-windows-amd64-2016-big",
  2176  		Notes:    "Windows Server 2016 with go test -short=false",
  2177  		tryBot: func(repo, branch, goBranch string) bool {
  2178  			onReleaseBranch := strings.HasPrefix(branch, "release-branch.")
  2179  			return repo == "go" && onReleaseBranch // See issue 37827.
  2180  		},
  2181  		buildsRepo: func(repo, branch, goBranch string) bool {
  2182  			b := defaultPlusExpBuild(repo, branch, goBranch)
  2183  			if repo != "go" && !(branch == "master" && goBranch == "master") {
  2184  				// For golang.org/x repos, don't test non-latest versions.
  2185  				b = false
  2186  			}
  2187  			return b
  2188  		},
  2189  		env: []string{
  2190  			"GO_TEST_TIMEOUT_SCALE=5", // give them lots of time
  2191  		},
  2192  		numTryTestHelpers: 4, // Target time is < 15 min for go.dev/issue/42661.
  2193  	})
  2194  	addBuilder(BuildConfig{
  2195  		Name:     "windows-amd64-race",
  2196  		HostType: "host-windows-amd64-2016",
  2197  		Notes:    "Only runs -race tests (./race.bat)",
  2198  		env: []string{
  2199  			"GOARCH=amd64",
  2200  			"GOHOSTARCH=amd64",
  2201  			// cmd/go takes ~188 seconds on windows-amd64
  2202  			// now, which is over the 180 second default
  2203  			// dist test timeout. So, bump this builder
  2204  			// up:
  2205  			"GO_TEST_TIMEOUT_SCALE=2"},
  2206  	})
  2207  	addBuilder(BuildConfig{
  2208  		Name:     "windows-arm-zx2c4",
  2209  		HostType: "host-windows-arm64-zx2c4",
  2210  		env: []string{
  2211  			"GOARM=7",
  2212  			"GO_TEST_TIMEOUT_SCALE=3"},
  2213  	})
  2214  	addBuilder(BuildConfig{
  2215  		Name:              "windows-arm64-11",
  2216  		HostType:          "host-windows11-arm64-azure",
  2217  		numTryTestHelpers: 1,
  2218  		env: []string{
  2219  			"GOARCH=arm64",
  2220  			// Note: GOMAXPROCS=4 workaround for go.dev/issue/51019
  2221  			// tentatively removed here, since Azure VMs have 3x more
  2222  			// RAM than the previous win11/arm64 machines.
  2223  		},
  2224  	})
  2225  	addBuilder(BuildConfig{
  2226  		Name:           "darwin-amd64-10_15",
  2227  		HostType:       "host-darwin-amd64-10_15-aws",
  2228  		distTestAdjust: macTestPolicy,
  2229  		buildsRepo: func(repo, branch, goBranch string) bool {
  2230  			return defaultPlusExpBuild(repo, branch, goBranch) && atMostGo1(goBranch, 22)
  2231  		},
  2232  	})
  2233  	addBuilder(BuildConfig{
  2234  		Name:           "darwin-amd64-11_0",
  2235  		HostType:       "host-darwin-amd64-11-aws",
  2236  		distTestAdjust: macTestPolicy,
  2237  		buildsRepo:     defaultPlusExpBuild,
  2238  	})
  2239  	addBuilder(BuildConfig{
  2240  		Name:           "darwin-amd64-12_0",
  2241  		HostType:       "host-darwin-amd64-12-aws",
  2242  		distTestAdjust: macTestPolicy,
  2243  		buildsRepo:     defaultPlusExpBuild,
  2244  	})
  2245  	addBuilder(BuildConfig{
  2246  		Name:           "darwin-amd64-13",
  2247  		HostType:       "host-darwin-amd64-13-aws",
  2248  		distTestAdjust: macTestPolicy,
  2249  		buildsRepo:     defaultPlusExpBuild,
  2250  	})
  2251  	addBuilder(BuildConfig{
  2252  		Name:           "darwin-amd64-nocgo",
  2253  		HostType:       "host-darwin-amd64-12-aws",
  2254  		distTestAdjust: noTestDirAndNoReboot,
  2255  		env:            []string{"CGO_ENABLED=0"},
  2256  	})
  2257  	addBuilder(BuildConfig{
  2258  		Name:     "darwin-amd64-longtest",
  2259  		HostType: "host-darwin-amd64-13-aws",
  2260  		Notes:    "macOS 13 with go test -short=false",
  2261  		buildsRepo: func(repo, branch, goBranch string) bool {
  2262  			b := buildRepoByDefault(repo)
  2263  			if repo == "go" && !atLeastGo1(goBranch, 21) {
  2264  				// The builder was added during Go 1.21 dev cycle.
  2265  				// It uncovered some tests that weren't passing and needed to be fixed.
  2266  				// Disable the builder on older release branches unless/until it's decided
  2267  				// that we should backport the needed fixes (and that the older releases
  2268  				// don't have even more that needs fixing before the builder passes fully).
  2269  				b = false
  2270  			}
  2271  			if repo != "go" && !(branch == "master" && goBranch == "master") {
  2272  				// For golang.org/x repos, don't test non-latest versions.
  2273  				b = false
  2274  			}
  2275  			return b
  2276  		},
  2277  		env: []string{
  2278  			// We use a timeout scale value of 5 for most longtest builders
  2279  			// to give them lots of time. This particular builder is not as fast
  2280  			// as the rest, so we give it 2x headroom for a scale value of 10.
  2281  			// See go.dev/issue/60919.
  2282  			"GO_TEST_TIMEOUT_SCALE=10",
  2283  		},
  2284  	})
  2285  	addBuilder(BuildConfig{
  2286  		Name:           "darwin-arm64-11",
  2287  		HostType:       "host-darwin-arm64-11",
  2288  		distTestAdjust: macTestPolicy,
  2289  		buildsRepo:     defaultPlusExpBuild,
  2290  	})
  2291  	addBuilder(BuildConfig{
  2292  		Name:           "darwin-arm64-12",
  2293  		HostType:       "host-darwin-arm64-12",
  2294  		distTestAdjust: macTestPolicy,
  2295  		buildsRepo:     defaultPlusExpBuild,
  2296  	})
  2297  	addBuilder(BuildConfig{
  2298  		Name:           "darwin-amd64-race",
  2299  		HostType:       "host-darwin-amd64-12-aws",
  2300  		distTestAdjust: macTestPolicy,
  2301  		buildsRepo:     onlyGo,
  2302  		env: []string{
  2303  			// Increase the timeout scale for this builder: it was observed to be
  2304  			// timing out frequently in
  2305  			// https://go.dev/issue/55311#issuecomment-1571986012.
  2306  			//
  2307  			// TODO(bcmills): The darwin-amd64-longtest builder was running extremely
  2308  			// slowly because it was hitting swap. Race-enabled builds are also
  2309  			// memory-hungry — is it possible that the -race builder is also swapping?
  2310  			"GO_TEST_TIMEOUT_SCALE=2",
  2311  		},
  2312  	})
  2313  	addBuilder(BuildConfig{
  2314  		Name:     "ios-arm64-corellium",
  2315  		HostType: "host-ios-arm64-corellium-ios",
  2316  		Notes:    "Virtual iPhone SE running on Corellium; owned by zenly (github.com/znly)",
  2317  		buildsRepo: func(repo, branch, goBranch string) bool {
  2318  			return repo == "go" && branch == "master" && goBranch == "master"
  2319  		},
  2320  	})
  2321  	addBuilder(BuildConfig{
  2322  		Name:     "android-arm64-corellium",
  2323  		HostType: "host-android-arm64-corellium-android",
  2324  		Notes:    "Virtual Android running on Corellium; owned by zenly (github.com/znly)",
  2325  		buildsRepo: func(repo, branch, goBranch string) bool {
  2326  			return repo == "go" && branch == "master" && goBranch == "master"
  2327  		},
  2328  	})
  2329  	addBuilder(BuildConfig{
  2330  		Name:     "android-arm-corellium",
  2331  		HostType: "host-android-arm64-corellium-android",
  2332  		Notes:    "Virtual Android running on Corellium; owned by zenly (github.com/znly)",
  2333  		buildsRepo: func(repo, branch, goBranch string) bool {
  2334  			return repo == "go" && branch == "master" && goBranch == "master"
  2335  		},
  2336  		env: []string{
  2337  			"CGO_ENABLED=1",
  2338  			"GOARCH=arm",
  2339  			"GO_TEST_TIMEOUT_SCALE=2", // inherited from cmd/dist's default for GOARCH=arm
  2340  		},
  2341  	})
  2342  	addBuilder(BuildConfig{
  2343  		Name:     "android-386-emu",
  2344  		HostType: "host-linux-amd64-androidemu", // same amd64 host is used for 386 builder
  2345  		Notes:    "Android emulator on GCE (GOOS=android GOARCH=386)",
  2346  		buildsRepo: func(repo, branch, goBranch string) bool {
  2347  			b := buildRepoByDefault(repo)
  2348  			switch repo {
  2349  			case "mobile":
  2350  				b = true
  2351  			case "build", "blog", "talks", "review", "tour", "website":
  2352  				b = false
  2353  			case "pkgsite":
  2354  				// The pkgsite tests need CL 472096, released in 1.21 to run properly.
  2355  				b = atLeastGo1(goBranch, 21)
  2356  			}
  2357  			return b
  2358  		},
  2359  		env: []string{
  2360  			"GOARCH=386",
  2361  			"GOOS=android",
  2362  			"GOHOSTARCH=amd64",
  2363  			"GOHOSTOS=linux",
  2364  			"CGO_ENABLED=1",
  2365  		},
  2366  	})
  2367  	addBuilder(BuildConfig{
  2368  		Name:              "android-amd64-emu",
  2369  		HostType:          "host-linux-amd64-androidemu",
  2370  		Notes:             "Android emulator on GCE (GOOS=android GOARCH=amd64)",
  2371  		numTryTestHelpers: 3,
  2372  		tryBot: func(repo, branch, goBranch string) bool {
  2373  			// See discussion in go.dev/issue/53377.
  2374  			switch repo {
  2375  			case "mobile":
  2376  				return true
  2377  			}
  2378  			return false
  2379  		},
  2380  		buildsRepo: func(repo, branch, goBranch string) bool {
  2381  			b := buildRepoByDefault(repo)
  2382  			switch repo {
  2383  			case "mobile":
  2384  				b = true
  2385  			case "build", "blog", "talks", "review", "tour", "website":
  2386  				b = false
  2387  			case "pkgsite":
  2388  				// The pkgsite tests need CL 472096, released in 1.21 to run properly.
  2389  				b = atLeastGo1(goBranch, 21)
  2390  			}
  2391  			return b
  2392  		},
  2393  		env: []string{
  2394  			"GOARCH=amd64",
  2395  			"GOOS=android",
  2396  			"GOHOSTARCH=amd64",
  2397  			"GOHOSTOS=linux",
  2398  			"CGO_ENABLED=1",
  2399  		},
  2400  	})
  2401  	addBuilder(BuildConfig{
  2402  		Name:     "illumos-amd64",
  2403  		HostType: "host-illumos-amd64-jclulow",
  2404  	})
  2405  	addBuilder(BuildConfig{
  2406  		Name:     "solaris-amd64-oraclerel",
  2407  		HostType: "host-solaris-oracle-amd64-oraclerel",
  2408  		Notes:    "Oracle Solaris release version",
  2409  		FlakyNet: true,
  2410  	})
  2411  	addBuilder(BuildConfig{
  2412  		Name:           "linux-ppc64-sid-buildlet",
  2413  		HostType:       "host-linux-ppc64-sid",
  2414  		FlakyNet:       true,
  2415  		distTestAdjust: ppc64DistTestPolicy,
  2416  		env:            []string{"GO_TEST_TIMEOUT_SCALE=2"}, // see go.dev/issues/44422
  2417  	})
  2418  	addBuilder(BuildConfig{
  2419  		Name:           "linux-ppc64-sid-power10",
  2420  		HostType:       "host-linux-ppc64-sid-power10",
  2421  		FlakyNet:       true,
  2422  		distTestAdjust: ppc64DistTestPolicy,
  2423  		env:            []string{"GO_TEST_TIMEOUT_SCALE=2"}, // see go.dev/issues/44422
  2424  	})
  2425  	addBuilder(BuildConfig{
  2426  		Name:           "linux-ppc64le-buildlet",
  2427  		HostType:       "host-linux-ppc64le-osu",
  2428  		FlakyNet:       true,
  2429  		distTestAdjust: ppc64DistTestPolicy,
  2430  		env:            []string{"GO_TEST_TIMEOUT_SCALE=2"}, // see go.dev/issues/44422
  2431  	})
  2432  	addBuilder(BuildConfig{
  2433  		Name:           "linux-ppc64le-power9osu",
  2434  		HostType:       "host-linux-ppc64le-power9-osu",
  2435  		FlakyNet:       true,
  2436  		distTestAdjust: ppc64DistTestPolicy,
  2437  		env:            []string{"GO_TEST_TIMEOUT_SCALE=2"}, // see go.dev/issues/44422
  2438  	})
  2439  	addBuilder(BuildConfig{
  2440  		Name:           "linux-ppc64le-power10osu",
  2441  		HostType:       "host-linux-ppc64le-power10-osu",
  2442  		FlakyNet:       true,
  2443  		distTestAdjust: ppc64DistTestPolicy,
  2444  		env:            []string{"GO_TEST_TIMEOUT_SCALE=2"}, // see go.dev/issues/44422
  2445  	})
  2446  	addBuilder(BuildConfig{
  2447  		Name:              "linux-arm64",
  2448  		HostType:          "host-linux-arm64-bullseye",
  2449  		tryBot:            defaultTrySet(),
  2450  		numTryTestHelpers: 1,
  2451  	})
  2452  	addBuilder(BuildConfig{
  2453  		Name:     "linux-arm64-race",
  2454  		HostType: "host-linux-arm64-bullseye",
  2455  	})
  2456  	addBuilder(BuildConfig{
  2457  		Name:     "linux-arm64-boringcrypto",
  2458  		HostType: "host-linux-arm64-bullseye",
  2459  		env: []string{
  2460  			"GOEXPERIMENT=boringcrypto",
  2461  			"GO_DISABLE_OUTBOUND_NETWORK=1",
  2462  		},
  2463  	})
  2464  	addBuilder(BuildConfig{
  2465  		Name:     "linux-arm64-longtest",
  2466  		HostType: "host-linux-arm64-bullseye-high-disk",
  2467  		Notes:    "Debian Bullseye with go test -short=false",
  2468  		tryBot: func(repo, branch, goBranch string) bool {
  2469  			onReleaseBranch := strings.HasPrefix(branch, "release-branch.")
  2470  			return repo == "go" && onReleaseBranch // See issue 37827.
  2471  		},
  2472  		buildsRepo: func(repo, branch, goBranch string) bool {
  2473  			b := buildRepoByDefault(repo)
  2474  			if repo != "go" && !(branch == "master" && goBranch == "master") {
  2475  				// For golang.org/x repos, don't test non-latest versions.
  2476  				b = false
  2477  			}
  2478  			return b
  2479  		},
  2480  		env: []string{
  2481  			"GO_TEST_TIMEOUT_SCALE=5", // give them lots of time
  2482  		},
  2483  		numTryTestHelpers: 4, // Target time is < 15 min for go.dev/issue/42661.
  2484  	})
  2485  	addBuilder(BuildConfig{
  2486  		Name:              "linux-arm-aws",
  2487  		HostType:          "host-linux-arm-aws",
  2488  		numTryTestHelpers: 1,
  2489  		env: []string{
  2490  			"GOARCH=arm",
  2491  			"GOARM=6",
  2492  			"GOHOSTARCH=arm",
  2493  			"CGO_CFLAGS=-march=armv6",
  2494  			"CGO_LDFLAGS=-march=armv6",
  2495  			"GO_TEST_TIMEOUT_SCALE=2", // inherited from cmd/dist's default for GOARCH=arm
  2496  		},
  2497  	})
  2498  	addBuilder(BuildConfig{
  2499  		FlakyNet:     true,
  2500  		HostType:     "host-linux-loong64-3a5000",
  2501  		Name:         "linux-loong64-3a5000",
  2502  		SkipSnapshot: true,
  2503  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2504  			switch distTest {
  2505  			case "api", "reboot":
  2506  				return false
  2507  			}
  2508  			return run
  2509  		},
  2510  		buildsRepo: func(repo, branch, goBranch string) bool {
  2511  			switch repo {
  2512  			case "go":
  2513  				return true
  2514  			case "arch", "net", "sys":
  2515  				return branch == "master"
  2516  			default:
  2517  				return false
  2518  			}
  2519  		},
  2520  		privateGoProxy: true, // this builder is behind firewall
  2521  		env: []string{
  2522  			"GOARCH=loong64",
  2523  			"GOHOSTARCH=loong64",
  2524  		},
  2525  	})
  2526  	addBuilder(BuildConfig{
  2527  		FlakyNet:       true,
  2528  		HostType:       "host-linux-mips64le-rtrk",
  2529  		Name:           "linux-mips64le-rtrk",
  2530  		SkipSnapshot:   true,
  2531  		distTestAdjust: mipsDistTestPolicy,
  2532  		buildsRepo:     mipsBuildsRepoPolicy,
  2533  		env: []string{
  2534  			"GOARCH=mips64le",
  2535  			"GOHOSTARCH=mips64le",
  2536  			"GO_TEST_TIMEOUT_SCALE=4", // inherited from cmd/dist's default for GOARCH=mips{,le,64,64le}
  2537  		},
  2538  	})
  2539  	addBuilder(BuildConfig{
  2540  		FlakyNet:       true,
  2541  		HostType:       "host-linux-mips64le-rtrk",
  2542  		Name:           "linux-mipsle-rtrk",
  2543  		SkipSnapshot:   true,
  2544  		distTestAdjust: mipsDistTestPolicy,
  2545  		buildsRepo:     mipsBuildsRepoPolicy,
  2546  		env: []string{
  2547  			"GOARCH=mipsle",
  2548  			"GOHOSTARCH=mipsle",
  2549  			"GO_TEST_TIMEOUT_SCALE=4", // inherited from cmd/dist's default for GOARCH=mips{,le,64,64le}
  2550  		},
  2551  	})
  2552  	addBuilder(BuildConfig{
  2553  		FlakyNet:       true,
  2554  		HostType:       "host-linux-mips64-rtrk",
  2555  		Name:           "linux-mips64-rtrk",
  2556  		SkipSnapshot:   true,
  2557  		distTestAdjust: mipsDistTestPolicy,
  2558  		buildsRepo:     mipsBuildsRepoPolicy,
  2559  		env: []string{
  2560  			"GOARCH=mips64",
  2561  			"GOHOSTARCH=mips64",
  2562  			"GO_TEST_TIMEOUT_SCALE=4", // inherited from cmd/dist's default for GOARCH=mips{,le,64,64le}
  2563  		},
  2564  	})
  2565  	addBuilder(BuildConfig{
  2566  		FlakyNet:       true,
  2567  		HostType:       "host-linux-mips64-rtrk",
  2568  		Name:           "linux-mips-rtrk",
  2569  		SkipSnapshot:   true,
  2570  		distTestAdjust: mipsDistTestPolicy,
  2571  		buildsRepo:     mipsBuildsRepoPolicy,
  2572  		env: []string{
  2573  			"GOARCH=mips",
  2574  			"GOHOSTARCH=mips",
  2575  			"GO_TEST_TIMEOUT_SCALE=4", // inherited from cmd/dist's default for GOARCH=mips{,le,64,64le}
  2576  		},
  2577  	})
  2578  	addBuilder(BuildConfig{
  2579  		HostType:       "host-linux-riscv64-joelsing",
  2580  		Name:           "linux-riscv64-jsing",
  2581  		SkipSnapshot:   true,
  2582  		FlakyNet:       true,
  2583  		env:            []string{"GO_TEST_TIMEOUT_SCALE=4"},
  2584  		distTestAdjust: riscvDistTestPolicy,
  2585  		buildsRepo: func(repo, branch, goBranch string) bool {
  2586  			switch repo {
  2587  			case "go", "net", "sys":
  2588  				return branch == "master" && goBranch == "master"
  2589  			default:
  2590  				return false
  2591  			}
  2592  		},
  2593  	})
  2594  	addBuilder(BuildConfig{
  2595  		HostType:       "host-linux-riscv64-unmatched",
  2596  		Name:           "linux-riscv64-unmatched",
  2597  		env:            []string{"GO_TEST_TIMEOUT_SCALE=4"},
  2598  		FlakyNet:       true,
  2599  		distTestAdjust: riscvDistTestPolicy,
  2600  		privateGoProxy: true, // this builder is behind firewall
  2601  		buildsRepo: func(repo, branch, goBranch string) bool {
  2602  			// see https://go.dev/issue/53745
  2603  			if repo == "perf" {
  2604  				return false
  2605  			}
  2606  			return onlyMasterDefault(repo, branch, goBranch)
  2607  		},
  2608  	})
  2609  	addBuilder(BuildConfig{
  2610  		Name:           "linux-s390x-ibm",
  2611  		HostType:       "host-linux-s390x",
  2612  		numTestHelpers: 0,
  2613  		FlakyNet:       true,
  2614  		env:            []string{"GO_TEST_TIMEOUT_SCALE=5"},
  2615  	})
  2616  	addBuilder(BuildConfig{
  2617  		Name:     "linux-s390x-ibm-race",
  2618  		HostType: "host-linux-s390x",
  2619  		Notes:    "Only runs -race tests (./race.bash)",
  2620  		FlakyNet: true,
  2621  		buildsRepo: func(repo, branch, goBranch string) bool {
  2622  			return repo == "go" && goBranch == "master"
  2623  		},
  2624  		env: []string{"GO_TEST_TIMEOUT_SCALE=5"},
  2625  	})
  2626  	addBuilder(BuildConfig{
  2627  		Name:        "linux-s390x-crosscompile",
  2628  		HostType:    "host-linux-amd64-s390x-cross",
  2629  		Notes:       "s390x cross-compile builder for releases; doesn't run tests",
  2630  		CompileOnly: true,
  2631  		tryOnly:     true, // but not in trybot set for now
  2632  		env: []string{
  2633  			"CGO_ENABLED=1",
  2634  			"GOARCH=s390x",
  2635  			"GOHOSTARCH=amd64",
  2636  			"CC_FOR_TARGET=s390x-linux-gnu-gcc",
  2637  		},
  2638  	})
  2639  	addBuilder(BuildConfig{
  2640  		Name:     "linux-amd64-localdev",
  2641  		HostType: "host-linux-amd64-localdev",
  2642  		Notes:    "for localhost development only",
  2643  		tryOnly:  true,
  2644  	})
  2645  	addBuilder(BuildConfig{
  2646  		Name:         "dragonfly-amd64-622",
  2647  		HostType:     "host-dragonfly-amd64-622",
  2648  		Notes:        "DragonFly BSD 6.2.2, running on GCE",
  2649  		SkipSnapshot: true,
  2650  	})
  2651  	addBuilder(BuildConfig{
  2652  		Name:           "freebsd-arm-paulzhol",
  2653  		HostType:       "host-freebsd-arm-paulzhol",
  2654  		distTestAdjust: noTestDirAndNoReboot,
  2655  		SkipSnapshot:   true,
  2656  		FlakyNet:       true,
  2657  		buildsRepo: func(repo, branch, goBranch string) bool {
  2658  			// This was a fragile little machine with limited memory.
  2659  			// Only run a few of the core subrepos for now while
  2660  			// we figure out what's killing it.
  2661  			switch repo {
  2662  			case "go", "sys", "net":
  2663  				return true
  2664  			}
  2665  			return false
  2666  		},
  2667  		env: []string{
  2668  			"GOARM=7",
  2669  			"CGO_ENABLED=1",
  2670  			"GO_TEST_TIMEOUT_SCALE=8", // from builder's local environment as of 2022-12-06
  2671  		},
  2672  	})
  2673  	addBuilder(BuildConfig{
  2674  		Name:     "freebsd-arm64-dmgk",
  2675  		HostType: "host-freebsd-arm64-dmgk",
  2676  	})
  2677  	addBuilder(BuildConfig{
  2678  		Name:           "freebsd-riscv64-unmatched",
  2679  		HostType:       "host-freebsd-riscv64-unmatched",
  2680  		env:            []string{"GO_TEST_TIMEOUT_SCALE=4"},
  2681  		FlakyNet:       true,
  2682  		distTestAdjust: riscvDistTestPolicy,
  2683  		privateGoProxy: true, // this builder is behind firewall
  2684  		SkipSnapshot:   true, // The builder has a slow uplink bandwidth.
  2685  		buildsRepo: func(repo, branch, goBranch string) bool {
  2686  			// see https://go.dev/issue/53745
  2687  			if repo == "perf" {
  2688  				return false
  2689  			}
  2690  			return onlyMasterDefault(repo, branch, goBranch)
  2691  		},
  2692  	})
  2693  	addBuilder(BuildConfig{
  2694  		Name:           "plan9-arm",
  2695  		HostType:       "host-plan9-arm-0intro",
  2696  		distTestAdjust: noTestDirAndNoReboot,
  2697  		buildsRepo:     plan9Default,
  2698  		KnownIssues:    []int{49338},
  2699  		env: []string{
  2700  			"GO_TEST_TIMEOUT_SCALE=3", // from builder's local environment as of 2022-12-06
  2701  		},
  2702  	})
  2703  	addBuilder(BuildConfig{
  2704  		Name:     "plan9-amd64-0intro",
  2705  		HostType: "host-plan9-amd64-0intro",
  2706  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2707  			run = noTestDirAndNoReboot(run, distTest, isNormalTry)
  2708  			switch distTest {
  2709  			case "api",
  2710  				"go_test:cmd/go": // takes over 20 minutes without working SMP
  2711  				return false
  2712  			}
  2713  			return run
  2714  		},
  2715  		buildsRepo:  plan9Default,
  2716  		KnownIssues: []int{49756, 49327},
  2717  	})
  2718  	addBuilder(BuildConfig{
  2719  		Name:     "plan9-386-0intro",
  2720  		HostType: "host-plan9-386-0intro",
  2721  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2722  			run = noTestDirAndNoReboot(run, distTest, isNormalTry)
  2723  			switch distTest {
  2724  			case "api",
  2725  				"go_test:cmd/go": // takes over 20 minutes without working SMP
  2726  				return false
  2727  			}
  2728  			return run
  2729  		},
  2730  		buildsRepo:  plan9Default,
  2731  		KnownIssues: []int{50137, 50878},
  2732  	})
  2733  	addBuilder(BuildConfig{
  2734  		Name:     "aix-ppc64",
  2735  		HostType: "host-aix-ppc64-osuosl",
  2736  		env: []string{
  2737  			"PATH=/opt/freeware/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java7_64/jre/bin:/usr/java7_64/bin",
  2738  		},
  2739  		buildsRepo: func(repo, branch, goBranch string) bool {
  2740  			switch repo {
  2741  			case "vulndb", "vuln", "pkgsite":
  2742  				// vulndb and pkgsite currently use a dependency which does not build cleanly
  2743  				// on aix-ppc64. Until that issue is resolved, skip vulndb on this builder.
  2744  				// (https://go.dev/issue/49218).
  2745  				return false
  2746  			}
  2747  			return buildRepoByDefault(repo)
  2748  		},
  2749  	})
  2750  	addBuilder(BuildConfig{
  2751  		Name:           "linux-amd64-wsl",
  2752  		HostType:       "host-linux-amd64-wsl",
  2753  		Notes:          "Windows 10 WSL2 Ubuntu",
  2754  		FlakyNet:       true,
  2755  		SkipSnapshot:   true, // The builder has a slow uplink bandwidth.
  2756  		privateGoProxy: true, // this builder is behind firewall
  2757  	})
  2758  	addBuilder(BuildConfig{
  2759  		Name:     "linux-amd64-perf",
  2760  		HostType: "host-linux-amd64-perf",
  2761  		Notes:    "Performance testing for linux-amd64",
  2762  		buildsRepo: func(repo, branch, goBranch string) bool {
  2763  			if repo == "benchmarks" {
  2764  				// Benchmark the main Go repo.
  2765  				return true
  2766  			}
  2767  			if repo == "tools" {
  2768  				// Benchmark x/tools.
  2769  				//
  2770  				// When benchmarking subrepos, we ignore the Go
  2771  				// commit and always use the most recent Go
  2772  				// release, meaning we get identical duplicate
  2773  				// runs for each Go commit that runs at the
  2774  				// same subrepo commit.
  2775  				//
  2776  				// Limit to running on release branches since
  2777  				// they have far fewer Go commits than tip,
  2778  				// thus reducing the number of duplicate
  2779  				// runs.
  2780  				return strings.HasPrefix(goBranch, "release-branch.")
  2781  			}
  2782  			return false
  2783  		},
  2784  		RunBench:     true,
  2785  		SkipSnapshot: true,
  2786  	})
  2787  	addBuilder(BuildConfig{
  2788  		Name:       "wasip1-wasm-wazero",
  2789  		HostType:   "host-linux-amd64-wasip1-wasm-wazero",
  2790  		buildsRepo: wasip1Default,
  2791  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2792  			if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
  2793  				// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
  2794  				run = false
  2795  			}
  2796  			return run
  2797  		},
  2798  		numTryTestHelpers: 3,
  2799  		env: []string{
  2800  			"GOOS=wasip1", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
  2801  			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
  2802  			"GO_DISABLE_OUTBOUND_NETWORK=1", "GOWASIRUNTIME=wazero",
  2803  		},
  2804  	})
  2805  	addBuilder(BuildConfig{
  2806  		Name:       "wasip1-wasm-wasmtime",
  2807  		HostType:   "host-linux-amd64-wasip1-wasm-wasmtime",
  2808  		tryBot:     explicitTrySet("go"),
  2809  		buildsRepo: wasip1Default,
  2810  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2811  			if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
  2812  				// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
  2813  				run = false
  2814  			}
  2815  			return run
  2816  		},
  2817  		numTryTestHelpers: 3,
  2818  		env: []string{
  2819  			"GOOS=wasip1", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
  2820  			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
  2821  			"GO_DISABLE_OUTBOUND_NETWORK=1", "GOWASIRUNTIME=wasmtime",
  2822  		},
  2823  	})
  2824  	addBuilder(BuildConfig{
  2825  		Name:        "wasip1-wasm-wasmer",
  2826  		HostType:    "host-linux-amd64-wasip1-wasm-wasmer",
  2827  		KnownIssues: []int{59907},
  2828  		buildsRepo:  wasip1Default,
  2829  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2830  			if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
  2831  				// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
  2832  				run = false
  2833  			}
  2834  			return run
  2835  		},
  2836  		numTryTestHelpers: 3,
  2837  		env: []string{
  2838  			"GOOS=wasip1", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
  2839  			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
  2840  			"GO_DISABLE_OUTBOUND_NETWORK=1", "GOWASIRUNTIME=wasmer",
  2841  		},
  2842  	})
  2843  	addBuilder(BuildConfig{
  2844  		Name:        "wasip1-wasm-wasmedge",
  2845  		HostType:    "host-linux-amd64-wasip1-wasm-wasmedge",
  2846  		KnownIssues: []int{60097},
  2847  		buildsRepo:  wasip1Default,
  2848  		distTestAdjust: func(run bool, distTest string, isNormalTry bool) bool {
  2849  			if isNormalTry && (strings.Contains(distTest, "/internal/") || distTest == "reboot") {
  2850  				// Skip some tests in an attempt to speed up normal trybots, inherited from CL 121938.
  2851  				run = false
  2852  			}
  2853  			return run
  2854  		},
  2855  		numTryTestHelpers: 3,
  2856  		env: []string{
  2857  			"GOOS=wasip1", "GOARCH=wasm", "GOHOSTOS=linux", "GOHOSTARCH=amd64",
  2858  			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workdir/go/misc/wasm",
  2859  			"GO_DISABLE_OUTBOUND_NETWORK=1", "GOWASIRUNTIME=wasmedge",
  2860  		},
  2861  	})
  2862  }
  2863  
  2864  // BuildersPortedToLUCI lists coordinator builders that have been ported
  2865  // over to LUCI and don't need to continue to run. Their results will be
  2866  // hidden from the build.golang.org page and new builds won't be started
  2867  // if stopPortedBuilder (below) returns true.
  2868  //
  2869  // See go.dev/issue/65913
  2870  // and go.dev/issue/63471.
  2871  var BuildersPortedToLUCI = map[string]bool{
  2872  	// macOS builders.
  2873  	"darwin-amd64-10_15":    true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64_10.15.
  2874  	"darwin-amd64-11_0":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64_11.
  2875  	"darwin-amd64-12_0":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64_12.
  2876  	"darwin-amd64-13":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64_13.
  2877  	"darwin-amd64-longtest": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64-longtest.
  2878  	"darwin-amd64-nocgo":    true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-amd64-nocgo.
  2879  	"darwin-arm64-11":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-arm64_11.
  2880  	"darwin-arm64-12":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-darwin-arm64_12.
  2881  
  2882  	// Linux builders (just those covering first-class ports).
  2883  	"linux-386":                     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-386.
  2884  	"linux-386-longtest":            true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-386-longtest.
  2885  	"linux-386-clang":               true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-386-clang15 (a newer clang, but we won't be adding exactly -clang7 to LUCI by now).
  2886  	"linux-386-softfloat":           true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-386-softfloat.
  2887  	"linux-arm-aws":                 true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-arm.
  2888  	"linux-amd64":                   true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64.
  2889  	"linux-amd64-longtest":          true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-longtest.
  2890  	"linux-amd64-race":              true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-race.
  2891  	"linux-amd64-longtest-race":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-longtest-race.
  2892  	"linux-amd64-racecompile":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-racecompile.
  2893  	"linux-amd64-nocgo":             true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-nocgo.
  2894  	"linux-amd64-noopt":             true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-noopt.
  2895  	"linux-amd64-clang":             true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-clang15 (a newer clang, but we won't be adding exactly -clang7 to LUCI by now).
  2896  	"linux-amd64-goamd64v3":         true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-goamd64v3.
  2897  	"linux-amd64-boringcrypto":      true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-boringcrypto.
  2898  	"linux-amd64-ssacheck":          true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-ssacheck.
  2899  	"linux-amd64-staticlockranking": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-staticlockranking.
  2900  	"linux-amd64-newinliner":        true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-amd64-newinliner.
  2901  	"linux-arm64":                   true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-arm64.
  2902  	"linux-arm64-longtest":          true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-arm64-longtest.
  2903  	"linux-arm64-race":              true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-arm64-race.
  2904  	"linux-arm64-boringcrypto":      true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-arm64-boringcrypto.
  2905  
  2906  	// Windows builders.
  2907  	"windows-386-2016":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-windows-386.
  2908  	"windows-amd64-2016":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-windows-amd64.
  2909  	"windows-amd64-longtest": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-windows-amd64-longtest.
  2910  	"windows-amd64-race":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-windows-amd64-race.
  2911  	"windows-arm64-11":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-windows-arm64.
  2912  
  2913  	"linux-riscv64-jsing":     true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-riscv64.
  2914  	"linux-riscv64-unmatched": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-riscv64 (this builder is testing the same port as on the line above).
  2915  
  2916  	"linux-ppc64le-buildlet":   true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-ppc64le_power8.
  2917  	"linux-ppc64le-power9osu":  true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-ppc64le_power9.
  2918  	"linux-ppc64le-power10osu": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-ppc64le_power10.
  2919  	"linux-ppc64-sid-buildlet": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-ppc64_power8.
  2920  	"linux-ppc64-sid-power10":  true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-linux-ppc64_power10.
  2921  
  2922  	"netbsd-arm64-bsiegert": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-netbsd-arm64.
  2923  
  2924  	"openbsd-amd64-72": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-openbsd-amd64.
  2925  
  2926  	"solaris-amd64-oraclerel": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-solaris-amd64.
  2927  
  2928  	// WebAssembly builders.
  2929  	"js-wasm-node18":       true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-js-wasm.
  2930  	"wasip1-wasm-wasmedge": true, // Would be 'wasip1-wasm_wasmedge' but put off until go.dev/issue/60097 picks up activity.
  2931  	"wasip1-wasm-wasmer":   true, // Would be 'wasip1-wasm_wasmer' but put off until go.dev/issue/59907 picks up activity.
  2932  	"wasip1-wasm-wasmtime": true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-wasip1-wasm_wasmtime.
  2933  	"wasip1-wasm-wazero":   true, // Available as https://ci.chromium.org/p/golang/builders/ci/gotip-wasip1-wasm_wazero.
  2934  }
  2935  
  2936  // stopPortedBuilder reports whether the named ported builder should be stopped,
  2937  // instead of just made invisible in the web UI.
  2938  func stopPortedBuilder(builderName string) (stop bool) {
  2939  	return strings.Contains(builderName, "-wasm-") || strings.Contains(builderName, "linux-ppc64")
  2940  }
  2941  
  2942  // addBuilder adds c to the Builders map after doing some checks.
  2943  func addBuilder(c BuildConfig) {
  2944  	if c.Name == "" {
  2945  		panic("empty name")
  2946  	}
  2947  	if c.HostType == "" {
  2948  		panic(fmt.Sprintf("missing HostType for builder %q", c.Name))
  2949  	}
  2950  	if _, dup := Builders[c.Name]; dup {
  2951  		panic("dup name " + c.Name)
  2952  	}
  2953  	if c.HostConfig().GoogleReverse && !c.IsReverse() {
  2954  		panic("GoogleReverse is set but the builder isn't reverse")
  2955  	}
  2956  	if _, ok := Hosts[c.HostType]; !ok {
  2957  		panic(fmt.Sprintf("undefined HostType %q for builder %q", c.HostType, c.Name))
  2958  	}
  2959  	if c.SkipSnapshot && (c.numTestHelpers > 0 || c.numTryTestHelpers > 0) {
  2960  		panic(fmt.Sprintf("config %q's SkipSnapshot is not compatible with sharded test helpers", c.Name))
  2961  	}
  2962  	for i, issue := range c.KnownIssues {
  2963  		if issue == 0 {
  2964  			panic(fmt.Errorf("config %q's KnownIssues slice has a zero issue at index %d", c.Name, i))
  2965  		}
  2966  	}
  2967  
  2968  	types := 0
  2969  	for _, fn := range []func() bool{c.IsReverse, c.IsContainer, c.IsVM} {
  2970  		if fn() {
  2971  			types++
  2972  		}
  2973  	}
  2974  	if types != 1 {
  2975  		panic(fmt.Sprintf("build config %q host type inconsistent (must be Reverse, Image, or VM)", c.Name))
  2976  	}
  2977  
  2978  	if BuildersPortedToLUCI[c.Name] && stopPortedBuilder(c.Name) {
  2979  		c.buildsRepo = func(_, _, _ string) bool { return false }
  2980  		c.Notes = "Unavailable in the coordinator. Use LUCI (https://go.dev/wiki/LUCI) instead."
  2981  	}
  2982  
  2983  	Builders[c.Name] = &c
  2984  }
  2985  
  2986  // tryNewMiscCompile is an intermediate step towards adding a real addMiscCompile TryBot.
  2987  //
  2988  // It adds a post-submit-only builder with KnownIssue, GoDeps set to the provided values,
  2989  // and runs on a limited set of branches to get test results without potential disruption
  2990  // for contributors. It can be modified as needed when onboarding a misc-compile builder.
  2991  func tryNewMiscCompile(goos, goarch, extraSuffix string, knownIssue int, goDeps []string, extraEnv ...string) {
  2992  	if knownIssue == 0 {
  2993  		panic("tryNewMiscCompile: knownIssue parameter must be non-zero")
  2994  	}
  2995  	platform := goos + "-" + goarch + extraSuffix
  2996  	addBuilder(BuildConfig{
  2997  		Name:         "misc-compile-" + platform,
  2998  		HostType:     "host-linux-amd64-bullseye",
  2999  		buildsRepo:   miscCompileBuildSet(goos, goarch),
  3000  		KnownIssues:  []int{knownIssue},
  3001  		GoDeps:       goDeps,
  3002  		env:          append(extraEnv, "GOOS="+goos, "GOARCH="+goarch, "GO_DISABLE_OUTBOUND_NETWORK=1"),
  3003  		CompileOnly:  true,
  3004  		SkipSnapshot: true,
  3005  		Notes:        fmt.Sprintf("Tries make.bash (or compile-only go test) for "+platform+" See go.dev/issue/%d.", knownIssue),
  3006  	})
  3007  }
  3008  
  3009  // fasterTrybots is a distTestAdjust policy function.
  3010  // It skips (returns false) the test/ directory and reboot tests for trybots.
  3011  func fasterTrybots(run bool, distTest string, isNormalTry bool) bool {
  3012  	if isNormalTry {
  3013  		if strings.HasPrefix(distTest, "test:") || distTest == "reboot" {
  3014  			return false // skip test
  3015  		}
  3016  	}
  3017  	return run
  3018  }
  3019  
  3020  // noTestDirAndNoReboot is a distTestAdjust policy function.
  3021  // It skips (returns false) the test/ directory and reboot tests for all builds.
  3022  func noTestDirAndNoReboot(run bool, distTest string, isNormalTry bool) bool {
  3023  	if strings.HasPrefix(distTest, "test:") || distTest == "reboot" {
  3024  		return false // skip test
  3025  	}
  3026  	return run
  3027  }
  3028  
  3029  // ppc64DistTestPolicy is a distTestAdjust policy function
  3030  // that's shared by linux-ppc64le, -ppc64le-power{9,10}-osu, and -ppc64.
  3031  func ppc64DistTestPolicy(run bool, distTest string, isNormalTry bool) bool {
  3032  	if distTest == "reboot" {
  3033  		// Skip test. It seems to use a lot of memory?
  3034  		// See https://go.dev/issue/35233.
  3035  		return false
  3036  	}
  3037  	return run
  3038  }
  3039  
  3040  // mipsDistTestPolicy is a distTestAdjust policy function
  3041  // that's shared by the slow mips builders.
  3042  func mipsDistTestPolicy(run bool, distTest string, isNormalTry bool) bool {
  3043  	switch distTest {
  3044  	case "api", "reboot":
  3045  		return false
  3046  	}
  3047  	return run
  3048  }
  3049  
  3050  // mipsBuildsRepoPolicy is a buildsRepo policy function
  3051  // that's shared by the slow mips builders.
  3052  func mipsBuildsRepoPolicy(repo, branch, goBranch string) bool {
  3053  	switch repo {
  3054  	case "go", "net", "sys":
  3055  		return branch == "master" && goBranch == "master"
  3056  	default:
  3057  		return false
  3058  	}
  3059  }
  3060  
  3061  // riscvDistTestPolicy is same as mipsDistTestPolicy for now.
  3062  var riscvDistTestPolicy = mipsDistTestPolicy
  3063  
  3064  // TryBuildersForProject returns the builders that should run as part of
  3065  // a TryBot set for the given project.
  3066  // The project argument is of the form "go", "net", "sys", etc.
  3067  // The branch is the branch of that project ("master", "release-branch.go1.12", etc)
  3068  // The goBranch is the branch of Go to use. If proj == "go", then branch == goBranch.
  3069  func TryBuildersForProject(proj, branch, goBranch string) []*BuildConfig {
  3070  	return buildersForProject(proj, branch, goBranch, (*BuildConfig).BuildsRepoTryBot)
  3071  }
  3072  
  3073  // isBuilderFunc is the type of functions that report whether a builder
  3074  // should be run given a project, branch and goBranch.
  3075  type isBuilderFunc func(conf *BuildConfig, proj, branch, goBranch string) bool
  3076  
  3077  // buildersForProject returns the builders that should be run for the given project,
  3078  // using isBuilder to test each builder.
  3079  // See TryBuildersForProject for the valid forms of proj, branch and goBranch.
  3080  func buildersForProject(proj, branch, goBranch string, isBuilder isBuilderFunc) []*BuildConfig {
  3081  	var confs []*BuildConfig
  3082  	for _, conf := range Builders {
  3083  		if isBuilder(conf, proj, branch, goBranch) {
  3084  			confs = append(confs, conf)
  3085  		}
  3086  	}
  3087  	sort.Slice(confs, func(i, j int) bool {
  3088  		return confs[i].Name < confs[j].Name
  3089  	})
  3090  	return confs
  3091  }
  3092  
  3093  // atLeastGo1 reports whether branch is "release-branch.go1.N" where N >= min.
  3094  // It assumes "master" and "dev.*" branches are already greater than min, and
  3095  // always includes them.
  3096  func atLeastGo1(branch string, min int) bool {
  3097  	if branch == "master" {
  3098  		return true
  3099  	}
  3100  	if strings.HasPrefix(branch, "dev.") {
  3101  		// Treat dev branches current.
  3102  		// If a dev branch is active, it will be current.
  3103  		// If it is not active, it doesn't matter anyway.
  3104  		// TODO: dev.boringcrypto.go1.N branches may be the
  3105  		// exception. Currently we only build boringcrypto
  3106  		// on linux/amd64 and windows/386, which support all
  3107  		// versions of Go, so it doesn't actually matter.
  3108  		return true
  3109  	}
  3110  	major, minor, ok := version.ParseReleaseBranch(branch)
  3111  	return ok && major == 1 && minor >= min
  3112  }
  3113  
  3114  // atMostGo1 reports whether branch is "release-branch.go1.N" where N <= max.
  3115  // It assumes "master" branch is already greater than max, and doesn't include it.
  3116  func atMostGo1(branch string, max int) bool {
  3117  	major, minor, ok := version.ParseReleaseBranch(branch)
  3118  	return ok && major == 1 && minor <= max
  3119  }
  3120  
  3121  // onlyGo is a common buildsRepo policy value that only builds the main "go" repo.
  3122  func onlyGo(repo, branch, goBranch string) bool { return repo == "go" }
  3123  
  3124  // onlyMasterDefault is a common buildsRepo policy value that only builds
  3125  // default repos on the master branch.
  3126  func onlyMasterDefault(repo, branch, goBranch string) bool {
  3127  	return branch == "master" && goBranch == "master" && buildRepoByDefault(repo)
  3128  }
  3129  
  3130  // plan9Default is like onlyMasterDefault, but also omits repos that are
  3131  // both filesystem-intensive and unlikely to be relevant to plan9 users.
  3132  func plan9Default(repo, branch, goBranch string) bool {
  3133  	switch repo {
  3134  	case "benchmarks":
  3135  		// Failure to build because of a dependency not supported on plan9.
  3136  		return false
  3137  	case "review":
  3138  		// The x/review repo tests a Git hook, but the plan9 "git" doesn't have the
  3139  		// same command-line API as "git" everywhere else.
  3140  		return false
  3141  	case "website":
  3142  		// The x/website tests read and check the website code snippets,
  3143  		// which require many filesystem walk and read operations.
  3144  		return false
  3145  	case "vulndb", "vuln":
  3146  		// vulncheck can't read plan9 binaries.
  3147  		return false
  3148  	case "pkgsite":
  3149  		// pkgsite has a dependency (github.com/lib/pq) that is broken on Plan 9.
  3150  		return false
  3151  	default:
  3152  		return onlyMasterDefault(repo, branch, goBranch)
  3153  	}
  3154  }
  3155  
  3156  // wasip1Default returns whether we should build the repo and branch on wasip1.
  3157  func wasip1Default(repo, branch, goBranch string) bool {
  3158  	b := buildRepoByDefault(repo) && atLeastGo1(goBranch, 21)
  3159  	switch repo {
  3160  	case "benchmarks", "debug", "perf", "pkgsite", "talks", "tools", "tour", "website":
  3161  		// Don't test these golang.org/x repos.
  3162  		b = false
  3163  	}
  3164  	if repo != "go" && !(branch == "master" && goBranch == "master") {
  3165  		// For golang.org/x repos, don't test non-latest versions.
  3166  		b = false
  3167  	}
  3168  	return b
  3169  }
  3170  
  3171  // disabledBuilder is a buildsRepo policy function that always return false.
  3172  func disabledBuilder(repo, branch, goBranch string) bool { return false }
  3173  
  3174  // macTestPolicy is the test policy for Macs.
  3175  //
  3176  // We have limited Mac resources. It's not worth wasting time testing
  3177  // portable things on them. That is, if there's a slow test that will
  3178  // still fail slowly on another builder where we have more resources
  3179  // (like linux-amd64), then there's no point testing it redundantly on
  3180  // the Macs.
  3181  func macTestPolicy(run bool, distTest string, isNormalTry bool) bool {
  3182  	if strings.HasPrefix(distTest, "test:") {
  3183  		return false
  3184  	}
  3185  	switch distTest {
  3186  	case "reboot", "api", "doc_progs",
  3187  		"wiki", "bench_go1", "codewalk":
  3188  		return false
  3189  	}
  3190  	if isNormalTry {
  3191  		switch distTest {
  3192  		case "runtime:cpu124", "race", "moved_goroot":
  3193  			return false
  3194  		}
  3195  		// TODO: more. Look at bigquery results once we have more data.
  3196  	}
  3197  	return run
  3198  }