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
This commit is contained in:
orbea 2021-04-01 19:01:54 -07:00 committed by Thomas Haller
parent 74fc279341
commit 68913466af
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 18 additions and 15 deletions

View file

@ -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

View file

@ -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