Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 865275 - app-crypt/tpm2-abrmd-2.4.1-r1 fails tests (lto): <artificial>:(.text+0x4c6): undefined reference to __wrap_set_logger
Summary: app-crypt/tpm2-abrmd-2.4.1-r1 fails tests (lto): <artificial>:(.text+0x4c6): ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Christopher Byrne
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-08-15 18:26 UTC by Agostino Sarubbo
Modified: 2022-09-27 21:44 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,356.48 KB, text/plain)
2022-08-15 18:26 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-08-15 18:26:45 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: app-crypt/tpm2-abrmd-2.4.1-r1 fails tests (lto).
Discovered on: amd64 (internal ref: lto_tinderbox)

NOTE:
This machine uses lto with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Here is a bit of explanation:

-Werror=lto-type-mismatch:
User to find possible runtime issues in packages. It likely means the package is unsafe to build & use with LTO.
For projects using the same identifier but with different types across different files, they must be fixed to be consistent across the codebase.

-Werror=odr:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO. C++ code must comply with the One Definition Rule (ODR) - see https://en.cppreference.com/w/cpp/language/definition#One_Definition_Rule.

-Werror=strict-aliasing:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO.

Workarounds:
- If upstream is friendly and still active, file a bug upstream. For emulators, codecs, games, or multimedia packages, it may be worth just applying a workaround instead, as upstreams sometimes aren't receptive to these bugs (VALID FOR ALL).
- Use the new 'filter-lto' from flag-o-matic.eclass as it's likely to be unsafe with LTO (VALID FOR lto-type-mismatch - odr).
- Fix it yourself if interested, of course (VALID FOR ALL).
- Append-flags -fno-strict-aliasing (VALID FOR strict-aliasing).
- Use memcpy() but a union is sometimes suitable too (VALID FOR strict-aliasing).
- -fstrict-aliasing is implied by -O2, so this must be addressed in some form (VALID FOR strict-aliasing).

See also: https://marc.info/?l=gentoo-dev&m=165639574126280&w=2
Comment 1 Agostino Sarubbo gentoo-dev 2022-08-15 18:26:48 UTC
Created attachment 799773 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2022-08-15 18:26:50 UTC
Error(s) that match a know pattern in addition to what has been reported in the summary:


<artificial>:(.text+0x175): undefined reference to `__wrap_tcti_tabrmd_call_cancel_sync'
<artificial>:(.text+0x25a): undefined reference to `__wrap_tcti_tabrmd_call_set_locality_sync'
<artificial>:(.text+0x4c6): undefined reference to `__wrap_set_logger'
<artificial>:(.text+0xf03): undefined reference to `__wrap_tcti_tabrmd_proxy_new_for_bus_sync'
collect2: error: ld returned 1 exit status
Comment 3 Christopher Byrne 2022-09-22 22:42:12 UTC
Well, this one's complicated. It appears to be an interaction between cmocka (used in tests), gcc and ld.bfd (the problem is even worse under ld,gold). clang/ld.lld is not affected and compiles file (but clang/ld.bfd is)

I have a feeling that any program uses gcc/ld.bfd/cmocka is going to run into this problem. filter-lto does not work src_test with autotools at least, and I'm not sure what the best option is going forward.
Comment 4 Joonas Niilola gentoo-dev 2022-09-25 08:12:07 UTC
How did you try to use "filter-flto"? I imagine you have to use it in src_configure, "if use test;" and remember to inherit flag-o-matic.eclass.
Comment 5 Christopher Byrne 2022-09-25 21:56:33 UTC
Something like "use test && filter-lto" in src_compile would work, but it would have the undesirable side effect of disabling LTO on the whole package, when only the tests need it disabled.
Comment 6 Joonas Niilola gentoo-dev 2022-09-26 06:32:12 UTC
Sounds totally fine to me. Doubt many regular users have tests turned on for ebuilds.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-26 17:44:31 UTC
(In reply to Joonas Niilola from comment #6)
> Sounds totally fine to me. Doubt many regular users have tests turned on for
> ebuilds.

The issue is that you then have no idea if LTO is breaking something at runtime. Just filter lto unconditionally until tests work and add a comment saying such.
Comment 8 Joonas Niilola gentoo-dev 2022-09-26 17:50:04 UTC
(In reply to Sam James from comment #7)
> 
> The issue is that you then have no idea if LTO is breaking something at
> runtime. 

... isn't that the default presumption when lto is turned on? :) but yeah don't mind turning it completely off either, that's probably the simplest and surest option here.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-26 17:55:00 UTC
(In reply to Joonas Niilola from comment #8)
> (In reply to Sam James from comment #7)
> > 
> > The issue is that you then have no idea if LTO is breaking something at
> > runtime. 
> 
> ... isn't that the default presumption when lto is turned on? :) but yeah
> don't mind turning it completely off either, that's probably the simplest
> and surest option here.

The whole idea of this work is to try find things which are likely to be broken at runtime and prevent it. If we have the tests failing with LTO for any reason, then we have to assume it's not safe.
Comment 10 Larry the Git Cow gentoo-dev 2022-09-27 21:44:44 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b37aeca1bcdac3de7c1be1229ad0960c9be88b83

commit b37aeca1bcdac3de7c1be1229ad0960c9be88b83
Author:     Christopher Byrne <salah.coronya@gmail.com>
AuthorDate: 2022-09-26 21:08:48 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-09-27 21:42:35 +0000

    app-crypt/tpm2-abrmd: Filter out LTO flags due test failures
    
    Closes: https://bugs.gentoo.org/865275
    Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 app-crypt/tpm2-abrmd/tpm2-abrmd-2.4.1-r1.ebuild | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)