Skip to content

Makefile: name the missing library instead of stopping at cannot find -lnvfm - #20

Open
100milliongold wants to merge 1 commit into
NVIDIA:mainfrom
100milliongold:fix/makefile-report-missing-libnvfm
Open

Makefile: name the missing library instead of stopping at cannot find -lnvfm#20
100milliongold wants to merge 1 commit into
NVIDIA:mainfrom
100milliongold:fix/makefile-report-missing-libnvfm

Conversation

@100milliongold

Copy link
Copy Markdown

Problem

When libnvfm is not usable, the build stops at the linker:

cannot find -lnvfm

That message covers three different situations and distinguishes none of them:

  1. The Fabric Manager development package is not installed.
  2. It is installed somewhere the linker does not search.
  3. It is installed, but ships libnvfm.so as a symlink to a libnvfm.so.1 that was never packaged.

The third is what people hit on Ubuntu 24.04 today. Every nvidia-fabricmanager-dev package built from Source: nvidia-fabricmanager in the CUDA ubuntu2404 repository — the newest, 610.57.04, included — installs the symlink without the library behind it. ls shows a libnvfm.so in the expected place and dpkg -L lists it, so the package looks correctly installed and the linker error looks like a mistake in the build. Details and the full version table are in #19.

Change

Two files, 60 lines added, nothing removed.

Makefile — before linking, look for libnvfm.so across the usual library directories and stop with a message that names what is actually wrong. When the library is present the recipe behaves exactly as it did before.

The directory list is a variable, so an installation outside the system paths can be pointed at:

make NVFM_LIB_DIRS=/opt/nvidia/lib

README.md — a note in the build prerequisites covering the packaging problem, the dpkg -c command that identifies an affected package without installing it, and the workaround.

Output

Nothing installed:

Makefile: libnvfm.so was not found in any of: /usr/lib/x86_64-linux-gnu ...
Makefile: Install the Fabric Manager development package: nvidia-fabricmanager-dev on Ubuntu,
Makefile: nvidia-fabricmanager-devel on RHEL. If it is already installed elsewhere, say where:
Makefile:   make NVFM_LIB_DIRS=/path/to/lib

Symlink with nothing behind it:

Makefile: /usr/lib/x86_64-linux-gnu/libnvfm.so is a symlink to libnvfm.so.1, which is not installed.
Makefile: The Fabric Manager development package here ships the linker symlink without the
Makefile: library it names, so -lnvfm cannot resolve. Confirm with:
Makefile:   dpkg -c nvidia-fabricmanager-dev_<version>.deb | grep libnvfm
Makefile: A version-suffixed package such as nvidia-fabricmanager-dev-575 carries libnvfm.so.1.

Implementation notes

  • The check is plain POSIX shell inside the link recipe. It uses no GNU-make functions, so it adds no requirement the project did not already have.
  • test -e follows symlinks and test -L does not. Together they separate "nothing installed" from "symlink with no target", which is the distinction this packaging bug turns on.
  • The search stops at the first directory holding a libnvfm.so entry and reports on that one, rather than skipping a broken entry to find a good one further along. ld takes the first match in its own search order and fails there, so continuing past a broken symlink would report success on a build that then fails.
  • The check does not modify LDFLAGS or add -L paths. It reports and stops; it does not try to repair the link line. It also does not read LDIR, which names a single fixed directory and is not the set of paths ld actually searches.
  • Headers are not checked. A missing nv_fm_agent.h already produces a compile error that names the file; cannot find -lnvfm is the one that does not say why.
  • Because the check lives in the link recipe, make clean is unaffected and an up-to-date fmpm is still not relinked.

Verification

Tested with GNU Make 3.81 and GNU Make 4.4.1, against three fixture directories: one holding libnvfm.so.1 plus the libnvfm.so symlink, one holding only the dangling symlink, and one empty.

mkdir -p t/present t/dangling t/absent
: > t/present/libnvfm.so.1 && ln -s libnvfm.so.1 t/present/libnvfm.so
ln -s libnvfm.so.1 t/dangling/libnvfm.so

: > fmpm.o && touch fmpm.o     # skip the compile, exercise the link recipe

make fmpm NVFM_LIB_DIRS=t/absent      # -> "was not found in any of", exit 1
make fmpm NVFM_LIB_DIRS=t/dangling    # -> "is a symlink to libnvfm.so.1", exit 1
make fmpm NVFM_LIB_DIRS=t/present     # -> check silent, g++ runs

Also confirmed:

Case Result
libnvfm.so as a real file, not a symlink check passes, g++ runs
NVFM_LIB_DIRS="t/dangling t/present" reports the dangling one, matching ld
NVFM_LIB_DIRS="t/absent t/present" check passes, g++ runs
default NVFM_LIB_DIRS, no override list expands and is searched
make clean exit 0, files removed, check not run
fmpm newer than fmpm.o 'fmpm' is up to date, no relink

The expanded recipe was extracted with make -n and passes sh -n, bash -n and zsh -n, and running it under sh reproduces all three verdicts with exit codes 1, 1 and 0.

Refs #19

🤖 Generated with Claude Code

When libnvfm is unusable the build stopped at the linker with
"cannot find -lnvfm", which reads like a mistake in the build rather
than a gap in the development package.

Some builds of nvidia-fabricmanager-dev install the linker symlink
libnvfm.so without the libnvfm.so.1 it points at. The symlink alone
does not satisfy -lnvfm, and because ls and dpkg -L both show the file
the package looks correctly installed.

Check for the library before linking and report which case it is:
absent everywhere, or present as a symlink to a library that is not
installed. NVFM_LIB_DIRS lists the directories searched and can be
overridden to point at a development package unpacked elsewhere. The
first match decides, matching how ld resolves -l.

Document the same trap and the rpath-based workaround in the README.

Refs NVIDIA#19

Co-Authored-By: Claude Opus 5 <[email protected]>
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