summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2019-08-05 19:19:08 -0700
committerChristian Hergert <chergert@redhat.com>2019-08-05 19:19:08 -0700
commiteed297fb82c3ae661b427ac5fe5ea6d299baa86a (patch)
treec05519606a62418d8783daece14b473d006b4eab /meson.build
parent7ad862c039ad5861ab270ac14ee59f664d7e1c32 (diff)
downloadlibpeas-eed297fb82c3ae661b427ac5fe5ea6d299baa86a.tar.gz
build: hide private symbols with -fvisibility=hidden
This continues with the previous commit to hide non-public symbols by default. It is slightly complicated by the fact that we need some symbol access from the unit tests. Normally that would mean we just add a static library and link against that, but we need shared access to globals so that is not an option. We could possibly switch to creating a shared library without -fvisibility=hidden.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build17
1 files changed, 17 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index f73d986..683b037 100644
--- a/meson.build
+++ b/meson.build
@@ -123,6 +123,23 @@ if build_machine.system() == 'darwin'
config_h.set_quoted('OS_OSX', 1)
endif
+# Detect and set symbol visibility
+hidden_visibility_args = []
+if get_option('default_library') != 'static'
+ if host_machine.system() == 'windows'
+ config_h.set('DLL_EXPORT', true)
+ if cc.get_id() == 'msvc'
+ config_h.set('_PEAS_EXTERN', '__declspec(dllexport) extern')
+ elif cc.has_argument('-fvisibility=hidden')
+ config_h.set('_PEAS_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
+ hidden_visibility_args = ['-fvisibility=hidden']
+ endif
+ elif cc.has_argument('-fvisibility=hidden')
+ config_h.set('_PEAS_EXTERN', '__attribute__((visibility("default"))) extern')
+ hidden_visibility_args = ['-fvisibility=hidden']
+ endif
+endif
+
configure_file(
output: 'config.h',
configuration: config_h