summaryrefslogtreecommitdiff
path: root/gmodule
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-10-03 10:36:04 -0400
committerXavier Claessens <xavier.claessens@collabora.com>2022-10-13 20:53:56 -0400
commitdcfc9f689e2483d7735bdc90fb36201838c1854f (patch)
treecce87e4e00d6984840382bcebb6034a6c870002a /gmodule
parentd40459c280b28cfe84f7e590b7d10d344661df2d (diff)
downloadglib-dcfc9f689e2483d7735bdc90fb36201838c1854f.tar.gz
Fix symbol visibility macros on Windows
There is currently no `dllimport` attribute on any of our function, which prevents MSVC to optimize function calls. To fix that issue, we need to redeclare all our visibility macros for each of our libraries, because when compiling e.g. GIO code, we need dllimport in GLIB headers and dllexport in GIO headers. That means they cannot use the same GLIB_AVAILABLE_* macro. Since that's a lot of boilerplate to copy/paste after each version bump, this MR generate all those macros using a python script. Also simplify the meson side by using `gnu_symbol_visibility : 'hidden'` keyword argument instead of passing the cflag manually. This leaves only API index to add manually into glib-docs.xml when bumping GLib version. That file cannot be generated because Meson does not allow passing a buit file to gnome.gtkdoc()'s main_xml kwarg unfortunately.
Diffstat (limited to 'gmodule')
-rw-r--r--gmodule/gmodule.h1
-rw-r--r--gmodule/meson.build9
2 files changed, 9 insertions, 1 deletions
diff --git a/gmodule/gmodule.h b/gmodule/gmodule.h
index 974489041..ec14f4e10 100644
--- a/gmodule/gmodule.h
+++ b/gmodule/gmodule.h
@@ -28,6 +28,7 @@
#define __GMODULE_H__
#include <glib.h>
+#include <gmodule/gmodule-visibility.h>
G_BEGIN_DECLS
diff --git a/gmodule/meson.build b/gmodule/meson.build
index 0c5aad311..54b25a0c5 100644
--- a/gmodule/meson.build
+++ b/gmodule/meson.build
@@ -66,6 +66,12 @@ gmodule_c = files('gmodule.c')
install_headers([gmodule_h], subdir : 'glib-2.0')
+gvisibility_h = configure_file(
+ output: 'gmodule-visibility.h',
+ command: [gen_visibility_macros, meson.project_version(), 'visibility-macros', 'GMODULE', '@OUTPUT@'],
+)
+install_headers(gvisibility_h, subdir : 'glib-2.0/gmodule')
+
gmodule_sources = [gmodule_c]
if host_system == 'windows'
gmodule_win_rc = configure_file(
@@ -85,7 +91,8 @@ libgmodule = library('gmodule-2.0',
install : true,
include_directories : [configinc, gmoduleinc],
dependencies : [libdl_dep, libglib_dep],
- c_args : ['-DG_LOG_DOMAIN="GModule"'] + glib_hidden_visibility_args,
+ c_args : ['-DG_LOG_DOMAIN="GModule"', '-DGMODULE_COMPILATION'],
+ gnu_symbol_visibility : 'hidden',
link_args : [glib_link_flags],
)