From 1c4fdf0a55f80a2597b6785b073225260bf28f92 Mon Sep 17 00:00:00 2001 From: lotherk Date: Mon, 23 Nov 2026 13:42:13 +0000 Subject: [PATCH] make: link the library by file, not through -L A package build passes -L=/usr/pkg/lib ahead of anything this Makefile can append, so -lsplinter found the copy installed by the previous release. A function added to engine.c the same day was then 'undefined' at link time (2026-11-23, cross release). The library is named as a file now, and carries a SONAME, so the installed binary records libsplinter.so and not a build path. Test: make install with LDFLAGS=-L/tmp/oldlib (the 22.11 library without sp_engine_sources) links and runs: 0 undefined references. --- Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 8de5ac7..3412f4f 100644 --- a/Makefile +++ b/Makefile @@ -31,15 +31,17 @@ CURSES_LIB ?= $(CURSES_DIR)/libcurses/libcurses.a \ CURSES_DEP ?= $(CURSES_LIB) LIB = libsplinter.so -# The library in this directory comes first, before every -L a package build -# adds: a pkgsrc build passes -L=/usr/pkg/lib, and an older libsplinter.so -# installed there was what `-lsplinter` found -- the freshly built one was -# ignored, so a binary linked against the library of the previous release -# (measured 2026-11-23: /usr/pkg/lib/libsplinter.so from 22.11. 22:26 made -# `splinter` stop with "undefined reference to sp_engine_sources", a function -# that had been added to engine.c the same day). -L. therefore travels with -# the -l, ahead of $(LDFLAGS). -SPLLIB = -L. -lsplinter +# Links name the library by file, never through a search path. A search path +# loses: a package build passes -L=/usr/pkg/lib ahead of anything this Makefile +# can append, so `-lsplinter` found the copy installed by the previous release +# instead of the one built a second ago (measured 2026-11-23: +# /usr/pkg/lib/libsplinter.so from 22.11. 22:26 made `splinter` fail with +# "undefined reference to sp_engine_sources", a function added to engine.c the +# same day). Naming the file is order-independent, and the SONAME the library +# carries (see the $(LIB) rule) is what the binary records as its dependency, +# so the installed program still looks for "libsplinter.so" and not for a +# build path. +SPLLIB = $(LIB) LIBOBJ = src/backend/buf.o src/backend/tool.o src/backend/session.o src/backend/conv.o src/backend/compact.o src/backend/transport.o \ src/backend/json.o src/backend/sse.o src/backend/openai.o src/backend/transport_openai.o \ src/backend/anthropic.o src/backend/transport_anthropic.o src/backend/builtin.o \ @@ -103,7 +105,7 @@ src/backend/buildinfo.c: $(LIBOBJ) $(BINOBJ) } > $@ $(LIB): $(LIBOBJ_ALL) $(CURSES_DEP) - $(CC) -shared -o $@ $(LIBOBJ_ALL) $(CURSES_LIB) $(LIBS) + $(CC) -shared -Wl,-soname,$(LIB) -o $@ $(LIBOBJ_ALL) $(CURSES_LIB) $(LIBS) # curses belongs to the front end, not to the library: a plugin that drew into # a WINDOW would be a plugin holding the UI thread's state.