Public bug reported:

mailfront 2.12-3 fails to build on amd64, arm64, ppc64el and s390x in
Ubuntu since oracular (it builds on armhf/riscv64 and on all Debian
architectures). The failing test is tests/backend-queuedir:

  -mailfront[#]: MAIL FROM:<somewhere>
  +mailfront: MAIL FROM:<somewhere>
  ...
  124 tests executed, 1 failures

https://launchpad.net/ubuntu/+source/mailfront/2.12-3/+build/32793504

The problem is in bglibs, not mailfront. The issue is a runtime one,
mailfront just happens to have a test checking for it.

libbg exports a default "const int msg_show_pid = 0" (msg/show_pid.c),
and include/msg.h declares it weak so that programs can override it with
their own definition (mailfront.c has "const int msg_show_pid = 1;").
msg_common()/msg_commonfv() are supposed to read whichever definition
wins at runtime.

Ubuntu builds bglibs with -flto on amd64/arm64/ppc64el/s390x. While
linking libbg.so, LTO sees the library-local const definition, folds it
to 0 and removes the whole PID-printing branch:

- Ubuntu libbg2 2.04+dfsg-9build1 amd64: no GLOB_DAT relocation for 
msg_show_pid, no getpid call in msg_common
- Debian libbg2 2.04+dfsg-9+b2 amd64 (no LTO): R_X86_64_GLOB_DAT msg_show_pid, 
getpid called

So on Ubuntu any libbg user that sets msg_show_pid (mailfront, ...)
silently loses the "[pid]" in its log lines.

Making the default definition weak isn't enough, GCC (13 and 15 tested)
still folds the const initializer. Reading the variable through a
volatile lvalue in msg/common.c and msg/commonf.c does fix it.

Tested in a stonking container (GCC 15.3, default LTO flags):
- bglibs with the patch: selftests pass, libbg.so has the msg_show_pid GLOB_DAT 
relocation again
- mailfront 2.12-3 built against it: "124 tests executed, 0 failures"

A debdiff will be attached; I will forward the patch to Debian and
upstream (https://github.com/bruceg/bglibs).

** Affects: bglibs (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: mailfront (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: ftbfs lto stonking

** Tags added: ftbfs lto patch stonking

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2170282

Title:
  LTO folds msg_show_pid, programs can't enable PID in log messages
  (mailfront FTBFS)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bglibs/+bug/2170282/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to