Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 858449 - dev-util/perf-5.19 fails to compile (lto): builtin-test.c:33:27: error: type of [-Werror=lto-type-mismatch]
Summary: dev-util/perf-5.19 fails to compile (lto): builtin-test.c:33:27: error: type ...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Naohiro Aota
Depends on:
Blocks: lto
  Show dependency tree
Reported: 2022-07-16 18:10 UTC by Agostino Sarubbo
Modified: 2023-07-10 15:34 UTC (History)
3 users (show)

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

build.log.xz (build.log.xz,24.50 KB, application/x-xz)
2022-07-16 18:10 UTC, Agostino Sarubbo

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-07-16 18:10:48 UTC

Issue: dev-util/perf-5.18 fails to compile (lto).
Discovered on: amd64 (internal ref: lto_tinderbox)

This machine uses lto with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Comment 1 Agostino Sarubbo gentoo-dev 2022-07-16 18:10:50 UTC
Created attachment 791786 [details]

build log and emerge --info (compressed because it exceeds attachment limit, use 'xzless' to read it)
Comment 2 Agostino Sarubbo gentoo-dev 2022-07-26 09:01:34 UTC
Here is a bit of explanation:

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.

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

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

- 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:
Comment 3 Agostino Sarubbo gentoo-dev 2022-09-26 08:46:41 UTC
lto_tinderbox has reproduced this issue with version 5.19 - Updating summary.
Comment 4 Matt Turner gentoo-dev 2023-06-28 23:48:57 UTC
Still occurs with 6.3.
Comment 5 Guilherme Amadio gentoo-dev 2023-07-06 16:02:12 UTC
Still happens with 6.4, unfortunately:

	perf-in.o pmu-events/pmu-events-in.o -Wl,--whole-archive /tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf/libapi/libapi.a /tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf/libperf/libperf.a /tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf/libsubcmd/libsubcmd.a /tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf/libsymbol/libsymbol.a /tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf/libbpf/libbpf.a  -Wl,--no-whole-archive -Wl,--start-group -lpthread -lrt -lm -ldl -ltcmalloc -lelf -ldw -lunwind-x86_64 -lunwind -llzma -lcrypto -lslang -ldl -lperl -ldl -lm -lcrypt -lutil -lc -lpython3.12 -ldl -lm -lutil -lbfd -lopcodes -lstdc++ -liberty -lz -llzma -lzstd -lcap -lnuma -lbabeltrace-ctf -lpfm -ltraceevent -ltracefs -Wl,--end-group -lclang-cpp -L/usr/lib/llvm/16/lib64 -lLLVM-16  -lstdc++ -o perf
tests/builtin-test.c:36:27: error: type of ‘arch_tests’ does not match original declaration [-Werror=lto-type-mismatch]
   36 | struct test_suite *__weak arch_tests[] = {
      |                           ^
arch/x86/tests/arch-tests.c:26:20: note: array types have different bounds
   26 | struct test_suite *arch_tests[] = {
      |                    ^
arch/x86/tests/arch-tests.c:26:20: note: ‘arch_tests’ was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile.perf:678: perf] Error 1
make[1]: Leaving directory '/tmp/portage/dev-util/perf-6.4-r1/work/linux-6.4/tools/perf'

I will get this reported upstream.
Comment 6 Larry the Git Cow gentoo-dev 2023-07-10 15:34:07 UTC
The bug has been referenced in the following commit(s):

commit 6020fc656e53f467c2d548a6550f835e07780b1f
Author:     Matt Turner <>
AuthorDate: 2023-07-10 15:33:40 +0000
Commit:     Matt Turner <>
CommitDate: 2023-07-10 15:34:03 +0000

    dev-util/perf: Filter LTO flags
    Signed-off-by: Matt Turner <>

 dev-util/perf/perf-6.3-r1.ebuild | 4 +++-
 dev-util/perf/perf-6.3.ebuild    | 4 +++-
 dev-util/perf/perf-6.4-r1.ebuild | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)