CI: Windows builds with CGO cross-compiler toolchain (#112922)

* CI: Windows builds with CGO cross-compiler toolchain

* fix comments
This commit is contained in:
Kevin Minehart
2025-10-24 09:23:14 +00:00
committed by GitHub
parent 4bdee91501
commit e7a49fc472
2 changed files with 23 additions and 5 deletions
+5 -3
View File
@@ -105,8 +105,8 @@ func GolangContainer(
opts *BuildOpts,
) (*dagger.Container, error) {
os, _ := OSAndArch(distro)
// Only use viceroy for all darwin and only windows/amd64
if opts.CGOEnabled && (os == "darwin" || distro == DistWindowsAMD64) {
// Only use viceroy for all darwin builds
if opts.CGOEnabled && os == "darwin" {
return ViceroyContainer(d, log, distro, goVersion, viceroyVersion, opts)
}
@@ -125,7 +125,9 @@ func GolangContainer(
WithExec([]string{"wget", "-q", "https://dl.grafana.com/ci/s390x-linux-musl-cross.tgz", "-P", "/toolchain"}).
WithExec([]string{"tar", "-xf", "/toolchain/s390x-linux-musl-cross.tgz", "-C", "/toolchain"}).
WithExec([]string{"wget", "-q", "https://dl.grafana.com/ci/riscv64-linux-musl-cross.tgz", "-P", "/toolchain"}).
WithExec([]string{"tar", "-xf", "/toolchain/riscv64-linux-musl-cross.tgz", "-C", "/toolchain"})
WithExec([]string{"tar", "-xf", "/toolchain/riscv64-linux-musl-cross.tgz", "-C", "/toolchain"}).
WithExec([]string{"wget", "-q", "https://dl.grafana.com/ci/x86_64-w64-mingw32-cross.tgz", "-P", "/toolchain"}).
WithExec([]string{"tar", "-xf", "/toolchain/x86_64-w64-mingw32-cross.tgz", "-C", "/toolchain"})
}
return WithGoEnv(log, container, distro, opts)
}
+18 -2
View File
@@ -264,7 +264,7 @@ func BuildOptsStaticS390X(distro Distribution, experiments []string, tags []stri
}
}
// BuildOptsStaticS390X builds Grafana statically for the s390x arch
// BuildOptsStaticRiscv64 builds Grafana statically for the riscv64 arch
func BuildOptsStaticRiscv64(distro Distribution, experiments []string, tags []string) *GoBuildOpts {
var (
os, _ = OSAndArch(distro)
@@ -280,6 +280,22 @@ func BuildOptsStaticRiscv64(distro Distribution, experiments []string, tags []st
}
}
// BuildOptsStaticWindows builds Grafana statically for Windows on amd64
func BuildOptsStaticWindows(distro Distribution, experiments []string, tags []string) *GoBuildOpts {
var (
os, _ = OSAndArch(distro)
)
return &GoBuildOpts{
CC: "/toolchain/x86_64-w64-mingw32-cross/bin/x86_64-w64-mingw32-gcc",
CXX: "/toolchain/x86_64-w64-mingw32-cross/bin/x86_64-w64-mingw32-cpp",
ExperimentalFlags: experiments,
OS: os,
Arch: "amd64",
CGOEnabled: true,
}
}
func StdZigBuildOpts(distro Distribution, experiments []string, tags []string) *GoBuildOpts {
var (
os, arch = OSAndArch(distro)
@@ -364,7 +380,7 @@ var DistributionGoOpts = map[Distribution]DistroBuildOptsFunc{
// Non-Linux distros can have whatever they want in CC and CXX; it'll get overridden
// but it's probably not best to rely on that.
DistWindowsAMD64: ViceroyBuildOpts,
DistWindowsAMD64: BuildOptsStaticWindows,
DistWindowsARM64: StdZigBuildOpts,
DistDarwinAMD64: ViceroyBuildOpts,
DistDarwinARM64: ViceroyBuildOpts,