Skip to content

build: link dynamically by default; add static fallback#3196

Draft
gnurizen wants to merge 1 commit into
mainfrom
build-dynamic
Draft

build: link dynamically by default; add static fallback#3196
gnurizen wants to merge 1 commit into
mainfrom
build-dynamic

Conversation

@gnurizen

Copy link
Copy Markdown
Contributor

Switch the default make build (and build-debug) to dynamic linking, and add build-static for a fully-static binary via a nonvml build tag.

Why: enables cgo features that dlopen shared libs at runtime (NVML for GPU metrics, follow-up) — go-nvml binds NULL and crashes in a fully-static binary. build-static keeps a run-anywhere binary (musl/scratch/chainguard/static) with such features compiled out.

Open question for reviewers: this flips the default from static→dynamic, so pipelines/images targeting musl/static must switch to make build-static. Alternative is to keep static as the default and make the dynamic build the opt-in target. Draft pending that call (and the matching Dockerfile/CI change).

Switch the default build (and build-debug) to dynamic linking, and add a
build-static target for a fully-static binary.

parca-agent is moving toward cgo-based features that dlopen shared
libraries at runtime (e.g. NVML for GPU metrics). go-nvml relies on the
dynamic linker resolving libnvidia-ml symbols via an RTLD_GLOBAL dlopen,
which a fully-static binary binds to NULL at link time and crashes on
first call. So the default binary is now dynamically linked.

build-static keeps producing a fully-static, run-anywhere binary via the
"nonvml" build tag, which excludes any such cgo features (today: NVML).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant