[glibmm] generate_wrap_init.pl.in: Use g_type_ensure()



commit bd0dc47262262901d131f78570f8f5fc47c6859c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Wed Nov 18 14:43:11 2020 +0100

    generate_wrap_init.pl.in: Use g_type_ensure()
    
    Call g_type_ensure(SomeClass::get_type()).
    
    Redefining the G_GNUC_CONST preprocessor macro does not have the
    intended effect (SomeClass::get_type() actually being called) if
    the package is compiled and linked with the -flto option.
    LTO = link time optimization
    
    https://mail.gnome.org/archives/gtkmm-list/2020-November/msg00009.html

 tools/generate_wrap_init.pl.in | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
---
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 6e4dcf3c..50e08275 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -207,12 +207,6 @@ print << "EOF";
 
 #define GLIBMM_INCLUDED_FROM_WRAP_INIT_CC
 #include <glibmm.h>
-
-// Disable the 'const' function attribute of the get_type() functions.
-// GCC would optimize them out because we don't use the return value.
-#undef  G_GNUC_CONST
-#define G_GNUC_CONST /* empty */
-
 #include <${parent_dir}/wrap_init.h>
 #include <glibmm/error.h>
 #include <glibmm/object.h>
@@ -437,7 +431,7 @@ foreach my $filename_header (sort keys %objects)
   {
     my ($cppname, $basename, @extra_namespace) = @{$i};
     my $qualified_cppname = join("::", (@extra_namespace, $cppname));
-    $message .= "  ${qualified_cppname}::get_type();\n"
+    $message .= "  g_type_ensure(${qualified_cppname}::get_type());\n"
   }
   print_with_guards($filename_header, $message);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]