With LTO enabled tpm2-pkcs11 build fails with
+ make check
make test/unit/test_twist test/unit/test_log test/unit/test_parser test/unit/test_attr
make: Entering directory '/builddir/build/BUILD/tpm2-pkcs11-1.3.1'
In function 'memcpy',
inlined from 'internal_append' at src/lib/twist.c:114:10,
inlined from 'twistbin_append' at src/lib/twist.c:302:9,
inlined from 'twistbin_append' at src/lib/twist.c:290:7,
inlined from 'test_twistbin_new_overflow_3' at test/unit/test_twist.c:264:17:
/usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' specified bound 18446744073709551603 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
In function 'memset',
inlined from 'twist_truncate' at src/lib/twist.c:346:3,
inlined from 'test_twist_truncate_smaller' at test/unit/test_twist.c:825:17:
/usr/include/bits/string_fortified.h:71:10: error: '__builtin_memset' specified bound 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
71 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Please see https://koji.fedoraproject.org/koji/taskinfo?taskID=47999421 for full logs.
Version-Release number of selected component (if applicable):
All kinds of interesting possibilities here, I'm sure the unique inlining tuning on s390 comes into play. Thanks for passing it along.
So this is a combination of LTO's cross-module inlining combined with a missed optimization computing ranges for integer overflow tests which results in an infeasible path being left in the CFG. On that infeasible path we have propagated a negative constant value into the size argument of a memset call and we get the bogus diagnostic.
I've filed an upstream BZ for the missed optimization. There's actually a good chance this will be solvable with work that Andrew & Aldy are looking to land in gcc-11.
In the immediate term, I think the s390 disablement of LTO is quite reasonable.
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.