Skip to content

Commit 8511831

Browse files
committed
build: fix stale soname symlink after a library version bump
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.
1 parent 77e9f58 commit 8511831

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ genclean:
534534
find . -name '*.o' |xargs rm -f
535535
-rm -rf objects
536536
-rm -f $(TARGETS)
537+
-rm -f ../lib/*.so.[0-9]*
537538
-rm -f $(GENERATED_MANPAGES)
538539
-rm -f ../rtlib/*.$(MODULE_EXT)
539540
-rm -f hal/components/conv_*.comp

src/emc/ini/Submakefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ $(patsubst ./emc/ini/%,../include/%,$(LIBLCNCINICXINCS)): ../include/%.hh: ./emc
1919
../lib/liblinuxcncini.so.1: $(call TOOBJS,$(LIBLCNCINISRCS))
2020
$(ECHO) Creating shared library $(notdir $@)
2121
@mkdir -p ../lib
22-
@rm -f $@
22+
@rm -f $(basename $@).[0-9]*
2323
$(Q)$(CXX) $(LDFLAGS) -Wl,-soname,$(notdir $@) -shared -o $@ $^ -lfmt
2424

25+
# Explicit symlink rule: the generic ../lib/%.so pattern rules in src/Makefile
26+
# match both %.so.0 and %.so.1, and the %.so.0 rule wins when a stale .so.0 is
27+
# left over from before this library's soname bump. Bind the dev symlink to the
28+
# current soname explicitly so it always repoints in a single build pass.
29+
../lib/liblinuxcncini.so: ../lib/liblinuxcncini.so.1
30+
ln -sf $(notdir $<) $@
31+
2532
# Command-line utility for reading ini-files
2633
INIVALUESRCS := emc/ini/inivalue.cc
2734
USERSRCS += $(INIVALUESRCS)

0 commit comments

Comments
 (0)