https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/ Issue: media-sound/mup-6.9 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 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
Created attachment 823369 [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: <artificial>:(.text+0xc7d): undefined reference to `yywrap' <artificial>:(.text.startup+0x347f): undefined reference to `yywrap' collect2: error: ld returned 1 exit status
This only happens when flex is ALSO compiled with LTO. configure:5745: checking for library containing yywrap configure:5781: x86_64-pc-linux-gnu-gcc -o conftest -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 conftest.c -lfl >&5 conftest.c:21:6: error: type of 'yywrap' does not match original declaration [-Werror=lto-type-mismatch] 21 | char yywrap (void); | ^ /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26:9: note: return value type mismatch /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26:9: note: type 'int' should match type 'char' /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26:9: note: 'yywrap' 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/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed This seems like an autoconf bug given it owns the relevant macro...
See also https://github.com/westes/flex/issues/277 (but not yet sure if it's actually related). (In reply to Eli Schwartz from comment #3) > This only happens when flex is ALSO compiled with LTO. > Bleh. > configure:5745: checking for library containing yywrap > configure:5781: x86_64-pc-linux-gnu-gcc -o conftest -march=native > -fstack-protector-all -O2 -pipe -fdiagnostics-color=always > -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 > -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch > -Werror=strict-aliasing -Wformat -Werror=format-security > -Werror=implicit-function-declaration -Werror=implicit-int > -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 > -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch > -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 conftest.c > -lfl >&5 > conftest.c:21:6: error: type of 'yywrap' does not match original declaration > [-Werror=lto-type-mismatch] > 21 | char yywrap (void); > | ^ Yeah, this is the standard prototype it uses. What's interesting is that it manages to include the header for yywrap so the fallback prototype isn't needed, then they conflict. > /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26: > 9: note: return value type mismatch > /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26: > 9: note: type 'int' should match type 'char' > /var/tmp/portage/sys-devel/flex-2.6.4-r6/work/flex-2.6.4/src/libyywrap.c:26: > 9: note: 'yywrap' 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/13/../../../../x86_64-pc-linux-gnu/bin/ld: > error: lto-wrapper failed > > > This seems like an autoconf bug given it owns the relevant macro... The autoconf people are generally not keen on when you tell them you built with -Werror=x, although really, I think in this case, it's justified. Just be prepred to have to explain why we're using it.
(In reply to Sam James from comment #4) > Yeah, this is the standard prototype it uses. What's interesting is that it > manages to include the header for yywrap so the fallback prototype isn't > needed, then they conflict. or, wait, is it that libfl is a static library, and it has the information encoded in there because LTO?
Yes, flex distributes a static library and that is what is conflicting.
Probably once again a "if we could strip out LTO bytecode from installed static archives and avoid compiler ICE after you update the compiler without recompiling all packages". Just a slightly different reason this time...
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd25aa948453fae21f85d607bde480904da451d6 commit dd25aa948453fae21f85d607bde480904da451d6 Author: Sam James <sam@gentoo.org> AuthorDate: 2025-05-02 00:30:46 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2025-05-06 08:45:08 +0000 sys-devel/flex: use dot-a.eclass for LTO This means that USE=static-libs doesn't produce a "broken" library when built w/ LTO. Closes: https://bugs.gentoo.org/592868 Closes: https://bugs.gentoo.org/616106 Closes: https://bugs.gentoo.org/876430 Closes: https://bugs.gentoo.org/924183 Closes: https://bugs.gentoo.org/936172 Closes: https://bugs.gentoo.org/938858 Closes: https://bugs.gentoo.org/940541 Closes: https://bugs.gentoo.org/944291 Closes: https://bugs.gentoo.org/945923 Signed-off-by: Sam James <sam@gentoo.org> sys-devel/flex/flex-2.6.4-r6.ebuild | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)