[PATCH] tests: disable link time optimization (LTO) that breaks tests

16 views
Skip to first unread message

Hector Cao

unread,
Aug 11, 2026, 9:41:46 AMAug 11
to hecto...@canonical.com, efibootg...@googlegroups.com
The test suite mocks internal functions by weakening their symbols with
objcopy (see libenvapi_testlib_fat.a rule below) so test-provided fake
implementations can override them at link time. LTO resolves symbols from
GIMPLE bytecode ignoring this post-hoc weakening, which causes "multiple
definition" link errors. Strip any global LTO flags and force LTO off for
this test directory so the weak-symbol override technique keeps working.

Signed-off-by: Hector Cao <hecto...@canonical.com>
---
tools/tests/Makefile.am | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am
index 7e3ac1e..0d38cb7 100644
--- a/tools/tests/Makefile.am
+++ b/tools/tests/Makefile.am
@@ -15,6 +15,15 @@ if BUILD_TESTS

OBJCOPY ?= objcopy

+# The test suite mocks internal functions by weakening their symbols with
+# objcopy (see libenvapi_testlib_fat.a rule below) so test-provided fake
+# implementations can override them at link time. LTO resolves symbols from
+# GIMPLE bytecode ignoring this post-hoc weakening, which causes "multiple
+# definition" link errors. Strip any global LTO flags and force LTO off for
+# this test directory so the weak-symbol override technique keeps working
+override CFLAGS := $(filter-out -flto -flto=% -ffat-lto-objects,$(CFLAGS)) -fno-lto
+override LDFLAGS := $(filter-out -flto -flto=%,$(LDFLAGS)) -fno-lto
+
AM_CFLAGS = \
$(LIBCHECK_CFLAGS) \
-I$(top_srcdir)/include \
--
2.43.0

Hector Cao

unread,
Aug 11, 2026, 9:43:40 AMAug 11
to hecto...@canonical.com, efibootg...@googlegroups.com
The test suite mocks internal functions by weakening their symbols with
objcopy (see libenvapi_testlib_fat.a rule below) so test-provided fake
implementations can override them at link time. LTO resolves symbols from
GIMPLE bytecode ignoring this post-hoc weakening, which causes "multiple
definition" link errors. Strip any global LTO flags and force LTO off for
this test directory so the weak-symbol override technique keeps working.

Signed-off-by: Hector Cao <hecto...@canonical.com>
---
tools/tests/Makefile.am | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am
index 7e3ac1e..87d1f81 100644
--- a/tools/tests/Makefile.am
+++ b/tools/tests/Makefile.am
@@ -15,6 +15,15 @@ if BUILD_TESTS

OBJCOPY ?= objcopy

+# The test suite mocks internal functions by weakening their symbols with
+# objcopy (see libenvapi_testlib_fat.a rule below) so test-provided fake
+# implementations can override them at link time. LTO resolves symbols from
+# GIMPLE bytecode ignoring this post-hoc weakening, which causes "multiple
+# definition" link errors. Append -fno-lto flag to force LTO off for
+# this test directory so the weak-symbol override technique keeps working
+CFLAGS += -fno-lto
+LDFLAGS += -fno-lto
Message has been deleted

Jan Kiszka

unread,
Aug 11, 2026, 12:22:27 PMAug 11
to Hector Cao, efibootg...@googlegroups.com
Thanks, applied!

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Jan Kiszka

unread,
Aug 11, 2026, 2:14:00 PMAug 11
to Hector Cao, efibootg...@googlegroups.com
Looks like my proposal to drop "override" was wrong. We are getting

warning: 'CFLAGS' is a user variable, you should not override it;

now, and the docs also suggest that it is needed. Adding this back.

Jan

PS: CI over the Ubuntu is images are currently broken while it is fine
locally with Debian. I suspect another round of qemu-user issues. Not a
problem of this patch, though.

Jan Kiszka

unread,
Aug 11, 2026, 2:25:57 PMAug 11
to Hector Cao, efibootg...@googlegroups.com
...but I happen to have the guy here who also did the qemu-user releases
for Ubuntu:

https://github.com/siemens/efibootguard/actions/runs/29389435585/job/87269392254
vs.
https://github.com/siemens/efibootguard/actions/runs/29389435585/job/93865862086

Same EBG commit, just more recent packages. Namely

1:8.2.2+ds-0ubuntu1.17
vs.
1:8.2.2+ds-0ubuntu1.18

Its changelog looks harmless, but a noble container locally with Debian
provided qemu-user does not trigger this. Any ideas?

Jan

Hector Cao

unread,
Aug 11, 2026, 2:34:18 PMAug 11
to Jan Kiszka, efibootg...@googlegroups.com
Hello Jan,

Yes, that is fortunate :)

I do not see any failure in the 2 links you gave.

Help me please
--
Hector CAO
Software Engineer – Server Team / Virtualization

Jan Kiszka

unread,
Aug 12, 2026, 1:47:56 AMAug 12
to Hector Cao, efibootg...@googlegroups.com
On 11.08.26 20:34, Hector Cao wrote:
> Hello Jan,
>
> Yes, that is fortunate :)
>
> I do not see any failure in the 2 links you gave.
>
> Help me please
>

The second one
(https://github.com/siemens/efibootguard/actions/runs/29389435585/job/93865862086)
points to:

[...]
make check-TESTS
FAIL: test_bgenv_init_retval
FAIL: test_probe_config_partitions
FAIL: test_probe_config_file
FAIL: test_ebgenv_api_internal
FAIL: test_uservars
FAIL: test_ebgenv_api
FAIL: test_fat

I would bet that the cross-execution of the test cases is failing here,
also given that we have no error messages from the tests themselves and
that amd64 completes.

Jan

> On Tue, Aug 11, 2026 at 8:25 PM Jan Kiszka <jan.k...@siemens.com
> <mailto:jan.k...@siemens.com>> wrote:
>
> On 11.08.26 20:13, Jan Kiszka wrote:
> > On 11.08.26 18:22, 'Jan Kiszka' via EFI Boot Guard wrote:
> >> On 11.08.26 15:43, 'Hector Cao' via EFI Boot Guard wrote:
> >>> The test suite mocks internal functions by weakening their
> symbols with
> >>> objcopy (see libenvapi_testlib_fat.a rule below) so test-
> provided fake
> >>> implementations can override them at link time. LTO resolves
> symbols from
> >>> GIMPLE bytecode ignoring this post-hoc weakening, which causes
> "multiple
> >>> definition" link errors. Strip any global LTO flags and force
> LTO off for
> >>> this test directory so the weak-symbol override technique keeps
> working.
> >>>
> >>> Signed-off-by: Hector Cao <hecto...@canonical.com
> <mailto:hecto...@canonical.com>>
> job/87269392254 <https://github.com/siemens/efibootguard/actions/
> runs/29389435585/job/87269392254>
>   vs.
> https://github.com/siemens/efibootguard/actions/runs/29389435585/
> job/93865862086 <https://github.com/siemens/efibootguard/actions/
> runs/29389435585/job/93865862086>
>
> Same EBG commit, just more recent packages. Namely
>
> 1:8.2.2+ds-0ubuntu1.17
>   vs.
> 1:8.2.2+ds-0ubuntu1.18
>
> Its changelog looks harmless, but a noble container locally with Debian
> provided qemu-user does not trigger this. Any ideas?
>
> Jan
>
> --
> Siemens AG, Foundational Technologies
> Linux Expert Center
>
>
>
> --
> Hector CAO
> Software Engineer – Server Team / Virtualization
> hecto...@canonical.com <mailto:hecto...@canonical.com>
> https://launc <https://launchpad.net/~hectorcao>hpad.net/~hectorcao
> <https://launchpad.net/~hectorcao>
>
> <https://launchpad.net/~hectorcao>

Jan Kiszka

unread,
Aug 12, 2026, 2:51:38 AMAug 12
to Hector Cao, efibootg...@googlegroups.com
On 12.08.26 07:47, 'Jan Kiszka' via EFI Boot Guard wrote:
> On 11.08.26 20:34, Hector Cao wrote:
>> Hello Jan,
>>
>> Yes, that is fortunate :)
>>
>> I do not see any failure in the 2 links you gave.
>>
>> Help me please
>>
>
> The second one
> (https://github.com/siemens/efibootguard/actions/runs/29389435585/job/93865862086)
> points to:
>
> [...]
> make check-TESTS
> FAIL: test_bgenv_init_retval
> FAIL: test_probe_config_partitions
> FAIL: test_probe_config_file
> FAIL: test_ebgenv_api_internal
> FAIL: test_uservars
> FAIL: test_ebgenv_api
> FAIL: test_fat
>
> I would bet that the cross-execution of the test cases is failing here,
> also given that we have no error messages from the tests themselves and
> that amd64 completes.
>

I've now also tried to reproduce the setup in a local debvm, noble
image, (hopefully) similar packages, including qemu-user-static
1:8.2.2+ds-0ubuntu1.18 - and that works fine?! Confused.
Reply all
Reply to author
Forward
0 new messages