From 68913466af49c738d7e226f55db15be70b22dbe6 Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 1 Apr 2021 19:01:54 -0700 Subject: [PATCH] tools: use libtool --mode=execute Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732 The original issue was that when compiling NetworkManager with slibtool the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym slibtool wrapper script to nm(1) instead of the actual binary. This is because slibtool and GNU libtool do not place the compiled programs in the same location. The original fix was to test both locations, but this is bit of a hack especially since the build system should not be using the .libs directory directly. However with $(LIBTOOL) --mode=execute this is not a problem since both implementations can figure out where the correct binary is. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805 --- Makefile.am | 2 +- tools/create-exports-NetworkManager.sh | 31 ++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1e804dacfe..b7a3a04c29 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2671,7 +2671,7 @@ src_core_NetworkManager_all_sym_LDFLAGS = \ $(src_core_NetworkManager_all_sym_OBJECTS): $(src_libnm_core_public_mkenums_h) src/core/NetworkManager.ver: src/core/NetworkManager-all-sym $(core_plugins) - $(AM_V_GEN) NM="$(NM)" "$(srcdir)/tools/create-exports-NetworkManager.sh" --called-from-build "$(srcdir)" + $(AM_V_GEN) LIBTOOL="$(LIBTOOL)" NM="$(NM)" "$(srcdir)/tools/create-exports-NetworkManager.sh" --called-from-build "$(srcdir)" CLEANFILES += src/core/NetworkManager.ver diff --git a/tools/create-exports-NetworkManager.sh b/tools/create-exports-NetworkManager.sh index f7fd3bab95..21ba369a41 100755 --- a/tools/create-exports-NetworkManager.sh +++ b/tools/create-exports-NetworkManager.sh @@ -35,15 +35,18 @@ _sort() { } call_nm() { - "${NM:-nm}" "$1" | - sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p' + if [ -n "$from_meson" ]; then + "${NM:-nm}" "$1" | + sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p' + else + libtool=(${LIBTOOL:-libtool}) + ${libtool[@]} --mode=execute "${NM:-nm}" "$1" | + sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p' + fi } get_symbols_nm () { - base=./src/core/.libs/NetworkManager-all-sym - if ! test -f "$base"; then - base=./src/core/NetworkManager-all-sym - fi + base=./src/core/NetworkManager-all-sym call_nm "$base" | sed -n 's/^[tTDGRBS] //p' | _sort @@ -85,6 +88,14 @@ do_update() { do_generate > ./src/core/NetworkManager.ver } +if [ -f "build.ninja" ]; then + from_meson=1 + libs= +else + from_meson= + libs=.libs/ +fi + SYMBOLS_MISSING="$(get_symbols_missing | pretty)" SYMBOLS_EXPLICIT="$(get_symbols_explicit | pretty)" @@ -102,14 +113,6 @@ local: EOF } -if [ -f "build.ninja" ]; then - from_meson=1 - libs= -else - from_meson= - libs=.libs/ -fi - test -f ./src/core/${libs}libNetworkManager.a || die "must be called from NetworkManager top build dir after building the tree" case "$1" in