https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/ Issue: dev-util/android-tools-31.0.3_p1 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 791669 [details] build.log build log and emerge --info
Error(s) that match a know pattern in addition to what has been reported in the summary: -- Package 'libunwind-generic', required by 'virtual:world', not found FAILED: vendor/CMakeFiles/libandroidfw.dir/base/libs/androidfw/ResourceTypes.cpp.o /var/tmp/portage/dev-util/android-tools-31.0.3_p1/work/android-tools-31.0.3p1/vendor/base/libs/androidfw/ResourceTypes.cpp:5479:14: error: dereferencing type-punned pointer will break strict-aliasing rules [-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
lto_tinderbox has reproduced this issue with version 33.0.3 - Updating summary.
lto_tinderbox has reproduced this issue with version 34.0.1 - Updating summary.
lto_tinderbox has reproduced this issue with version 34.0.5 - Updating summary.
Also has lto type mismatches if you pass -fno-strict-aliasing, so it goes further into the build FAILED: vendor/make_f2fs : && /usr/bin/x86_64-pc-linux-gnu-g++ -march=native -O2 -pipe -flto=auto -fexceptions -g -grecord-gcc-switches -fasynchronous-unwind-tables -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -fno-strict-aliasing -ftrivial-auto-var-init=zero -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--sort-common -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing vendor/CMakeFiles/make_f2fs.dir/f2fs-tools/lib/libf2fs_io.c.o vendor/CMakeFiles/make_f2fs.dir/f2fs-tools/mkfs/f2fs_format_main.c.o -o vendor/make_f2fs vendor/liblibf2fs.a vendor/liblibsparse.a -lz vendor/liblibext2_uuid.a vendor/liblibbase.a vendor/fmtlib/libfmt.a vendor/libliblog.a && : /var/tmp/portage/dev-util/android-tools-34.0.5/work/android-tools-34.0.5/vendor/f2fs-tools/include/f2fs_fs.h:1558:34: error: type of ‘c’ does not match original declaration [-Werror=lto-type-mismatch] 1558 | extern struct f2fs_configuration c; | ^ /var/tmp/portage/dev-util/android-tools-34.0.5/work/android-tools-34.0.5/vendor/f2fs-tools/lib/libf2fs_io.c:42:27: note: ‘c’ was previously declared here 42 | struct f2fs_configuration c; | ^ /var/tmp/portage/dev-util/android-tools-34.0.5/work/android-tools-34.0.5/vendor/f2fs-tools/lib/libf2fs_io.c:42:27: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used lto1: some warnings being treated as errors lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status compilation terminated. /usr/libexec/gcc/x86_64-pc-linux-gnu/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status
Right, that's just the vendored copy of bug 863896
Unsure why this code is even included in android-tools, since it is compiled but never linked or installed.
Filed an upstream adb ticket for the remaining adb-specific LTO error (ODR violations, not in f2fs-tools).
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0c03b34a1057b2859947e5c1f8c592ff412babf3 commit 0c03b34a1057b2859947e5c1f8c592ff412babf3 Author: Eli Schwartz <eschwartz93@gmail.com> AuthorDate: 2024-06-16 19:02:49 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-06-17 01:46:48 +0000 dev-util/android-tools: mark as LTO-unsafe And delete some build system glop that has strict-aliasing errors but is never actually used. Closes: https://bugs.gentoo.org/858311 Signed-off-by: Eli Schwartz <eschwartz93@gmail.com> Signed-off-by: Sam James <sam@gentoo.org> dev-util/android-tools/android-tools-34.0.5.ebuild | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
*** Bug 937769 has been marked as a duplicate of this bug. ***