build: fix nm binutils tool when building with LTO

When building with -flto, we need to use linker plugins.
In case of binutils' nm, it means to prefer gcc-nm if
available.

Like for ranlib and ar, prefer gcc-nm.

- replace AC_PATH_TOOL() by AC_CHECK_TOOLS(). That is consistent
  with what we do for ar,ranlib and suggested on bgo#783311.
- instead of using the variable $BINUTILS_NM, replace it by
  $NM, which is more common according to bgo#783311.
- Keep recognizing $BINUTILS_NM environment, which was introduced
  by commit 8bc88bcc7c. This is purely to keep previous build
  scripts working. Originally I named it "$BINUTILS_NM" because
  using $NM in NetworkManager seemed confusing. But well...

https://bugs.gentoo.org/show_bug.cgi?id=620052
https://bugzilla.gnome.org/show_bug.cgi?id=782525
https://bugzilla.gnome.org/show_bug.cgi?id=783311
This commit is contained in:
Thomas Haller 2017-06-01 10:26:59 +02:00
parent afebdc795d
commit 484d666485
3 changed files with 3 additions and 4 deletions

View file

@ -1570,7 +1570,7 @@ $(src_libNetworkManagerTest_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
###############################################################################
src/NetworkManager.ver: src/libNetworkManager.la $(core_plugins)
$(AM_V_GEN) BINUTILS_NM="$(BINUTILS_NM)" "$(srcdir)/tools/create-exports-NetworkManager.sh" --called-from-make "$(srcdir)"
$(AM_V_GEN) NM="$(NM)" "$(srcdir)/tools/create-exports-NetworkManager.sh" --called-from-make "$(srcdir)"
CLEANFILES += src/NetworkManager.ver

View file

@ -38,6 +38,7 @@ AC_PROG_MKDIR_P
# Prefer gcc-* variants; the ones libtool would choose don't work with LTO
AC_CHECK_TOOLS(AR, [gcc-ar ar], false)
AC_CHECK_TOOLS(RANLIB, [gcc-ranlib ranlib], :)
AC_CHECK_TOOLS(NM, [$BINUTILS_NM gcc-nm nm])
dnl Initialize libtool
LT_PREREQ([2.2])
@ -1199,8 +1200,6 @@ else
fi
AC_SUBST(NM_LOG_COMPILER, 'LOG_COMPILER = "$(top_srcdir)/tools/run-nm-test.sh" --called-from-make "$(LIBTOOL)" "$(with_valgrind)" "'"$with_valgrind_suppressions"'" --launch-dbus=auto')
AC_PATH_TOOL(BINUTILS_NM, nm, nm)
AM_PATH_PYTHON([], [], [PYTHON=python])
AC_SUBST(PYTHON, [$PYTHON])
AC_DEFINE_UNQUOTED(TEST_NM_PYTHON, "$PYTHON", [Define python path for test binary])

View file

@ -30,7 +30,7 @@ _sort() {
}
call_nm() {
"${BINUTILS_NM:-${NM:-nm}}" "$1" |
"${NM:-nm}" "$1" |
sed -n 's/.* \([^ ]\) \([^ ]*\)$/\1 \2/p'
}