On 2025/07/14 10:40, Matthias Andree wrote:
> It is conventional for OpenBSD to open bug reports for ports through
> sendbug(1) or via bugs@?  I skimmed a bit through the ports FAQ and
> "Reporting problems" and a few messages randomly picked from the June and
> July 2025 ports mailing list archives, and it doesn't look so.

email to ports@ and/or the person listed as maintainer of the relevant port.

> The issue is that at least these two ports guys
> 
> - databases/lmdb
> - databases/sqlite3
> 
> link against pthread these days, but their pkg-config file does not list
> -lpthread when queried via pkgconfig --libs <database>.

I'd expect 

> Consequence: bogofilter itself is single-threaded and does not use
> material from the POSIX threads library itself, so won't add -pthreads,
> -lpthreads or similar.  It does use the respective pkg-config file of lmdb
> or sqlite3 for --libs and --cflags, and then fails to link any of the
> database-related programs constituting bogofilter, because neither
> 
> pkg-config --libs lmdb
> 
> nor
> 
> pkg-config --libs sqlite3
> 
> gives me -lpthreads on the output.  Excerpt from linker error:
> 
> > ld: error: undefined symbol: pthread_mutexattr_init
> > > > > referenced by sqlite3.c:29857
> > > > > sqlite3.o:(pthreadMutexAlloc) in archive /usr/local/lib/libsqlite3.a
> 
> > $ pkg-config --libs sqlite3
> > -L/usr/local/lib -lsqlite3
> 
> What I find confusing about this is that there was some effort to fix that
> for sqlite3 - and I haven't built the sqlite3 from source but just used
> "pkg_add sqlite3" on my OpenBSD 7.7 VM. (Which itself got updated through
> several releases by way of sysupgrade followed by syspatch and pkg_add
> -u):
> 
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/databases/sqlite3/Makefile#rev1.134

That was "libs.private" as used for static linking. I wouldn't normally
expect pthread to be listed in "libs" if the .so has a NEEDED pointing
at libpthread as ld.so would normally resolve that itself at runtime.

> But lmdb's .pc file definitely doesn't match that LMDB links against
> pthreads these days:
> 
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/databases/lmdb/files/lmdb.pc.in?rev=1.1&content-type=text/x-cvsweb-markup

I think pkgconfig --libs would normally just be expected to list the
linker options needed when linking against the shared library.

> Excerpt from linker error:
> > ld: error: undefined symbol: pthread_mutexattr_init
> > referenced by sqlite3.c:29857
> > sqlite3.o:(pthreadMutexAlloc) in archive /usr/local/lib/libsqlite3.a

Here you're linking the static library, so you need to tell pkg-config
that's what you're doing:

$ pkg-config --libs sqlite3
-L/usr/local/lib -lsqlite3

$ pkg-config --static --libs sqlite3
-L/usr/local/lib -lsqlite3 -lz -lm -lpthread

I don't think there's a problem with the sqlite port, but it looks like
-lpthread is indeed missing from lmdb's libs.private.

Reply via email to