From 444bc02ae6562547dcc74cfdd8022f83a43d809f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 5 Aug 2026 12:40:33 +0000 Subject: [PATCH] fix: make libfastfields.so link depend on cpu/cuda sub-libraries (#56) Under `make -j`, the top-level `libfastfields.so` link rule only listed $(OBJECTS) as prerequisites -- its dependency on the cpu (and cuda, when USE_CUDA=1) sub-library was expressed only as a sibling under the recipe-less `lib:` target, not as a real prerequisite of the link rule itself. Make is free to run independent prerequisites of `lib:` in any order/concurrently under -j, so the link step could run before `make -C cpu install` finished producing build/lib/libfastfields-cpu.so, failing with `ld: cannot find -lfastfields-cpu`. Add the cpu .so (and $(CUDA_DEP)) as real prerequisites of the $(BUILDDIR)/libfastfields.$(SOSUF) rule so make -j can't schedule the link before they exist. The recipe now lists $(OBJECTS) explicitly instead of $^, since $^ would otherwise pull the .so prerequisites into the link command's positional arguments. Closes #56 --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 257a414..c79cd9d 100644 --- a/Makefile +++ b/Makefile @@ -183,10 +183,15 @@ $(BUILDDIR)/lib/libfastfields-cpu.$(SOSUF): $(BUILDDIR) $(BUILDDIR)/lib/libfastfields-cuda.$(SOSUF): $(BUILDDIR) $(MAKE) -C cuda install -$(BUILDDIR)/libfastfields.$(SOSUF): $(OBJECTS) +# Real prerequisites (not just siblings under the `lib:` recipe-less target) +# so `make -j` can't run this link step before the cpu/cuda sub-libraries it +# links against actually exist -- see #56. ($^ would pull the .so +# prerequisites into the link line too, so the recipe lists $(OBJECTS) +# explicitly instead.) +$(BUILDDIR)/libfastfields.$(SOSUF): $(OBJECTS) $(BUILDDIR)/lib/libfastfields-cpu.$(SOSUF) $(CUDA_DEP) $(CXX) $(CXXFLAGS) -shared $(PICFLAG) $(SONAME_FLAG) $(RPATH) \ -L$(BUILDDIR)/lib -lfastfields-cpu $(CUDA_LDFLAGS) \ - -o $@ $^ + -o $@ $(OBJECTS) ######################################################################## # Objects