diff -Nru bglibs-2.04+dfsg/debian/changelog bglibs-2.04+dfsg/debian/changelog --- bglibs-2.04+dfsg/debian/changelog 2025-10-04 18:45:36.000000000 +0200 +++ bglibs-2.04+dfsg/debian/changelog 2026-10-09 09:15:34.000000000 +0200 @@ -1,3 +1,9 @@ +bglibs (2.04+dfsg-10) UNRELEASED; urgency=medium + + * d/p/msg-show-pid-lto.patch: prevent LTO from folding msg_show_pid + + -- Sebastien Bacher Fri, 09 Oct 2026 07:15:34 +0000 + bglibs (2.04+dfsg-9) unstable; urgency=medium * QA upload. diff -Nru bglibs-2.04+dfsg/debian/patches/msg-show-pid-lto.patch bglibs-2.04+dfsg/debian/patches/msg-show-pid-lto.patch --- bglibs-2.04+dfsg/debian/patches/msg-show-pid-lto.patch 1970-01-01 01:00:00.000000000 +0100 +++ bglibs-2.04+dfsg/debian/patches/msg-show-pid-lto.patch 2026-10-09 09:15:34.000000000 +0200 @@ -0,0 +1,60 @@ +Description: msg: do not let LTO constant-fold the default msg_show_pid + libbg ships a default "const int msg_show_pid = 0" (msg/show_pid.c) which + programs are expected to override with their own definition (the header + declares it weak). When the library is built with -flto, GCC sees the + library-local const definition while linking libbg.so, folds the value to 0 + and drops the whole PID-printing branch from msg_common()/msg_commonfv(). + Programs such as mailfront that set msg_show_pid = 1 then silently lose the + "[pid]" in their log lines (and mailfront FTBFS because its testsuite + checks for it). + . + Marking the default definition weak is not sufficient (GCC still folds the + const initializer), so read the variable through a volatile lvalue instead. +Author: Sebastien Bacher +Bug-Ubuntu: https://bugs.launchpad.net/bugs/2170282 +Forwarded: no +Last-Update: 2026-10-09 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: bglibs-2.04+dfsg/msg/common.c +=================================================================== +--- bglibs-2.04+dfsg.orig/msg/common.c ++++ bglibs-2.04+dfsg/msg/common.c +@@ -17,8 +17,14 @@ void msg_common(const char* type, + msg_show_program = getenv("MSG_NO_PROGRAM") == NULL; + if (msg_show_program) { + obuf_puts(&errbuf, program); +- if (&msg_show_pid != 0 && msg_show_pid) { +- if (!pid || msg_show_pid < 0) ++ /* Read msg_show_pid through a volatile lvalue: the library carries a ++ * default definition (msg/show_pid.c) that programs override, and with ++ * LTO the compiler would otherwise constant-fold that default (0) and ++ * ignore the program's definition. */ ++ const int show_pid = (&msg_show_pid != 0) ++ ? *(const volatile int*)&msg_show_pid : 0; ++ if (show_pid) { ++ if (!pid || show_pid < 0) + pid = getpid(); + obuf_putc(&errbuf, '['); + obuf_putu(&errbuf, pid); +Index: bglibs-2.04+dfsg/msg/commonf.c +=================================================================== +--- bglibs-2.04+dfsg.orig/msg/commonf.c ++++ bglibs-2.04+dfsg/msg/commonf.c +@@ -14,8 +14,14 @@ void msg_commonfv(const char* type, + { + if (program != 0) { + obuf_puts(&errbuf, program); +- if (&msg_show_pid != 0 && msg_show_pid) { +- if (!pid || msg_show_pid < 0) ++ /* Read msg_show_pid through a volatile lvalue: the library carries a ++ * default definition (msg/show_pid.c) that programs override, and with ++ * LTO the compiler would otherwise constant-fold that default (0) and ++ * ignore the program's definition. */ ++ const int show_pid = (&msg_show_pid != 0) ++ ? *(const volatile int*)&msg_show_pid : 0; ++ if (show_pid) { ++ if (!pid || show_pid < 0) + pid = getpid(); + obuf_putc(&errbuf, '['); + obuf_putu(&errbuf, pid); diff -Nru bglibs-2.04+dfsg/debian/patches/series bglibs-2.04+dfsg/debian/patches/series --- bglibs-2.04+dfsg/debian/patches/series 2025-10-04 18:45:36.000000000 +0200 +++ bglibs-2.04+dfsg/debian/patches/series 2026-10-09 09:15:34.000000000 +0200 @@ -1,3 +1,4 @@ 001_ensure_use_of_usr_bin_perl.patch declarations.patch 0001-Fixes-for-new-GCC.patch +msg-show-pid-lto.patch