Build fails with LTO

8 views
Skip to first unread message

Eli Schwartz

unread,
May 12, 2024, 8:58:46 PMMay 12
to wmake...@googlegroups.com
I tried to build with the following *FLAGS to optimize the build:
`-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing`

Note the -Werror=* flags are used to help detect cases where the
compiler tries to optimize by assuming UB cannot exist in the source
code -- if it does exist, ordinarily the code would be miscompiled, and
this says to make the miscompilation a fatal error.

I got this error (when building test programs):
```
x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe
-fdiagnostics-color=always -frecord-gcc-switches -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 -D_GNU_SOURCE -W -Wall -Wshadow
-Wpointer-arith -Wwrite-strings -Wl,-O1 -Wl,--as-needed -flto=4
-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
-Wl,--defsym=__gentoo_check_ldflags__=0 -o test_tlscomm test_tlscomm.o
tlsComm.o -lXpm -lXext -lX11 -lz -lresolv -lnsl -lgnutls
gnutls-common.h:28:5: error: type of ‘print_info’ does not match
original declaration [-Werror=lto-type-mismatch]
28 | int print_info( gnutls_session_t state, const char* hostname);
| ^
test_tlscomm.c:28:5: note: type mismatch in parameter 2
28 | int print_info(void *state __attribute__((unused)))
| ^
test_tlscomm.c:28:5: note: ‘print_info’ 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
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:628: test_tlscomm] Error 1
make[2]: Leaving directory
'/var/tmp/portage/x11-plugins/wmbiff-0.4.36/work/wmbiff-0.4.36/wmbiff'
make[2]: Entering directory
'/var/tmp/portage/x11-plugins/wmbiff-0.4.36/work/wmbiff-0.4.36/wmbiff'
x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe
-fdiagnostics-color=always -frecord-gcc-switches -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 -D_GNU_SOURCE -W -Wall -Wshadow
-Wpointer-arith -Wwrite-strings -Wl,-O1 -Wl,--as-needed -flto=4
-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
-Wl,--defsym=__gentoo_check_ldflags__=0 -o test_wmbiff ShellClient.o
charutil.o test_wmbiff.o passwordMgr.o Imap4Client.o regulo.o
Pop3Client.o tlsComm.o socket.o -lgcrypt -lgpg-error -lXpm -lXext -lX11
-lz -lresolv -lnsl -lgnutls
gnutls-common.h:28:5: error: type of ‘print_info’ does not match
original declaration [-Werror=lto-type-mismatch]
28 | int print_info( gnutls_session_t state, const char* hostname);
| ^
test_wmbiff.c:396:5: note: type mismatch in parameter 2
396 | int print_info(UNUSED(void *state))
| ^
test_wmbiff.c:396:5: note: ‘print_info’ 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
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:632: test_wmbiff] Error 1
```


Orginally reported downstream: https://bugs.gentoo.org/864855
Attached is my full build log.



--
Eli Schwartz
build.log
OpenPGP_0x84818A6819AF4A9B.asc
OpenPGP_signature.asc

Jeremy Sowden

unread,
May 15, 2024, 6:19:13 PMMay 15
to Eli Schwartz, wmake...@googlegroups.com
1. The test programmes define `print_info` functions to override the
real one in gnutls-common.c but use the wrong prototype.

2. The test programmes should be listed in `check_PROGRAMS`, not
`noinst_PROGRAMS`.

Patches to follow.

J.
signature.asc
Reply all
Reply to author
Forward
0 new messages