Uh oh!
There was an error while loading. Please reload this page.
fix: make libfastfields.so link depend on cpu/cuda sub-libraries - #64
Merged
Conversation
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
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Summary
libfastfields.so's link rule listed only$(OBJECTS)as prerequisites. Its dependency onbuild/lib/libfastfields-cpu.so(and, whenUSE_CUDA=1,build/lib/libfastfields-cuda.so) was expressed only by listinglibcpu/$(CUDA_DEP)as siblings of the link target under the recipe-lesslib:goal — not as a real prerequisite of the link rule itself.make -j, prerequisites oflib:have no ordering guarantee and can run concurrently, so the link step could start (and finish) beforemake -C cpu installhad producedbuild/lib/libfastfields-cpu.so, failing withld: cannot find -lfastfields-cpu.$(BUILDDIR)/lib/libfastfields-cpu.$(SOSUF)and$(CUDA_DEP)as real prerequisites of the$(BUILDDIR)/libfastfields.$(SOSUF)rule, somake -jcannot schedule the link before they exist. The recipe now references$(OBJECTS)explicitly instead of$^, since$^would otherwise also pull the newly-added.soprerequisites into the link command's positional arguments (redundant with the existing-lfastfields-cpu/$(CUDA_LDFLAGS)flags).cuda's submake for the analogous issue per the issue's suggestion: same pattern ($(CUDA_DEP)was only a sibling, not a real prerequisite), fixed in the same rule. Both cpu-lib's and cuda-lib's own internalinstall/libcpu/libcudarules already declare correct real (non-sibling) prerequisites, so no further changes were needed there.Closes#56
Verification
Ran from a clean
build/each time (rm -rf build), CPU path only (USE_CUDAdefaults to 0, matching how CI builds this repo today).Before the fix, a clean
make -C . all CXX=clang++ -j4reproduces the exact failure from the issue:(the top-level link ran before
make -C cpu installhad finished copyinglibfastfields-cpu.sointobuild/lib/).After the fix:
make -C . all CXX=clang++ -j4from a cleanbuild/— 2 consecutive clean runs, both succeed, both producebuild/libfastfields.soandbuild/lib/libfastfields-cpu.so, nocannot find -lfastfields-cpu/ noErrormarkers in either log.make -C . all CXX=clang++from a cleanbuild/— also succeeds, same artifacts produced, no errors.make -ndry-run sanity check that the link target now lists the cpu.soas a prerequisitemake -C . all CXX=clang++ -j4— before: reproducibly fails; after: 2/2 clean runs passmake -C . all CXX=clang++— passesCLAUDE.md); correctness remains gated byfastfields-cpu-lib's test suite, unaffected by this changeGenerated by Claude Code