Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 858311 - dev-util/android-tools-34.0.5 fails to compile (lto): ResourceTypes.cpp:5479:14: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
Summary: dev-util/android-tools-34.0.5 fails to compile (lto): ResourceTypes.cpp:5479:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Zac Medico
URL:
Whiteboard:
Keywords:
: 937769 (view as bug list)
Depends on: 863896
Blocks: lto
  Show dependency tree
 
Reported: 2022-07-16 08:58 UTC by Agostino Sarubbo
Modified: 2024-08-25 07:23 UTC (History)
4 users (show)

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


Attachments
build.log (build.log,189.25 KB, text/plain)
2022-07-16 08:58 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 08:58:54 UTC
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
Comment 1 Agostino Sarubbo gentoo-dev 2022-07-16 08:58:57 UTC
Created attachment 791669 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2022-07-16 08:58:59 UTC
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]
Comment 3 Agostino Sarubbo gentoo-dev 2022-07-26 09:01:22 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 4 Agostino Sarubbo gentoo-dev 2022-09-25 06:32:13 UTC
lto_tinderbox has reproduced this issue with version 33.0.3 - Updating summary.
Comment 5 Agostino Sarubbo gentoo-dev 2024-03-01 08:35:00 UTC
lto_tinderbox has reproduced this issue with version 34.0.1 - Updating summary.
Comment 6 Agostino Sarubbo gentoo-dev 2024-05-13 09:28:59 UTC
lto_tinderbox has reproduced this issue with version 34.0.5 - Updating summary.
Comment 7 Kostadin Shishmanov 2024-06-10 17:39:50 UTC
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
Comment 8 Eli Schwartz gentoo-dev 2024-06-16 18:00:51 UTC
Right, that's just the vendored copy of bug 863896
Comment 9 Eli Schwartz gentoo-dev 2024-06-16 18:39:02 UTC
Unsure why this code is even included in android-tools, since it is compiled but never linked or installed.
Comment 10 Eli Schwartz gentoo-dev 2024-06-16 18:54:39 UTC
Filed an upstream adb ticket for the remaining adb-specific LTO error (ODR violations, not in f2fs-tools).
Comment 11 Larry the Git Cow gentoo-dev 2024-06-17 01:47:55 UTC
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(-)
Comment 12 Zac Medico gentoo-dev 2024-08-25 07:23:10 UTC
*** Bug 937769 has been marked as a duplicate of this bug. ***