After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 619721 - Initialization routine calls in native module is GNU C specific
Initialization routine calls in native module is GNU C specific
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Solaris
: Normal major
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-05-26 13:58 UTC by Erwann Chenede
Modified: 2012-11-06 17:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Erwann Chenede 2010-05-26 13:58:55 UTC
GJS_REGISTER_NATIVE_MODULE_WITH_FLAGS (in gjs/native.h)
defines shared objects initialization routines using GNU C specific annotation.
When running gjs compiled with Sun's compiler native modules cannot register 
as the __attribute__((constructor)) is ignored.

Please find below a patch to fix this problem.

--- gjs-0.7/gjs/native.h        2010-04-18 02:55:15.000000000 +0200
+++ gjs-0.7-sunpro/gjs/native.h 2010-05-26 14:29:17.761796993 +0200
@@ -65,8 +65,18 @@
 typedef JSBool (* GjsDefineModuleFunc) (JSContext *context,
                                         JSObject  *module_obj);
 
+#ifdef __GNUC__
+#define INIT __attribute__((constructor))
+#elif __SUNPRO_C
+#define Pragma(x) _Pragma(#x)
+#define INIT Pragma(init(register_native_module))
+#else
+Initialization routine in a dynamic object not defined for current compiler
+#endif
+
 #define GJS_REGISTER_NATIVE_MODULE_WITH_FLAGS(module_id_string, module_func, flags) \
-    __attribute__((constructor)) static void                                 \
+    INIT                                            \
+    static void                                                                     \
     register_native_module (void)                                            \
     {                                                                        \
         gjs_register_native_module(module_id_string, module_func, flags); \
Comment 1 Colin Walters 2012-11-06 17:57:39 UTC
Merged this patch with minor tweaks.  I spent a bit of time writing a
patch to reuse gconstructor.h from GLib before I realized it's not
exported...