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
Created attachment 791786 [details] build.log.xz build log and emerge --info (compressed because it exceeds attachment limit, use 'xzless' to read it)
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
lto_tinderbox has reproduced this issue with version 5.19 - Updating summary.
Still occurs with 6.3.
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.
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(-)