Hi,
libbg ships a default "const int msg_show_pid = 0" (msg/show_pid.c)
which programs override with their own definition (include/msg.h
declares it weak); msg_common()/msg_commonfv() are supposed to use
whichever definition wins at runtime.
When the library is built with -flto (the default in Ubuntu on amd64,
arm64, ppc64el and s390x), GCC sees the library-local const definition
while linking libbg.so, folds it to 0 and drops the PID-printing branch
entirely: the resulting libbg.so has no GLOB_DAT relocation for
msg_show_pid and no getpid() call in msg_common. Programs such as
mailfront that set msg_show_pid = 1 then lose the "[pid]" in their log
lines, and mailfront's testsuite fails (tests/backend-queuedir):
https://bugs.launchpad.net/bugs/2170282
Debian is not affected today since LTO isn't enabled by default, but it
would be with DEB_BUILD_MAINT_OPTIONS=optimize=+lto.
Making the default definition weak isn't sufficient (GCC 13 and 15
still fold the const initializer); the attached patch reads the variable
through a volatile lvalue instead. Tested with GCC 15.3 and LTO: bglibs
selftests pass, libbg.so references msg_show_pid through the GOT again,
and mailfront 2.12-3 built against it passes all 124 tests.
The patch has also been sent upstream,
https://github.com/bruceg/bglibs/pull/12
Thanks,
Sebastien Bacher