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 ...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Naohiro Aota
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-07-16 18:10 UTC by Agostino Sarubbo
Modified: 2024-01-30 15:30 UTC (History)
3 users (show)

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


Attachments
build.log.xz (build.log.xz,24.50 KB, application/x-xz)
2022-07-16 18:10 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-07-16 18:10:48 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: dev-util/perf-5.18 fails to compile (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
Comment 1 Agostino Sarubbo gentoo-dev 2022-07-16 18:10:50 UTC
Created attachment 791786 [details]
build.log.xz

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:

-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 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):

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

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

    dev-util/perf: Filter LTO flags
    
    Bug: https://bugs.gentoo.org/858449
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 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(-)
Comment 7 Guilherme Amadio gentoo-dev 2024-01-30 15:30:25 UTC
Fixed upstream in perf-6.7.