build: link dynamically by default; add static fallback#3196
Draft
gnurizen wants to merge 1 commit into
Draft
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch the default
make build(andbuild-debug) to dynamic linking, and addbuild-staticfor a fully-static binary via anonvmlbuild 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-statickeeps 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).