8
8
// developed and tested locally, the stage0 instead looks for the
9
9
// META_BUILDLET_BINARY_URL environment to have a URL to the buildlet
10
10
// binary.
11
+ //
12
+ // The stage0 binary is typically baked into the VM or container
13
+ // images or manually copied to dedicated once and is typically never
14
+ // auto-updated. Changes to this binary should be rare, as it's
15
+ // difficult and slow to roll out. Any per-host-type logic to do at
16
+ // start-up should be done in x/build/cmd/buildlet instead, which is
17
+ // re-downloaded once per build, and rolls out easily.
11
18
package main
12
19
13
20
import (
@@ -125,12 +132,20 @@ func main() {
125
132
cmd .Stdout = os .Stdout
126
133
cmd .Stderr = os .Stderr
127
134
cmd .Env = env
128
- switch buildenv := os .Getenv ("GO_BUILDER_ENV" ); buildenv {
135
+
136
+ // buildEnv is set by some builders. It's increasingly set by new ones.
137
+ // It predates the buildtype-vs-hosttype split, so the values aren't
138
+ // always host types, but they're often host types. They should probably
139
+ // be host types in the future, or we can introduce GO_BUILD_HOST_TYPE
140
+ // to be explicit and kill off GO_BUILDER_ENV.
141
+ buildEnv := os .Getenv ("GO_BUILDER_ENV" )
142
+
143
+ switch buildEnv {
129
144
case "linux-arm-arm5spacemonkey" :
130
- cmd .Args = append (cmd .Args , legacyReverseBuildletArgs ( buildenv )... )
145
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs ( "host-linux-arm5spacemonkey" )... )
131
146
case "host-linux-arm-scaleway" :
132
147
scalewayArgs := append (
133
- legacyReverseBuildletArgs ( buildenv ),
148
+ reverseHostTypeArgs ( buildEnv ),
134
149
"--hostname=" + os .Getenv ("HOSTNAME" ),
135
150
)
136
151
cmd .Args = append (cmd .Args ,
@@ -140,13 +155,13 @@ func main() {
140
155
switch osArch {
141
156
case "linux/s390x" :
142
157
cmd .Args = append (cmd .Args , "--workdir=/data/golang/workdir" )
143
- cmd .Args = append (cmd .Args , legacyReverseBuildletArgs ( " linux-s390x-ibm " )... )
158
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs ( "host- linux-s390x" )... )
144
159
case "linux/arm64" :
145
- switch v := os . Getenv ( "GO_BUILDER_ENV" ); v {
160
+ switch buildEnv {
146
161
case "host-linux-arm64-packet" , "host-linux-arm64-linaro" :
147
162
hostname := os .Getenv ("HOSTNAME" ) // if empty, docker container name is used
148
163
cmd .Args = append (cmd .Args ,
149
- "--reverse-type=" + v ,
164
+ "--reverse-type=" + buildEnv ,
150
165
"--workdir=/workdir" ,
151
166
"--hostname=" + hostname ,
152
167
"--halt=false" ,
@@ -157,11 +172,23 @@ func main() {
157
172
panic (fmt .Sprintf ("unknown/unspecified $GO_BUILDER_ENV value %q" , env ))
158
173
}
159
174
case "linux/ppc64" :
160
- cmd .Args = append (cmd .Args , legacyReverseBuildletArgs ("linux-ppc64-buildlet" )... )
175
+ // Assume OSU (osuosl.org) host type for now. If we get more, use
176
+ // GO_BUILD_HOST_TYPE (see above) and check that.
177
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs ("host-linux-ppc64-osu" )... )
161
178
case "linux/ppc64le" :
162
- cmd .Args = append (cmd .Args , legacyReverseBuildletArgs ("linux-ppc64le-buildlet" )... )
179
+ // Assume OSU (osuosl.org) host type for now. If we get more, use
180
+ // GO_BUILD_HOST_TYPE (see above) and check that.
181
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs ("host-linux-ppc64le-osu" )... )
163
182
case "solaris/amd64" :
164
- cmd .Args = append (cmd .Args , legacyReverseBuildletArgs ("solaris-amd64-smartosbuildlet" )... )
183
+ if buildEnv != "" {
184
+ // Explicit value given. Treat it like a host type.
185
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs (buildEnv )... )
186
+ } else {
187
+ // If there's no value, assume it's the old Joyent builders,
188
+ // which are currently GOOS=solaris, but will be illumos after
189
+ // golang.org/issue/20603.
190
+ cmd .Args = append (cmd .Args , reverseHostTypeArgs ("host-solaris-amd64" )... )
191
+ }
165
192
}
166
193
// Release the serial port (if we opened it) so the buildlet
167
194
// process can open & write to it. At least on Windows, only
@@ -177,12 +204,13 @@ func main() {
177
204
}
178
205
}
179
206
180
- // legacyReverseBuildletArgs passes builder as the deprecated --reverse flag.
181
- // New code should use --reverse-type instead.
182
- func legacyReverseBuildletArgs (builder string ) []string {
207
+ // reverseHostTypeArgs returns the default arguments for the buildlet
208
+ // for the provided host type. (one of the keys of the
209
+ // x/build/dashboard.Hosts map)
210
+ func reverseHostTypeArgs (hostType string ) []string {
183
211
return []string {
184
212
"--halt=false" ,
185
- "--reverse=" + builder ,
213
+ "--reverse-type =" + hostType ,
186
214
"--coordinator=farmer.golang.org:443" ,
187
215
}
188
216
}
0 commit comments