From 53cc2a2460e2b1253e01720bb4e094c6b5da4e75 Mon Sep 17 00:00:00 2001 From: peterschmidt85 Date: Tue, 11 Nov 2025 08:48:32 +0100 Subject: [PATCH 1/2] [runner] Allow to compile runner on macOS (for development purposes only) --- runner/.justfile | 7 ++++++- runner/internal/shim/dcgm/wrapper_linux.go | 2 +- runner/internal/shim/dcgm/wrapper_linux_nocgo.go | 9 +++++++++ runner/internal/shim/dcgm/wrapper_linux_test.go | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 runner/internal/shim/dcgm/wrapper_linux_nocgo.go diff --git a/runner/.justfile b/runner/.justfile index 80e2ee114..9997a5016 100644 --- a/runner/.justfile +++ b/runner/.justfile @@ -56,7 +56,12 @@ build-shim-binary: cd {{source_directory()}}/cmd/shim if [ -n "$shim_os" ] && [ -n "$shim_arch" ]; then echo "Building shim for $shim_os/$shim_arch" - GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" + if [ "$shim_os" = "linux" ] && [ "$(uname -s)" != "Linux" ]; then + echo "WARNING: Cross-compiling to Linux, disabling CGO (DCGM unavailable)" + CGO_ENABLED=0 GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" + else + GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" + fi else echo "Building shim for current platform" go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" diff --git a/runner/internal/shim/dcgm/wrapper_linux.go b/runner/internal/shim/dcgm/wrapper_linux.go index 23d9ad5b4..359d374ea 100644 --- a/runner/internal/shim/dcgm/wrapper_linux.go +++ b/runner/internal/shim/dcgm/wrapper_linux.go @@ -1,4 +1,4 @@ -//go:build linux +//go:build linux && cgo package dcgm diff --git a/runner/internal/shim/dcgm/wrapper_linux_nocgo.go b/runner/internal/shim/dcgm/wrapper_linux_nocgo.go new file mode 100644 index 000000000..60c97e49e --- /dev/null +++ b/runner/internal/shim/dcgm/wrapper_linux_nocgo.go @@ -0,0 +1,9 @@ +//go:build linux && !cgo + +package dcgm + +import "fmt" + +func NewDCGMWrapper(address string) (DCGMWrapperInterface, error) { + return nil, fmt.Errorf("DCGM unavailable: built with CGO disabled (cross-compilation)") +} diff --git a/runner/internal/shim/dcgm/wrapper_linux_test.go b/runner/internal/shim/dcgm/wrapper_linux_test.go index 93cb61055..20fc4d59a 100644 --- a/runner/internal/shim/dcgm/wrapper_linux_test.go +++ b/runner/internal/shim/dcgm/wrapper_linux_test.go @@ -1,4 +1,4 @@ -//go:build linux +//go:build linux && cgo package dcgm From 7a8b63fab5ba98e8aa824dac9a078e12bca3269f Mon Sep 17 00:00:00 2001 From: peterschmidt85 Date: Wed, 12 Nov 2025 14:19:14 +0100 Subject: [PATCH 2/2] [runner] Allow to compile runner on macOS (for development purposes only) PR review --- runner/.justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runner/.justfile b/runner/.justfile index 9997a5016..2dd452de2 100644 --- a/runner/.justfile +++ b/runner/.justfile @@ -45,7 +45,7 @@ build-runner-binary: #!/usr/bin/env bash set -e echo "Building runner for linux/amd64" - cd {{source_directory()}}/cmd/runner && GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" + cd {{source_directory()}}/cmd/runner && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" echo "Runner build complete!" # Build shim @@ -60,7 +60,7 @@ build-shim-binary: echo "WARNING: Cross-compiling to Linux, disabling CGO (DCGM unavailable)" CGO_ENABLED=0 GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" else - GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version' -extldflags '-static'" + CGO_ENABLED=1 GOOS=$shim_os GOARCH=$shim_arch go build -ldflags "-X 'main.Version=$version'" fi else echo "Building shim for current platform"