Bug 1480005 - Move NM to python configure. r=firefox-build-system-reviewers,nalexander

There is only one place where it's used:
config/check_vanilla_allocations.py, which is only executed from
js/src/build/Makefile.in on the condition that the build is targeting
Linux and not LTO. But the LTO test is actually outdated, because we
don't build with `-flto`, but `-flto=thin`, so the exclusion doesn't
work anymore.

There is however no AC_CHECK_PROG, and we currently rely on NM to be
given, or fall back to "nm", which works in most cases, except LTO with
clang. It works on CI because in LTO builds we explicitly set NM to
llvm-nm (which can output symbols from LLVM bitcode objects), but we
could also do that automatically.

So we add a full detection of nm/llvm-nm to python configure, and limit
it to Linux, since we only ever use it there.

Differential Revision: https://phabricator.services.mozilla.com/D101681
This commit is contained in:
Mike Hommey 2021-01-14 20:17:08 +00:00
Родитель 3a558130b5
Коммит a9c5e28258
14 изменённых файлов: 21 добавлений и 23 удалений

Просмотреть файл

@ -2898,6 +2898,26 @@ add_old_configure_assignment("AR", ar)
set_config("AR_FLAGS", ar_config.flags)
@depends(toolchain_prefix, c_compiler)
def nm_names(toolchain_prefix, c_compiler):
names = tuple("%s%s" % (p, "nm") for p in (toolchain_prefix or ()) + ("",))
if c_compiler.type == "clang":
# Get the llvm-nm path as per the output from clang --print-prog-name=llvm-nm
# so that we directly get the one under the clang directory, rather than one
# that might be in /usr/bin and that might point to one from a different version
# of clang.
out = check_cmd_output(
c_compiler.compiler, "--print-prog-name=llvm-nm", onerror=lambda: None
)
llvm_nm = out.rstrip() if out else "llvm-nm"
names = (llvm_nm,) + names
return names
check_prog("NM", nm_names, paths=toolchain_search_path, when=target_is_linux)
option("--enable-cpp-rtti", help="Enable C++ RTTI")
add_old_configure_assignment("_MOZ_USE_RTTI", "1", when="--enable-cpp-rtti")

Просмотреть файл

@ -33,7 +33,6 @@ unset MOZ_LTO
unset MOZ_STDCXX_COMPAT
unset MOZ_NO_PIE_COMPAT
unset NM
unset NASM
# Don't unset this on Linux artifact builds so the artifact builds correctly

Просмотреть файл

@ -36,7 +36,6 @@ else
ac_add_options --with-pgo-jarlog=${MOZ_FETCHES_DIR}/en-US.log
ac_add_options --with-pgo-profile-path=${MOZ_FETCHES_DIR}/merged.profdata
export LLVM_PROFDATA="$MOZ_FETCHES_DIR/clang/bin/llvm-profdata"
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
fi
fi

Просмотреть файл

@ -6,6 +6,7 @@
include $(topsrcdir)/config/rules.mk
ifdef NM
# check_vanilla_allocations.py is tailored to Linux, so only run it there.
# That should be enough to catch any problems.
check-vanilla-allocations:
@ -16,11 +17,8 @@ check-vanilla-allocations:
check-vanilla-allocations-aggressive:
$(PYTHON3) $(topsrcdir)/config/check_vanilla_allocations.py --aggressive $(REAL_LIBRARY)
ifeq ($(OS_ARCH),Linux)
ifeq (,$(filter -flto,$(COMPUTED_CFLAGS) $(COMPUTED_CXXFLAGS) $(COMPUTED_LDFLAGS)))
check:: check-vanilla-allocations
endif
endif
$(LIBRARY_NAME).pc: js.pc
cp $^ $@

Просмотреть файл

@ -1330,7 +1330,6 @@ dnl = Maintainer debug option (no --enable equivalent)
dnl =
dnl ========================================================
AC_SUBST(NM)
AC_SUBST_LIST(ASFLAGS)
AC_SUBST(IMPLIB)
AC_SUBST(FILTER)

Просмотреть файл

@ -8,6 +8,4 @@ ac_add_options --with-branding=mobile/android/branding/beta
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -10,6 +10,4 @@ export FENNEC_NIGHTLY=1
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -13,6 +13,4 @@ ac_add_options --with-branding=mobile/android/branding/beta
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -15,6 +15,4 @@ export FENNEC_NIGHTLY=1
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -12,6 +12,4 @@ ac_add_options --with-branding=mobile/android/branding/beta
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -15,6 +15,4 @@ export FENNEC_NIGHTLY=1
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -8,6 +8,4 @@ ac_add_options --with-branding=mobile/android/branding/beta
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -10,6 +10,4 @@ export FENNEC_NIGHTLY=1
export MOZILLA_OFFICIAL=1
export NM="$MOZ_FETCHES_DIR/clang/bin/llvm-nm"
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

Просмотреть файл

@ -2470,7 +2470,6 @@ dnl = Maintainer debug option (no --enable equivalent)
dnl =
dnl ========================================================
AC_SUBST(NM)
AC_SUBST_LIST(ASFLAGS)
AC_SUBST(IMPLIB)
AC_SUBST(FILTER)