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

LTO build fails #259

Closed
kloczek opened this issue Feb 11, 2019 · 17 comments
Closed

LTO build fails #259

kloczek opened this issue Feb 11, 2019 · 17 comments

Comments

@kloczek
Copy link

kloczek commented Feb 11, 2019

To reporoduce this you need to configure source tree by:
$ CFAL:GS="-flto" LDFLAGS="-flto -fuse-linker-plugin" AR=gcc-ar RANLIB=gcc-ranlib NM=gcc-nm ./configure <optiions>

/usr/bin/sed -e 's,[@]GETTEXT_PACKAGE[@],GPaste,g' < data/control-center/42-gpaste.control-center.xml.in > data/control-center/42-gpaste.xml
CPPFLAGS="" CFLAGS="-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -flto -pipe -pedantic -DANOTHER_BRICK_IN_THE -Wall -W -Wextra -Wvla -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unknown-warning-option -Wno-float-equal -Werror=overflow -Wp,-D_FORTIFY_SOURCE=2 -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -ffunction-sections -fdata-sections" LDFLAGS="-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto -fuse-linker-plugin -Wl,--as-needed -Wl,--gc-sections" CC="gcc" PKG_CONFIG="/usr/bin/x86_64-redhat-linux-gnu-pkg-config" GI_HOST_OS="" DLLTOOL="false"  /usr/bin/g-ir-scanner   --namespace=GPaste --nsversion=1.0 --libtool="/bin/sh ./libtool"  --include=GdkPixbuf-2.0 --include=Gio-2.0 --include=GObject-2.0 --include=Gtk-3.0 --pkg-export=libgpaste --c-include=gpaste.h  --library=lib/libgpaste.la --warn-all --cflags-begin -include config.h -I./src/libgpaste -I./src/libgpaste/client -I./src/libgpaste/core -I./src/libgpaste/daemon -I./src/libgpaste/gnome-shell-client -I./src/libgpaste/io -I./src/libgpaste/keybinder -I./src/libgpaste/screensaver-client -I./src/libgpaste/settings -I./src/libgpaste/settings-ui -I./src/libgpaste/ui -I./src/libgpaste/util -DG_PASTE_COMPILATION -DGTK_API=3 -DLOCALEDIR=\"/usr/share/locale\" -DPKGLIBEXECDIR=\"/usr/libexec/gpaste\" -DG_LOG_USE_STRUCTURED=1 -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED   --cflags-end  src/libgpaste/gpaste-gdbus-defines.h src/libgpaste/gpaste-gsettings-keys.h src/libgpaste/gpaste-macros.h src/libgpaste/util/gpaste-util.h src/libgpaste/gpaste.h src/libgpaste/client/gpaste-client.h src/libgpaste/core/gpaste-clipboard.h src/libgpaste/core/gpaste-clipboards-manager.h src/libgpaste/core/gpaste-history.h src/libgpaste/core/gpaste-image-item.h src/libgpaste/core/gpaste-item.h src/libgpaste/core/gpaste-password-item.h src/libgpaste/core/gpaste-text-item.h src/libgpaste/core/gpaste-item-enums.h src/libgpaste/core/gpaste-special-atom.h src/libgpaste/core/gpaste-update-enums.h src/libgpaste/core/gpaste-uris-item.h src/libgpaste/daemon/gpaste-bus.h src/libgpaste/daemon/gpaste-bus-object.h src/libgpaste/daemon/gpaste-daemon.h src/libgpaste/daemon/gpaste-search-provider.h src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.h src/libgpaste/io/gpaste-file-backend.h src/libgpaste/io/gpaste-storage-backend.h src/libgpaste/keybinder/gpaste-keybinder.h src/libgpaste/keybinder/gpaste-keybinding.h src/libgpaste/keybinder/gpaste-make-password-keybinding.h src/libgpaste/keybinder/gpaste-pop-keybinding.h src/libgpaste/keybinder/gpaste-show-history-keybinding.h src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.h src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.h src/libgpaste/keybinder/gpaste-ui-keybinding.h src/libgpaste/keybinder/gpaste-upload-keybinding.h src/libgpaste/screensaver-client/gpaste-screensaver-client.h src/libgpaste/settings/gpaste-settings.h src/libgpaste/settings-ui/gpaste-settings-ui-panel.h src/libgpaste/settings-ui/gpaste-settings-ui-stack.h src/libgpaste/settings-ui/gpaste-settings-ui-widget.h src/libgpaste/ui/gpaste-ui-about.h src/libgpaste/ui/gpaste-ui-backup-history.h src/libgpaste/ui/gpaste-ui-delete-history.h src/libgpaste/ui/gpaste-ui-delete-item.h src/libgpaste/ui/gpaste-ui-edit-item.h src/libgpaste/ui/gpaste-ui-empty-history.h src/libgpaste/ui/gpaste-ui-empty-item.h src/libgpaste/ui/gpaste-ui-header.h src/libgpaste/ui/gpaste-ui-history.h src/libgpaste/ui/gpaste-ui-history-action.h src/libgpaste/ui/gpaste-ui-history-actions.h src/libgpaste/ui/gpaste-ui-item.h src/libgpaste/ui/gpaste-ui-item-action.h src/libgpaste/ui/gpaste-ui-item-skeleton.h src/libgpaste/ui/gpaste-ui-new-item.h src/libgpaste/ui/gpaste-ui-panel.h src/libgpaste/ui/gpaste-ui-panel-history.h src/libgpaste/ui/gpaste-ui-reexec.h src/libgpaste/ui/gpaste-ui-search.h src/libgpaste/ui/gpaste-ui-search-bar.h src/libgpaste/ui/gpaste-ui-settings.h src/libgpaste/ui/gpaste-ui-shortcuts-window.h src/libgpaste/ui/gpaste-ui-switch.h src/libgpaste/ui/gpaste-ui-upload-item.h src/libgpaste/ui/gpaste-ui-window.h src/libgpaste/gpaste-gdbus-macros.h src/libgpaste/gpaste-gtk-compat.h src/libgpaste/client/gpaste-client.c src/libgpaste/core/gpaste-clipboard.c src/libgpaste/core/gpaste-clipboards-manager.c src/libgpaste/core/gpaste-history.c src/libgpaste/core/gpaste-image-item.c src/libgpaste/core/gpaste-item.c src/libgpaste/core/gpaste-password-item.c src/libgpaste/core/gpaste-text-item.c src/libgpaste/core/gpaste-item-enums.c src/libgpaste/core/gpaste-special-atom.c src/libgpaste/core/gpaste-update-enums.c src/libgpaste/core/gpaste-uris-item.c src/libgpaste/daemon/gpaste-bus.c src/libgpaste/daemon/gpaste-bus-object.c src/libgpaste/daemon/gpaste-daemon.c src/libgpaste/daemon/gpaste-search-provider.c src/libgpaste/gnome-shell-client/gpaste-gnome-shell-client.c src/libgpaste/io/gpaste-file-backend.c src/libgpaste/io/gpaste-storage-backend.c src/libgpaste/keybinder/gpaste-keybinder.c src/libgpaste/keybinder/gpaste-keybinding.c src/libgpaste/keybinder/gpaste-make-password-keybinding.c src/libgpaste/keybinder/gpaste-pop-keybinding.c src/libgpaste/keybinder/gpaste-show-history-keybinding.c src/libgpaste/keybinder/gpaste-sync-clipboard-to-primary-keybinding.c src/libgpaste/keybinder/gpaste-sync-primary-to-clipboard-keybinding.c src/libgpaste/keybinder/gpaste-ui-keybinding.c src/libgpaste/keybinder/gpaste-upload-keybinding.c src/libgpaste/screensaver-client/gpaste-screensaver-client.c src/libgpaste/settings/gpaste-settings.c src/libgpaste/settings-ui/gpaste-settings-ui-panel.c src/libgpaste/settings-ui/gpaste-settings-ui-stack.c src/libgpaste/settings-ui/gpaste-settings-ui-widget.c src/libgpaste/ui/gpaste-ui-about.c src/libgpaste/ui/gpaste-ui-backup-history.c src/libgpaste/ui/gpaste-ui-delete-history.c src/libgpaste/ui/gpaste-ui-delete-item.c src/libgpaste/ui/gpaste-ui-edit-item.c src/libgpaste/ui/gpaste-ui-empty-history.c src/libgpaste/ui/gpaste-ui-empty-item.c src/libgpaste/ui/gpaste-ui-header.c src/libgpaste/ui/gpaste-ui-history.c src/libgpaste/ui/gpaste-ui-history-action.c src/libgpaste/ui/gpaste-ui-history-actions.c src/libgpaste/ui/gpaste-ui-item.c src/libgpaste/ui/gpaste-ui-item-action.c src/libgpaste/ui/gpaste-ui-item-skeleton.c src/libgpaste/ui/gpaste-ui-new-item.c src/libgpaste/ui/gpaste-ui-panel.c src/libgpaste/ui/gpaste-ui-panel-history.c src/libgpaste/ui/gpaste-ui-reexec.c src/libgpaste/ui/gpaste-ui-search.c src/libgpaste/ui/gpaste-ui-search-bar.c src/libgpaste/ui/gpaste-ui-settings.c src/libgpaste/ui/gpaste-ui-shortcuts-window.c src/libgpaste/ui/gpaste-ui-switch.c src/libgpaste/ui/gpaste-ui-upload-item.c src/libgpaste/ui/gpaste-ui-window.c src/libgpaste/util/gpaste-util.c lib/libgpaste.la --output bindings/GPaste-1.0.gir
g-ir-scanner: link: /bin/sh ./libtool --mode=link --tag=CC gcc -o /home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/GPaste-1.0 -export-dynamic -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -flto -pipe -pedantic -DANOTHER_BRICK_IN_THE -Wall -W -Wextra -Wvla -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unknown-warning-option -Wno-float-equal -Werror=overflow -Wp,-D_FORTIFY_SOURCE=2 -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -ffunction-sections -fdata-sections /home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/GPaste-1.0.o -L. lib/libgpaste.la -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -lglib-2.0 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto -fuse-linker-plugin -Wl,--as-needed -Wl,--gc-sections
libtool: link: gcc -o /home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/.libs/GPaste-1.0 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -flto -pipe -pedantic -DANOTHER_BRICK_IN_THE -Wall -W -Wextra -Wvla -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unknown-warning-option -Wno-float-equal -Werror=overflow -Wp,-D_FORTIFY_SOURCE=2 -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -ffunction-sections -fdata-sections /home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/GPaste-1.0.o -Wl,--export-dynamic -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto -fuse-linker-plugin -Wl,--as-needed -Wl,--gc-sections -Wl,--export-dynamic  -L. lib/.libs/libgpaste.so -lgtk-3 -lgdk-3 -lpangocairo-1.0 -latk-1.0 -lcairo-gobject -lcairo -lpixman-1 -lfontconfig -lfreetype -lpng16 -lz -lxcb-shm -lxcb -lxcb-render -lXrender -lXext -lgdk_pixbuf-2.0 -lpango-1.0 -lX11 -lXi -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0
Invalid GType function: 'g_paste_settings_get_type'
Failed to find symbol 'g_paste_settings_get_type'
Command '['/home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/GPaste-1.0', '--introspect-dump=/home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/functions.txt,/home/tkloczko/rpmbuild/BUILD/gpaste-3.30.2/tmp-introspectid6_up2g/dump.xml']' returned non-zero exit status 1.
make[2]: *** [/usr/share/gobject-introspection-1.0/Makefile.introspection:156: bindings/GPaste-1.0.gir] Error 1
make[1]: *** [Makefile:2757: all-recursive] Error 1
make: *** [Makefile:1286: all] Error 2
@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

Enabling everything bug introspection (and vapi + gnome-shell extension that depends on it, but those do not involve compilation) builds fine, so it looks like gobject-introspection integration is the culprit.

Did you manage to build another project that uses introspection with LTO?

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

Fixed in the 3.30 branch, will see if I have some other fix pending and make a new release soon-ish

@kloczek
Copy link
Author

kloczek commented Feb 12, 2019

You know .. it still fails with lto.
Patch like this is more like hiding the the bug than fixing it :/

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019 via email

@kloczek
Copy link
Author

kloczek commented Feb 12, 2019

I have all other gnome packages build with using lto and many are using gobject-introspection.
Only gpaste hast LTO linking issue.
And g_paste_settings_get_type it is gpaste symbol.
How it is possible that it is gobject-introspection issue? Can you drop some details telling that it is g-o issue?

regards

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

I'm not really familiar with lto tbh.
All I know is that the so contains the symbol, even with lto (or so does nm tell me at least), so I don't really get what the root cause could be.
Also, I fail to see the point of lto for the typelib

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

Note that gtk itself has the same problem: https://gitlab.gnome.org/GNOME/gtk/issues/1309

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

It seems that building with bfd fails while building with gold works.

Will thus revert my change. I guess the answer here is: if you want to build with LTO, use gold

@Keruspe
Copy link
Owner

Keruspe commented Feb 12, 2019

Is it a more satisfactory solution for you?

@kloczek
Copy link
Author

kloczek commented Feb 12, 2019

I'm not sure.
That depends it it some issue in bdf ld or real issue with gpaste source code.
Will try to open ticket against binutils :)
Let's keep for now this ticket opened :p

@kloczek
Copy link
Author

kloczek commented Feb 12, 2019

@kloczek
Copy link
Author

kloczek commented Feb 14, 2019

Please find new comments under https://bugzilla.redhat.com/show_bug.cgi?id=1676679
There is no IMO clear answer on what needs to be corrected.
I did not mention originally that reported issue was when I'v been building gpaste against latest mutter.
I'm interested about your comment in current situation :)

@Keruspe
Copy link
Owner

Keruspe commented Feb 14, 2019

The version of libmutter shouldn't matter.

The symbol does exist, it's created by a glib macro.

keruspe@Lou ~/Projects/GPaste (git)-[gpaste-3.30] % nm lib/.libs/libgpaste.so.11.1.1 | grep g_paste_settings_get_type
000000000001fb10 T g_paste_settings_get_type
000000000001e660 t g_paste_settings_get_type_once

@Keruspe
Copy link
Owner

Keruspe commented Feb 14, 2019

Note that with the patch from that bug, the same problem still occurs

@kloczek
Copy link
Author

kloczek commented Feb 15, 2019

The version of libmutter shouldn't matter.

Indeed. Looks like it is bug in ld.
Let's wait a bit on binutils maintainers :)

@kloczek
Copy link
Author

kloczek commented Feb 21, 2019

I just found a little time to investigate this issue and looks like it is bug in gpaste because:

[tkloczko@domek gpaste-3.30.2]$ grep -r g_paste_settings_get_type
src/libgpaste/settings/gpaste-settings.h:#define G_PASTE_TYPE_SETTINGS (g_paste_settings_get_type ())
src/libgpaste/libgpaste.sym:    g_paste_settings_get_type;

In other words you've created symbol and put it in library interface but it is nothing behind it.
Other issue is with gcc or ld that kind of bugs is somehow hide and that is another part of the story.

So in the libgpaste interface you have g_paste_settings_get_type but this symbol is used to define G_PASTE_TYPE_SETTINGS. Than this define is used in another define in src/libgpaste/settings/gpaste-settings.c:

[tkloczko@domek gpaste-3.30.2]$ grep -wr G_PASTE_TYPE_SETTINGS
src/libgpaste/settings/gpaste-settings.h:#define G_PASTE_TYPE_SETTINGS (g_paste_settings_get_type ())
src/libgpaste/settings/gpaste-settings.c:                  G_PASTE_TYPE_SETTINGS,             \
src/libgpaste/settings/gpaste-settings.c:    return g_object_new (G_PASTE_TYPE_SETTINGS, NULL);

I'm not fully understand gobject interface. Can you have look on this as well?

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

No branches or pull requests

2 participants