build: fix stale soname symlink after a library version bump#4180
build: fix stale soname symlink after a library version bump#4180grandixximo wants to merge 1 commit into
Conversation
When a shared library's soname is bumped (e.g. liblinuxcncini.so.0 -> .so.1), incremental trees keep the old .so.0 on disk. The generic ../lib/%.so symlink has two pattern rules in src/Makefile (matching %.so.0 and %.so.1, .so.0 listed first), so make repoints the dev symlink at the stale .so.0. Everything then links against the old library and fails with undefined symbols (e.g. IniFile::mapLinearUnits), breaking the python module, linuxcnc_check_ini and startup. Clean builds are immune, so CI never sees it; only incremental builders across the bump are hit. make clean did not help either: .so.0 is no longer in TARGETS, so rm -f $(TARGETS) leaves it behind. Fixes: - liblinuxcncini.so.1 rule removes any leftover .so.[0-9]* sibling. - Add an explicit liblinuxcncini.so -> .so.1 symlink rule. Explicit rules override the ambiguous pattern pair, so the symlink repoints to the current soname in a single build pass (the rm alone self-heals only on a second make). - genclean also removes ../lib/*.so.[0-9]* so stale versioned libraries no longer survive make clean.
|
Should there also be a matching fixup in 2.9 to ensure .so.0? |
|
A fully general fix (auto-handling any future bump) is not really feasible without routing every lib through one build macro, since sonames are written inline per-Submakefile. The |
|
Check. |
When a library soname is bumped (here
liblinuxcncini.so.0to.so.1), an incremental tree keeps the old.so.0on disk, and the dev symlink../lib/liblinuxcncini.sogets repointed at the stale lib: the generic../lib/%.sopattern rules insrc/Makefilematch both%.so.0and%.so.1, and the.so.0rule is listed first so it wins. Everything then links against the old library and fails with undefined symbols (IniFile::mapLinearUnits), breaking the pythonlinuxcncmodule,linuxcnc_check_iniand startup.Clean builds are immune, so CI never sees it; only people building incrementally across the bump are hit.
make cleandoes not help either, because.so.0is no longer in$(TARGETS)sorm -f $(TARGETS)leaves it behind.Fixes:
liblinuxcncini.so.1rule removes any leftover.so.[0-9]*sibling.liblinuxcncini.soto.so.1symlink rule, which overrides the ambiguous pattern pair so the symlink repoints to the current soname in a single build pass (the rm alone only self-heals on a secondmake).gencleanalso removes../lib/*.so.[0-9]*so stale versioned libraries no longer survivemake clean.@BsAtHome flagging you as reviewer. AndyPugh, myself, and Peter Wallace from Mesa all fell into this same trap; I walked Peter through it on Discord. A general fix for everyone seems nicer than the
git clean -dxfwe keep recommending, and it avoids that step entirely. Any reason not to do it?