Re: Gtk::Builder::get_widget_derived() Issue on Fedora 33

Kjell Ahlstedt via gtkmm-list <[email protected]> Wed, 18 Nov 2020 11:37:55 +0100
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
You're on the right track. I built gtkmm with the -flto compile and link 
option (and gcc 9.3.0). Then Ahmet's test case does not work.

I then removed the redefiniton of G_GNUC_CONST and wrapped the call to 
Gtk::TextView::get_type() in a call to g_type_ensure() in wrap_init.cc. 
The test case then works even with LTO enabled.

I guess that with LTO the linker notices that the get_type() methods are 
declared with __attribute__((__const__)) (from the expansion of 
G_GNUC_CONST) in one compilation unit and then assumes that it's okay to 
optimize as if it were declared that way everywhere.

g_type_ensure() is safer than the redefinition of G_GNUC_CONST. I'll fix 
this in glibmm/tools/generate_wrap_init.pl.in. (wrap_init.cc is 
generated by generate_wrap_init.pl.) It will probably take quite some 
time before this fix is available in released versions of all affected 
mm packages. Meanwhile it would be fine if Fedora and other distros 
could build the mm packages without LTO.

On 2020-11-17 22:44, Andrew Potter wrote:
> I believe this is caused by https://fedoraproject.org/wiki/LTOByDefault
>
> I built the srpm and noticed that the get_type() calls were present in 
> wrap_init.o but was missing from the .so
>
> I added
> %define _lto_cflags %{nil}
> to the gtkmm .spec file and rebuilt--this disables LTO; the get_type() 
> were then present in the .so
>
> I've left a comment at Fedora's bug tracker for them to disable lto in 
> mm packagesI've left a comment at Fedora's bug tracker for them to 
> disable lto in mm packages. But if we used g_type_ensure() then LTO 
> would be possible I think
>
>

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list