mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-17 14:00:22 +01:00
build: fix generating "NetworkManager.ver" with LTO
We use a linker version script "NetworkManager.ver", to hide
symbols from NetworkManager that are not used. That is important
due to our habit of using internal helper libraries that we link
statically everywhere, without handpicking the symbols we actually
need. We want the tooling to get rid of unnecessary symbols.
However, NetworkManager loads shared libraries for settings and device
plugins. These libraries require symbols from the NetworkManager binary,
but which one depends on build options. Hence, we also generate
"NetworkManager.ver" by the "tools/create-exports-NetworkManager.sh"
script.
For that the script uses "nm" to find symbols that are undefined in the
plugin libraries but defined in NetworkManager. With autotools the
script looked at "./src/.libs/libNetworkManager.a" to find the present
symbols. Note that for meson that already didn't work, and we build
instead an intermediate NetworkManager binary first (with all symbols
exposed). With LTO, "nm" doesn't find all symbols in
"./src/.libs/libNetworkManager.a", and consequently they are not
exported and dropped/hidden.
This also causes unit tests to fail with LTO, because our test script
"tools/check-exports.sh" catches such bugs.
Fix that by also with autotools generate a complete "NetworkManager-all-sym"
binary that is used to generate "NetworkManager.ver", before rebuilding
"NetworkManager" again.
(cherry picked from commit c92a3ca5c2)
This commit is contained in:
parent
043bf59602
commit
bfa5a58642
4 changed files with 25 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -216,6 +216,7 @@ test-*.trs
|
|||
/po/remove-potcdate.sin
|
||||
|
||||
/src/NetworkManager
|
||||
/src/NetworkManager-all-sym
|
||||
/src/NetworkManager.ver
|
||||
/src/devices/bluetooth/tests/nm-bt-test
|
||||
/src/devices/tests/test-acd
|
||||
|
|
|
|||
21
Makefile.am
21
Makefile.am
|
|
@ -2376,7 +2376,26 @@ $(src_libNetworkManagerTest_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
|||
|
||||
###############################################################################
|
||||
|
||||
src/NetworkManager.ver: src/libNetworkManager.la $(core_plugins)
|
||||
noinst_PROGRAMS += src/NetworkManager-all-sym
|
||||
|
||||
src_NetworkManager_all_sym_CPPFLAGS = $(src_cppflags)
|
||||
|
||||
src_NetworkManager_all_sym_SOURCES = \
|
||||
src/main.c
|
||||
|
||||
src_NetworkManager_all_sym_LDADD = \
|
||||
src/libNetworkManager.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
src_NetworkManager_all_sym_LDFLAGS = \
|
||||
-rdynamic \
|
||||
$(SANITIZER_EXEC_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
$(src_NetworkManager_all_sym_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||
|
||||
src/NetworkManager.ver: src/NetworkManager-all-sym $(core_plugins)
|
||||
$(AM_V_GEN) NM="$(NM)" "$(srcdir)/tools/create-exports-NetworkManager.sh" --called-from-build "$(srcdir)"
|
||||
|
||||
CLEANFILES += src/NetworkManager.ver
|
||||
|
|
|
|||
|
|
@ -264,8 +264,8 @@ symbol_map_name = 'NetworkManager.ver'
|
|||
# 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',
|
||||
network_manager_all_sym = executable(
|
||||
'NetworkManager-all-sym',
|
||||
'main.c',
|
||||
dependencies: nm_deps,
|
||||
c_args: daemon_c_flags,
|
||||
|
|
@ -277,7 +277,7 @@ network_manager_sym = executable(
|
|||
ver_script = custom_target(
|
||||
symbol_map_name,
|
||||
output: symbol_map_name,
|
||||
depends: [network_manager_sym, core_plugins],
|
||||
depends: [network_manager_all_sym, core_plugins],
|
||||
command: [create_exports_networkmanager, '--called-from-build', source_root],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,7 @@ call_nm() {
|
|||
}
|
||||
|
||||
get_symbols_nm () {
|
||||
if [ -z "$from_meson" ]; then
|
||||
base=./src/.libs/libNetworkManager.a
|
||||
else
|
||||
base=./src/nm-full-symbols
|
||||
fi
|
||||
base=./src/NetworkManager-all-sym
|
||||
call_nm "$base" |
|
||||
sed -n 's/^[tTDGRBS] //p' |
|
||||
_sort
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue