build: keep the NVML -L out of LDFLAGS - #18
Merged
Conversation
LDFLAGS is a user variable. A value passed on the command line, or exported by a packaging system such as dpkg-buildflags or rpm's build flags, replaces the makefile's `LDFLAGS +=` and takes the NVML -L with it, so the link fails on exactly the layouts the lookup was added for (Debian keeps libnvidia-ml.so.1 in /usr/lib/<triplet>/nvidia/current, which only ld.so searches). Hold the flag in NVML_LDFLAGS and put it in LIBS, which is not a user variable, so a caller-supplied LDFLAGS composes with it instead of replacing it. test_makefile_nvml_detection.sh now asserts on NVML_LDFLAGS, which also stops an exported LDFLAGS from failing `make check`.
ricky-chaoju
force-pushed
the
fix/nvml-ldflags-override
branch
from
September 5, 2026 05:19
8234606 to
ce698f9
Compare
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.
LDFLAGSis a user variable, so folding the NVML-Linto it (added in #15) means a caller-supplied value replaces it.make LDFLAGS="-Wl,-z,now"— roughly what dpkg-buildflags and rpm's build flags do — drops the-L, and the link then fails on exactly the layout the lookup was added for: Debian keepslibnvidia-ml.so.1in/usr/lib/<triplet>/nvidia/current, which onlyld.sosearches, notld. An exportedLDFLAGSalso failsmake check, becausetest_makefile_nvml_detection.shcompares the whole variable.This moves the flag into
NVML_LDFLAGSand puts it inLIBS, which is not a user variable, so a caller'sLDFLAGScomposes with it instead of replacing it. The test now asserts onNVML_LDFLAGS.Verified in a container reproducing the Debian layout (driver library only in
nvidia/current, registered viald.so.conf):makemake LDFLAGS="-Wl,-z,now"-Lon the link line-LkeptLDFLAGS="-Wl,-z,now" make checkmake NVML_LIBDIR=...make check,make -j4,scripts/install.shAlso rebuilt on the standard layout (Ubuntu 26.04, driver 595.84):
make,make checkandnvfd listagainst a real RTX 5090 all fine.