aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2021-06-14 15:34:30 +0200
committerSimon Ser <contact@emersion.fr>2021-06-17 11:02:30 +0200
commitcb6db86a2832564ec862d95b1ae14a47a9f4572f (patch)
treea18b7a4856fd82a29cbb6eb5a0f232aaa49746e8 /meson.build
parent72ee196efaa4e1ecad8a487e9fb273df914fca26 (diff)
meson: Make private static library symbols local
Static libraries are not affected by our symbol file, so private symbols are globally visible by default. Use objcopy to make symbols that we do not want to expose local. Closes: https://github.com/swaywm/wlroots/issues/1892 Closes: https://github.com/swaywm/wlroots/issues/2952
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build22
1 files changed, 22 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 36bf6e8b..6c6b2b23 100644
--- a/meson.build
+++ b/meson.build
@@ -150,8 +150,30 @@ lib_wlr = library(
install: true,
link_args: symbols_flag,
link_depends: symbols_file,
+ prelink: true,
)
+if get_option('default_library') != 'shared'
+ lib_target = lib_wlr
+ if get_option('default_library') == 'both'
+ lib_target = lib_wlr.get_static_lib()
+ endif
+ objcopy_prog = find_program('objcopy', native: true)
+ custom_target('libwlroots',
+ input: lib_target,
+ output: lib_target.name() + '.is-stripped',
+ capture: true,
+ command: [
+ objcopy_prog.full_path(), '-w',
+ '--localize-symbol=!wlr_*',
+ '--localize-symbol=!_wlr_*',
+ '--localize-symbol=*',
+ '@INPUT@',
+ ],
+ build_by_default: true,
+ )
+endif
+
wlr_vars = {}
foreach name, have : features
wlr_vars += { 'have_' + name.underscorify(): have.to_string() }