From 19a718bc13824eae925ece55d04ebc07cd00cf62 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 18 Sep 2018 10:14:09 +0200 Subject: [PATCH] build: meson: fix computing NM exported symbols The script didn't include all the symbols needed by plugins because libNetworkManager.a, as built by meson, doesn't include symbols from other static libraries that are linked in. Since we used libNetworkManager.a to know which symbols are potentiall available from NM, the result was an incomplete list. Unfortunately, the only way to include the whole static library is to create a dependency object and use 'link_whole', but this is only available in meson >= 0.46. Since 'link_whole' is available for executables in meson >= 0.40, create a fake executable and use that to enumerate symbols. Also add tests to check that plugins can be loaded correctly. Fixes: dfa2a2b40c866bf7a5484b72639464c31b80e7da --- src/meson.build | 27 +++++++++++++++++++++++++- tools/create-exports-NetworkManager.sh | 7 ++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/meson.build b/src/meson.build index f46366a904..0a66647c25 100644 --- a/src/meson.build +++ b/src/meson.build @@ -252,11 +252,27 @@ subdir('settings/plugins') create_exports_networkmanager = join_paths(meson.source_root(), 'tools', 'create-exports-NetworkManager.sh') symbol_map_name = 'NetworkManager.ver' +# libNetworkManager.a, as built by meson doesn't contain all symbols +# from libNetworkManagerBase.a and other static libraries, unless we +# add dependencies with link_whole, only supported in meson >= 0.46. +# Create an executable with full symbols that we use in place of the +# library to enumerate the symbols. +network_manager_sym = executable( + 'nm-full-symbols', + 'main.c', + c_args: nm_cflags, + link_args: '-Wl,--no-gc-sections', + dependencies: nm_deps, + link_whole: [libnetwork_manager, libnetwork_manager_base, libnm_core], + install: false, +) + +# this uses symbols from nm-full-symbols instead of libNetworkManager.a ver_script = custom_target( symbol_map_name, input: meson.source_root(), output: symbol_map_name, - depends: [ libnetwork_manager, core_plugins ], + depends: [ network_manager_sym, core_plugins ], command: [create_exports_networkmanager, '--called-from-build', '@INPUT@'] ) @@ -273,3 +289,12 @@ network_manager = executable( install: true, install_dir: nm_sbindir ) + +if enable_tests + foreach plugin : core_plugins + test ('sym/' + plugin.full_path().split('/')[-1], + network_manager, + args: '--version', + env: ['LD_BIND_NOW=1', 'LD_PRELOAD=' + plugin.full_path()]) + endforeach +endif diff --git a/tools/create-exports-NetworkManager.sh b/tools/create-exports-NetworkManager.sh index 7d359005b7..1462501ee3 100755 --- a/tools/create-exports-NetworkManager.sh +++ b/tools/create-exports-NetworkManager.sh @@ -35,7 +35,12 @@ call_nm() { } get_symbols_nm () { - call_nm ./src/${libs}libNetworkManager.a | + if [ -z "$from_meson" ]; then + base=./src/.libs/libNetworkManager.a + else + base=./src/nm-full-symbols + fi + call_nm "$base" | sed -n 's/^[tTDGRBS] //p' | _sort }