Bug 4616 - LTO build issue (failing compilation with -Werror=lto-type-mismatch)
Summary: LTO build issue (failing compilation with -Werror=lto-type-mismatch)
Status: NEW
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.1.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2022-07-22 19:13 UTC by Bernard Cafarelli
Modified: 2022-11-18 16:09 UTC (History)
0 users

See Also:


Attachments
LTO build log (compressed for size limit (47.99 KB, application/x-xz)
2022-07-23 21:55 UTC, Bernard Cafarelli
Details

Description Bernard Cafarelli 2022-07-22 19:13:39 UTC
How to reproduce (4.1 and current master):
CFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" ./configure

% grep HAVE_VA_OPT config.h
#define HAVE_VA_OPT 1


/bin/sh ../libtool  --tag=CC   --mode=link gcc -Wall -Wno-pointer-sign -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wl,--export-dynamic -o claws-mail account.o action.o addrcache.o addr_compl.o addressadd.o addrgather.o addrharvest.o addritem.o advsearch.o alertpanel.o autofaces.o avatars.o compose.o crash.o customheader.o displayheader.o edittags.o enriched.o entity.o export.o file_checker.o filtering.o folder.o folder_item_prefs.o foldersel.o folderutils.o folderview.o grouplistdialog.o headerview.o html.o image_viewer.o imap.o imap_gtk.o import.o inc.o localfolder.o main.o mainwindow.o manual.o matcher.o matcher_parser_lex.o matcher_parser_parse.o mbox.o message_search.o messageview.o mh.o mh_gtk.o mimeview.o msgcache.o news.o news_gtk.o noticeview.o oauth2.o partial_download.o password.o password_gtk.o passwordstore.o pop.o prefs_account.o prefs_actions.o prefs_common.o prefs_compose_writing.o prefs_customheader.o prefs_display_header.o prefs_ext_prog.o prefs_filtering_action.o prefs_filtering.o prefs_folder_item.o prefs_fonts.o prefs_gtk.o prefs_image_viewer.o prefs_logging.o prefs_matcher.o prefs_message.o prefs_migration.o prefs_msg_colors.o prefs_other.o prefs_proxy.o prefs_quote.o prefs_receive.o prefs_send.o prefs_spelling.o prefs_summaries.o prefs_summary_column.o prefs_summary_open.o prefs_folder_column.o prefs_template.o prefs_themes.o prefs_toolbar.o prefs_wrapping.o printing.o privacy.o procheader.o procmime.o procmsg.o quote_fmt.o quote_fmt_lex.o quote_fmt_parse.o recv.o remotefolder.o send_message.o setup.o sourcewindow.o ssl_manager.o statusbar.o stock_pixmap.o summary_search.o summaryview.o textview.o toolbar.o undo.o uri_opener.o wizard.o addrbook.o addrclip.o addrcustomattr.o addressbook.o addressbook_foldersel.o addrindex.o addrquery.o addrselect.o addrduplicates.o addrmerge.o browseldap.o editaddress.o editaddress_other_attributes_ldap.o editbook.o editgroup.o editjpilot.o editldap_basedn.o editldap.o editvcard.o exphtmldlg.o expldifdlg.o exporthtml.o exportldif.o importldif.o importmutt.o importpine.o jpilot.o ldapctrl.o ldaplocate.o ldapquery.o ldapserver.o ldapupdate.o ldaputil.o ldif.o mutt.o pine.o vcard.o etpan/libclawsetpan.la gtk/libclawsgtk.la -lenchant-2   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lcairo  -lresolv -lnsl -llber -lldap -lgnutls  -lnettle  -lcompface  -lpthread -lSM -lICE  -lstartup-notification-1  -letpan -lssl -lcrypto -lz -pthread  -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0  -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lcairo   -lm -lresolv -letpan -lssl -lcrypto -lz -pthread 
libtool: link: gcc -Wall -Wno-pointer-sign -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--export-dynamic -o claws-mail account.o action.o addrcache.o addr_compl.o addressadd.o addrgather.o addrharvest.o addritem.o advsearch.o alertpanel.o autofaces.o avatars.o compose.o crash.o customheader.o displayheader.o edittags.o enriched.o entity.o export.o file_checker.o filtering.o folder.o folder_item_prefs.o foldersel.o folderutils.o folderview.o grouplistdialog.o headerview.o html.o image_viewer.o imap.o imap_gtk.o import.o inc.o localfolder.o main.o mainwindow.o manual.o matcher.o matcher_parser_lex.o matcher_parser_parse.o mbox.o message_search.o messageview.o mh.o mh_gtk.o mimeview.o msgcache.o news.o news_gtk.o noticeview.o oauth2.o partial_download.o password.o password_gtk.o passwordstore.o pop.o prefs_account.o prefs_actions.o prefs_common.o prefs_compose_writing.o prefs_customheader.o prefs_display_header.o prefs_ext_prog.o prefs_filtering_action.o prefs_filtering.o prefs_folder_item.o prefs_fonts.o prefs_gtk.o prefs_image_viewer.o prefs_logging.o prefs_matcher.o prefs_message.o prefs_migration.o prefs_msg_colors.o prefs_other.o prefs_proxy.o prefs_quote.o prefs_receive.o prefs_send.o prefs_spelling.o prefs_summaries.o prefs_summary_column.o prefs_summary_open.o prefs_folder_column.o prefs_template.o prefs_themes.o prefs_toolbar.o prefs_wrapping.o printing.o privacy.o procheader.o procmime.o procmsg.o quote_fmt.o quote_fmt_lex.o quote_fmt_parse.o recv.o remotefolder.o send_message.o setup.o sourcewindow.o ssl_manager.o statusbar.o stock_pixmap.o summary_search.o summaryview.o textview.o toolbar.o undo.o uri_opener.o wizard.o addrbook.o addrclip.o addrcustomattr.o addressbook.o addressbook_foldersel.o addrindex.o addrquery.o addrselect.o addrduplicates.o addrmerge.o browseldap.o editaddress.o editaddress_other_attributes_ldap.o editbook.o editgroup.o editjpilot.o editldap_basedn.o editldap.o editvcard.o exphtmldlg.o expldifdlg.o exporthtml.o exportldif.o importldif.o importmutt.o importpine.o jpilot.o ldapctrl.o ldaplocate.o ldapquery.o ldapserver.o ldapupdate.o ldaputil.o ldif.o mutt.o pine.o vcard.o  etpan/.libs/libclawsetpan.a gtk/.libs/libclawsgtk.a -lgmodule-2.0 -lgthread-2.0 -lenchant-2 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lnsl -llber -lldap -lgnutls -lnettle -lcompface -lpthread -lSM -lICE -lstartup-notification-1 -ldbus-glib-1 -ldbus-1 -lrsvg-2 -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lcairo -lm -lresolv -letpan -lssl -lcrypto -lz -pthread
common/utils.h:484:6: error: type of 'debug_print_real' does not match original declaration [-Werror=lto-type-mismatch]
  484 | void debug_print_real (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
      |      ^
common/utils.c:2973:6: note: types have different parameter counts
 2973 | void debug_print_real(const char *file, int line, const gchar *format, ...)
      |      ^
common/utils.c:2973:6: note: 'debug_print_real' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1435: claws-mail] Error 1



Adding "#include "config.h" in the header "#ifdef HAVE_CONFIG_H" fixes the warning:
https://git.claws-mail.org/?p=claws.git;a=blob;f=src/common/utils.h;h=43f68a2ac63819a8db0b0ac2471ac2b4284f81c5;hb=HEAD#l26


Downstream bug: https://bugs.gentoo.org/859490
Comment 1 Paul 2022-07-23 13:14:17 UTC
I used the CFLAGS yopu indicated but cannot reproduce this. The build completes.
Comment 2 Bernard Cafarelli 2022-07-23 21:55:46 UTC
Created attachment 2295 [details]
LTO build log (compressed for size limit

Is it with clang? A quick run with CC=clang seems to indeed go through (I have another error in itehtml_viewer.so with it that I need to check, but claws-mail binary itself builds).
Locally, I checked with gcc 11.3.0 and 12.1.1 and both triggered the issue, here is the full configure+make output log
Comment 3 Paul 2022-07-23 23:33:58 UTC
gcc 12.1.1 here
Comment 4 Bernard Cafarelli 2022-07-25 15:50:51 UTC
This is strange, I tested on some of my work systems, both have the error (x86_64):
* Fedora release 36 - gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)
* Ubuntu 20.04.4 LTS (Focal Fossa) - gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

Just running on a fresh git checkout:
% ./autogen.sh
% CFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" ./configure
% make # same result with or without -j$(nproc)

This is a manual run of the link command generated by libtool (Fedora, Ubuntu error was similar but less detailed)
(git)-[be0f05095c9f master ]% gcc -Wall -Wno-pointer-sign -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--export-dynamic -o claws-mail account.o action.o addrcache.o addr_compl.o addressadd.o addrgather.o addrharvest.o addritem.o advsearch.o alertpanel.o autofaces.o avatars.o compose.o crash.o customheader.o displayheader.o edittags.o enriched.o entity.o export.o file_checker.o filtering.o folder.o folder_item_prefs.o foldersel.o folderutils.o folderview.o grouplistdialog.o headerview.o html.o image_viewer.o imap.o imap_gtk.o import.o inc.o localfolder.o main.o mainwindow.o manual.o matcher.o matcher_parser_lex.o matcher_parser_parse.o mbox.o message_search.o messageview.o mh.o mh_gtk.o mimeview.o msgcache.o news.o news_gtk.o noticeview.o oauth2.o partial_download.o password.o password_gtk.o passwordstore.o pop.o prefs_account.o prefs_actions.o prefs_common.o prefs_compose_writing.o prefs_customheader.o prefs_display_header.o prefs_ext_prog.o prefs_filtering_action.o prefs_filtering.o prefs_folder_item.o prefs_fonts.o prefs_gtk.o prefs_image_viewer.o prefs_logging.o prefs_matcher.o prefs_message.o prefs_migration.o prefs_msg_colors.o prefs_other.o prefs_proxy.o prefs_quote.o prefs_receive.o prefs_send.o prefs_spelling.o prefs_summaries.o prefs_summary_column.o prefs_summary_open.o prefs_folder_column.o prefs_template.o prefs_themes.o prefs_toolbar.o prefs_wrapping.o printing.o privacy.o procheader.o procmime.o procmsg.o quote_fmt.o quote_fmt_lex.o quote_fmt_parse.o recv.o remotefolder.o send_message.o setup.o sourcewindow.o ssl_manager.o statusbar.o stock_pixmap.o summary_search.o summaryview.o textview.o toolbar.o undo.o uri_opener.o wizard.o addrbook.o addrclip.o addrcustomattr.o addressbook.o addressbook_foldersel.o addrindex.o addrquery.o addrselect.o addrduplicates.o addrmerge.o browseldap.o editaddress.o editaddress_other_attributes_ldap.o editbook.o editgroup.o editjpilot.o editldap_basedn.o editldap.o editvcard.o exphtmldlg.o expldifdlg.o exporthtml.o exportldif.o importldif.o importmutt.o importpine.o jpilot.o ldapctrl.o ldaplocate.o ldapquery.o ldapserver.o ldapupdate.o ldaputil.o ldif.o mutt.o pine.o vcard.o  etpan/.libs/libclawsetpan.a gtk/.libs/libclawsgtk.a -lgmodule-2.0 -lgthread-2.0 -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lgdk_pixbuf-2.0 -lgio-2.0 -lcairo -lgnutls -lnettle -lpthread -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 -lm -lresolv -letpan -pthread
common/utils.h:484:6: error: type of 'debug_print_real' does not match original declaration [-Werror=lto-type-mismatch]
  484 | void debug_print_real (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
      |      ^
common/utils.c:2973:6: note: types have different parameter counts
 2973 | void debug_print_real(const char *file, int line, const gchar *format, ...)
      |      ^
common/utils.c:2973:6: note: 'debug_print_real' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Comment 5 Bernard Cafarelli 2022-11-18 16:09:59 UTC
Mentioned fix added to Gentoo ebuild for 4.1.1:
https://gitweb.gentoo.org/repo/gentoo.git/tree/mail-client/claws-mail/files/claws-mail-4.1.1-fix_lto.patch

Note You need to log in before you can comment on or make changes to this bug.