Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail with LTO due to type mismatch in unittest #1992

Closed
eli-schwartz opened this issue Aug 5, 2024 · 3 comments · Fixed by #1993
Closed

Tests fail with LTO due to type mismatch in unittest #1992

eli-schwartz opened this issue Aug 5, 2024 · 3 comments · Fixed by #1993
Assignees
Labels
Milestone

Comments

@eli-schwartz
Copy link

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:

/bin/sh ./libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw -Wall -Wno-deprecated-declarations -std=gnu99 -ggdb3 -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid   -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/fribidi -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/gio-unix-2.0 -I/usr/lib64/libffi/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid  -DTHEMES_PATH="\"/usr/share/profanity/themes\"" -DICONS_PATH="\"/usr/share/profanity/icons\"" -DGLOBAL_PYTHON_PLUGINS_PATH="\"\"" -DGLOBAL_C_PLUGINS_PATH="\"/usr/lib64/profanity/plugins\"" -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -pipe -march=native -fstack-protector-all -O2 -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 -DLIBXMPP_VERSION_MAJOR=0 -DLIBXMPP_VERSION_MINOR=13 -I/usr/include/libxml2 -I./src -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -pipe -march=native -fstack-protector-all -O2 -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 -DLIBXMPP_VERSION_MAJOR=0 -DLIBXMPP_VERSION_MINOR=13 -I/usr/include/libxml2 -export-dynamic -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o tests/unittests/unittests src/xmpp/contact.o src/common.o src/profanity.o src/xmpp/chat_session.o src/xmpp/muc.o src/xmpp/jid.o src/xmpp/resource.o src/xmpp/chat_state.o src/xmpp/roster_list.o src/xmpp/form.o src/command/cmd_defs.o src/command/cmd_funcs.o src/command/cmd_ac.o src/tools/parser.o src/tools/autocomplete.o src/tools/clipboard.o src/tools/editor.o src/tools/bookmark_ignore.o src/config/account.o src/config/files.o src/config/tlscerts.o src/config/preferences.o src/config/theme.o src/config/color.o src/config/scripts.o src/config/conflists.o src/plugins/plugins.o src/plugins/api.o src/plugins/callbacks.o src/plugins/autocompleters.o src/plugins/themes.o src/plugins/settings.o src/plugins/disco.o src/ui/window_list.o src/event/common.o src/event/server_events.o src/event/client_events.o src/ui/tray.o tests/unittests/xmpp/stub_vcard.o tests/unittests/xmpp/stub_avatar.o tests/unittests/xmpp/stub_ox.o tests/unittests/xmpp/stub_xmpp.o tests/unittests/xmpp/stub_message.o tests/unittests/ui/stub_ui.o tests/unittests/ui/stub_vcardwin.o tests/unittests/log/stub_log.o tests/unittests/chatlog/stub_chatlog.o tests/unittests/database/stub_database.o tests/unittests/config/stub_accounts.o tests/unittests/config/stub_cafile.o tests/unittests/tools/stub_http_upload.o tests/unittests/tools/stub_http_download.o tests/unittests/tools/stub_aesgcm_download.o tests/unittests/tools/stub_plugin_download.o tests/unittests/helpers.o tests/unittests/test_form.o tests/unittests/test_common.o tests/unittests/test_autocomplete.o tests/unittests/test_jid.o tests/unittests/test_parser.o tests/unittests/test_roster_list.o tests/unittests/test_chat_session.o tests/unittests/test_contact.o tests/unittests/test_preferences.o tests/unittests/test_server_events.o tests/unittests/test_muc.o tests/unittests/test_cmd_presence.o tests/unittests/test_cmd_alias.o tests/unittests/test_cmd_connect.o tests/unittests/test_cmd_rooms.o tests/unittests/test_cmd_account.o tests/unittests/test_cmd_sub.o tests/unittests/test_cmd_bookmark.o tests/unittests/test_cmd_otr.o tests/unittests/test_cmd_pgp.o tests/unittests/test_cmd_join.o tests/unittests/test_cmd_roster.o tests/unittests/test_cmd_disconnect.o tests/unittests/test_callbacks.o tests/unittests/test_plugins_disco.o tests/unittests/unittests.o  src/plugins/c_plugins.o src/plugins/c_api.o    -lcmocka -lglib-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lpthread -lcurl -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lsqlite3 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lreadline -lncursesw -ltinfow -lstrophe -lm  -ldl
libtool: link: x86_64-pc-linux-gnu-gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw -Wall -Wno-deprecated-declarations -std=gnu99 -ggdb3 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/atk-1.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/fribidi -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/gio-unix-2.0 -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -DTHEMES_PATH=\"/usr/share/profanity/themes\" -DICONS_PATH=\"/usr/share/profanity/icons\" -DGLOBAL_PYTHON_PLUGINS_PATH=\"\" -DGLOBAL_C_PLUGINS_PATH=\"/usr/lib64/profanity/plugins\" -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -pipe -march=native -fstack-protector-all -O2 -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 -DLIBXMPP_VERSION_MAJOR=0 -DLIBXMPP_VERSION_MINOR=13 -I/usr/include/libxml2 -I./src -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/lib64/libffi/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -pipe -march=native -fstack-protector-all -O2 -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 -DLIBXMPP_VERSION_MAJOR=0 -DLIBXMPP_VERSION_MINOR=13 -I/usr/include/libxml2 -Wl,-O1 -Wl,--as-needed -Wl,-z -Wl,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o tests/unittests/unittests src/xmpp/contact.o src/common.o src/profanity.o src/xmpp/chat_session.o src/xmpp/muc.o src/xmpp/jid.o src/xmpp/resource.o src/xmpp/chat_state.o src/xmpp/roster_list.o src/xmpp/form.o src/command/cmd_defs.o src/command/cmd_funcs.o src/command/cmd_ac.o src/tools/parser.o src/tools/autocomplete.o src/tools/clipboard.o src/tools/editor.o src/tools/bookmark_ignore.o src/config/account.o src/config/files.o src/config/tlscerts.o src/config/preferences.o src/config/theme.o src/config/color.o src/config/scripts.o src/config/conflists.o src/plugins/plugins.o src/plugins/api.o src/plugins/callbacks.o src/plugins/autocompleters.o src/plugins/themes.o src/plugins/settings.o src/plugins/disco.o src/ui/window_list.o src/event/common.o src/event/server_events.o src/event/client_events.o src/ui/tray.o tests/unittests/xmpp/stub_vcard.o tests/unittests/xmpp/stub_avatar.o tests/unittests/xmpp/stub_ox.o tests/unittests/xmpp/stub_xmpp.o tests/unittests/xmpp/stub_message.o tests/unittests/ui/stub_ui.o tests/unittests/ui/stub_vcardwin.o tests/unittests/log/stub_log.o tests/unittests/chatlog/stub_chatlog.o tests/unittests/database/stub_database.o tests/unittests/config/stub_accounts.o tests/unittests/config/stub_cafile.o tests/unittests/tools/stub_http_upload.o tests/unittests/tools/stub_http_download.o tests/unittests/tools/stub_aesgcm_download.o tests/unittests/tools/stub_plugin_download.o tests/unittests/helpers.o tests/unittests/test_form.o tests/unittests/test_common.o tests/unittests/test_autocomplete.o tests/unittests/test_jid.o tests/unittests/test_parser.o tests/unittests/test_roster_list.o tests/unittests/test_chat_session.o tests/unittests/test_contact.o tests/unittests/test_preferences.o tests/unittests/test_server_events.o tests/unittests/test_muc.o tests/unittests/test_cmd_presence.o tests/unittests/test_cmd_alias.o tests/unittests/test_cmd_connect.o tests/unittests/test_cmd_rooms.o tests/unittests/test_cmd_account.o tests/unittests/test_cmd_sub.o tests/unittests/test_cmd_bookmark.o tests/unittests/test_cmd_otr.o tests/unittests/test_cmd_pgp.o tests/unittests/test_cmd_join.o tests/unittests/test_cmd_roster.o tests/unittests/test_cmd_disconnect.o tests/unittests/test_callbacks.o tests/unittests/test_plugins_disco.o tests/unittests/unittests.o src/plugins/c_plugins.o src/plugins/c_api.o -Wl,--export-dynamic  -lcmocka -lpthread -lcurl -lnotify -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgio-2.0 -lsqlite3 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lreadline -lncursesw -ltinfow -lstrophe -lm -ldl -pthread
./src/config/accounts.h:48:7: error: type of 'accounts_find_enabled' does not match original declaration [-Werror=lto-type-mismatch]
   48 | char* accounts_find_enabled(const char* const prefix, gboolean previous, void* context);
      |       ^
tests/unittests/config/stub_accounts.c:25:1: note: type mismatch in parameter 2
   25 | accounts_find_enabled(char* prefix, void* context)
      | ^
tests/unittests/config/stub_accounts.c:25:1: note: 'accounts_find_enabled' was previously declared here
./src/xmpp/avatar.h:42:10: error: type of 'avatar_get_by_nick' does not match original declaration [-Werror=lto-type-mismatch]
   42 | gboolean avatar_get_by_nick(const char* nick, gboolean open);
      |          ^
tests/unittests/xmpp/stub_avatar.c:7:1: note: type mismatch in parameter 2
    7 | avatar_get_by_nick(const char* nick)
      | ^
tests/unittests/xmpp/stub_avatar.c:7:1: note: type 'void' should match type 'gboolean'
tests/unittests/xmpp/stub_avatar.c:7:1: note: 'avatar_get_by_nick' was previously declared here
./src/tools/http_upload.h:72:7: error: type of 'file_size' does not match original declaration [-Werror=lto-type-mismatch]
   72 | off_t file_size(int filedes);
      |       ^
tests/unittests/tools/stub_http_upload.c:36:1: note: type mismatch in parameter 1
   36 | file_size(const char* const file_name)
      | ^
tests/unittests/tools/stub_http_upload.c:36:1: note: 'file_size' was previously declared here
./src/config/accounts.h:51:6: error: type of 'accounts_add' does not match original declaration [-Werror=lto-type-mismatch]
   51 | void accounts_add(const char* jid, const char* altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
      |      ^
tests/unittests/config/stub_accounts.c:40:1: note: type mismatch in parameter 4
   40 | accounts_add(const char* jid, const char* altdomain, const int port)
      | ^
tests/unittests/config/stub_accounts.c:40:1: note: 'accounts_add' 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:1893: tests/unittests/unittests] Error 1

Originally reported downstream: https://bugs.gentoo.org/932874
Full build log: build.log

@jubalh jubalh self-assigned this Aug 5, 2024
@jubalh jubalh added the cleanup label Aug 5, 2024
@jubalh jubalh added this to the next milestone Aug 5, 2024
@jubalh
Copy link
Member

jubalh commented Aug 5, 2024

Thanks for the report.
Could you test: #1993 ?

@sjaeckel
Copy link
Member

sjaeckel commented Aug 5, 2024

Maybe we should also add those compiler flags to the (test) build?

@eli-schwartz
Copy link
Author

Yup, that PR works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants