Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

ci(otel-gpu-collector): enable CGO for linux release binaries (#1224)

Aman Agarwal2aca45310e0c
diff --git a/.github/workflows/otel-gpu-collector-release.yml b/.github/workflows/otel-gpu-collector-release.yml
index 3eb8abdd..e752bd2d 100644
--- a/.github/workflows/otel-gpu-collector-release.yml
+++ b/.github/workflows/otel-gpu-collector-release.yml
@@ -88,6 +88,16 @@ jobs:
| sudo tar -xz -C /usr/local/bin/
sudo chmod +x /usr/local/bin/bpftool
+ # NVIDIA NVML (github.com/NVIDIA/go-nvml) uses cgo+dlopen to load
+ # libnvidia-ml.so at runtime, so the linux release binaries must be built
+ # with CGO_ENABLED=1. Cross-compiling linux/arm64 from an amd64 runner
+ # additionally needs an aarch64 C toolchain.
+ - name: Install aarch64 cross-compiler (linux/arm64 only)
+ if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
+ run: |
+ sudo apt-get update -q
+ sudo apt-get install --no-install-recommends -y gcc-aarch64-linux-gnu
+
- name: Generate eBPF objects (linux targets only)
if: matrix.goos == 'linux'
working-directory: opentelemetry-gpu-collector
@@ -103,7 +113,10 @@ jobs:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
- CGO_ENABLED: "0"
+ # Linux ships NVML via go-nvml (cgo+dlopen); darwin/windows have no
+ # NVML at all and fall through to the stub, so CGO is unnecessary.
+ CGO_ENABLED: ${{ matrix.goos == 'linux' && '1' || '0' }}
+ CC: ${{ (matrix.goos == 'linux' && matrix.goarch == 'arm64') && 'aarch64-linux-gnu-gcc' || '' }}
run: |
OUTPUT="${{ env.BINARY_NAME }}-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('-armv{0}', matrix.goarm) || '' }}${{ matrix.ext }}"
go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.version }}" \