From 85118312a4067ba82b56181868607c224a792cba Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Sat, 20 Jun 2026 09:30:29 +0800 Subject: [PATCH] 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. --- src/Makefile | 1 + src/emc/ini/Submakefile | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 4b221e6546b..fbe1e5768e8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -534,6 +534,7 @@ genclean: find . -name '*.o' |xargs rm -f -rm -rf objects -rm -f $(TARGETS) + -rm -f ../lib/*.so.[0-9]* -rm -f $(GENERATED_MANPAGES) -rm -f ../rtlib/*.$(MODULE_EXT) -rm -f hal/components/conv_*.comp diff --git a/src/emc/ini/Submakefile b/src/emc/ini/Submakefile index 250d2075c49..e619a430569 100644 --- a/src/emc/ini/Submakefile +++ b/src/emc/ini/Submakefile @@ -19,9 +19,16 @@ $(patsubst ./emc/ini/%,../include/%,$(LIBLCNCINICXINCS)): ../include/%.hh: ./emc ../lib/liblinuxcncini.so.1: $(call TOOBJS,$(LIBLCNCINISRCS)) $(ECHO) Creating shared library $(notdir $@) @mkdir -p ../lib - @rm -f $@ + @rm -f $(basename $@).[0-9]* $(Q)$(CXX) $(LDFLAGS) -Wl,-soname,$(notdir $@) -shared -o $@ $^ -lfmt +# Explicit symlink rule: the generic ../lib/%.so pattern rules in src/Makefile +# match both %.so.0 and %.so.1, and the %.so.0 rule wins when a stale .so.0 is +# left over from before this library's soname bump. Bind the dev symlink to the +# current soname explicitly so it always repoints in a single build pass. +../lib/liblinuxcncini.so: ../lib/liblinuxcncini.so.1 + ln -sf $(notdir $<) $@ + # Command-line utility for reading ini-files INIVALUESRCS := emc/ini/inivalue.cc USERSRCS += $(INIVALUESRCS)