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
This commit is contained in:
Kenny Levinsen 2021-06-14 15:34:30 +02:00 committed by Simon Ser
parent 72ee196efa
commit cb6db86a28
1 changed files with 22 additions and 0 deletions

View File

@ -150,8 +150,30 @@ lib_wlr = library(
install: true, install: true,
link_args: symbols_flag, link_args: symbols_flag,
link_depends: symbols_file, 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 = {} wlr_vars = {}
foreach name, have : features foreach name, have : features
wlr_vars += { 'have_' + name.underscorify(): have.to_string() } wlr_vars += { 'have_' + name.underscorify(): have.to_string() }