Skip to content

Commit 687b2c6

Browse files
committed
[ci] aarch64 cross-compilation still broken with non-gold linkers
1 parent 5b11b7f commit 687b2c6

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

ci/main.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ import (
2727

2828
type ApoxyCli struct{}
2929

30-
func hostArch() string {
31-
switch runtime.GOARCH {
30+
func canonArchFromGoArch(goarch string) string {
31+
switch goarch {
3232
case "amd64":
3333
return "x86_64"
3434
case "arm64":
3535
return "aarch64"
3636
default:
37-
return runtime.GOARCH
37+
return goarch
3838
}
3939
}
4040

41+
func hostArch() string {
42+
return canonArchFromGoArch(runtime.GOARCH)
43+
}
44+
4145
// BuilderContainer builds a CLI binary.
4246
func (m *ApoxyCli) BuilderContainer(ctx context.Context, src *dagger.Directory) *dagger.Container {
4347
return dag.Container().
@@ -192,10 +196,17 @@ func (m *ApoxyCli) BuildBackplane(
192196
WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod-"+goarch)).
193197
WithEnvVariable("GOMODCACHE", "/go/pkg/mod").
194198
WithMountedCache("/go/build-cache", dag.CacheVolume("go-build-"+goarch)).
195-
WithEnvVariable("GOCACHE", "/go/build-cache").
196-
WithEnvVariable("CGO_ENABLED", "1").
197-
WithExec([]string{"go", "build", "-o", bpOut, "./cmd/backplane"}).
198-
WithExec([]string{"go", "build", "-o", dsOut, "./cmd/dial-stdio"})
199+
WithEnvVariable("GOCACHE", "/go/build-cache")
200+
201+
if goarch == "amd64" {
202+
builder = builder.
203+
WithEnvVariable("CGO_ENABLED", "1").
204+
WithEnvVariable("CC", fmt.Sprintf("zig cc --target=%s-linux-musl", canonArchFromGoArch(goarch)))
205+
}
206+
207+
builder = builder.
208+
WithExec([]string{"go", "build", "-ldflags", "-v -linkmode=external", "-o", bpOut, "./cmd/backplane"}).
209+
WithExec([]string{"go", "build", "-ldflags", "-v -linkmode=external", "-o", dsOut, "./cmd/dial-stdio"})
199210

200211
runtimeCtr := m.PullEdgeRuntime(ctx, platform)
201212

@@ -229,7 +240,10 @@ func (m *ApoxyCli) PublishImages(
229240
fmt.Println("API server image published to", addr)
230241

231242
var bCtrs []*dagger.Container
232-
for _, platform := range []string{"linux/amd64", "linux/arm64"} {
243+
// TODO(dilyevsky): When Go team finally gets around fixing their
244+
// https://github.com/golang/go/issues/22040 hack, we can enable arm64
245+
// builds in CI.
246+
for _, platform := range []string{"linux/amd64" /* "linux/arm64", */} {
233247
bCtr := m.BuildBackplane(ctx, src, platform)
234248
bCtrs = append(bCtrs, bCtr)
235249
}

0 commit comments

Comments
 (0)