Skip to content

Commit

Permalink
Bug 1480005 - Move NM to python configure. r=firefox-build-system-rev…
Browse files Browse the repository at this point in the history
…iewers,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
  • Loading branch information
glandium committed Jan 14, 2021
1 parent 3a55813 commit a9c5e28
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 23 deletions.
20 changes: 20 additions & 0 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 0 additions & 1 deletion build/mozconfig.no-compile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion build/unix/mozconfig.unix
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions js/src/build/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 $^ $@
Expand Down
1 change: 0 additions & 1 deletion js/src/old-configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-aarch64/beta
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-aarch64/nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-api-16/beta
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-api-16/nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-x86/beta
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-x86/nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-x86_64/beta
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions mobile/android/config/mozconfigs/android-x86_64/nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 0 additions & 1 deletion old-configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a9c5e28

Please sign in to comment.