Bug 1880103 - Move dead_strip linker check to moz.configure r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D201724
This commit is contained in:
serge-sans-paille 2024-02-28 11:11:16 +00:00
parent c05e0c4124
commit 1142b832db
6 changed files with 40 additions and 54 deletions

View File

@ -436,6 +436,24 @@ def check_and_add_linker_flag(flag, compiler=None, when=None, check=True):
)
# Like the compilation checks above, but for linker optimization flags.
@dependable
def linker_optimize_flags():
return namespace(ldflags=[])
@template
def check_and_add_linker_optimize_flag(flag, compiler=None, when=None, check=True):
return check_and_add_flags(
flag,
linker_optimize_flags,
[flag],
when=when,
check=check,
mode="link",
)
# Add the given flag to the list of linker flags for the build.
# - `flag` is the flag (e.g. -fno-sized-deallocation)
# - `when` (optional) is a @depends function or option name conditioning

View File

@ -177,6 +177,8 @@ check_and_add_linker_flag("-Wl,-z,relro", when=is_gnu_cc)
check_and_add_linker_flag("-Wl,-z,now", when=is_gnu_cc)
check_and_add_linker_flag("-Wl,-z,nocopyreloc", when=is_gnu_cc)
check_and_add_linker_optimize_flag("-Wl,-dead_strip", when=target_is_darwin & ~dtrace)
@depends("--enable-address-sanitizer", is_gnu_cc)
def check_Bsymbolic(enable_asan, is_gnu_cc):
@ -195,4 +197,7 @@ check_and_add_linker_flag("-Wl,-Bsymbolic", when=check_Bsymbolic)
add_old_configure_assignment("_COMPILATION_ASFLAGS", asm_flags.asflags)
add_old_configure_assignment("_COMPILATION_HOST_ASFLAGS", asm_flags.host_asflags)
add_old_configure_assignment("_COMPILATION_LDFLAGS", linker_flags.ldflags)
add_old_configure_assignment(
"_COMPILATION_OPTIMIZE_LDFLAGS", linker_optimize_flags.ldflags
)
add_old_configure_assignment("_COMPILATION_HOST_LDFLAGS", linker_flags.host_ldflags)

View File

@ -3279,3 +3279,16 @@ set_config(
flags=["-mavx512vnni", "-mavx512bw", "-mavx512f", "-mavx512dq", "-mavx512cd"],
),
)
# dtrace support
##
option("--enable-dtrace", help="Build with dtrace support")
dtrace = check_header(
"sys/sdt.h",
when="--enable-dtrace",
onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
)
set_config("HAVE_DTRACE", True, when=dtrace)
set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)

View File

@ -250,30 +250,12 @@ dnl ========================================================
dnl System overrides of the defaults for target
dnl ========================================================
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
case "$target" in
*-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3"
DSO_LDOPTS=''
dnl DTrace and -dead_strip don't interact well. See bug 403132.
dnl ===================================================================
if test "x$enable_dtrace" = "xyes"; then
echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
else
dnl check for the presence of the -dead_strip linker flag
AC_MSG_CHECKING([for -dead_strip option to ld])
_SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-dead_strip"
AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
if test -n "$_HAVE_DEAD_STRIP" ; then
AC_MSG_RESULT([yes])
MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
else
AC_MSG_RESULT([no])
fi
LDFLAGS=$_SAVE_LDFLAGS
fi
MOZ_FIX_LINK_PATHS=
;;

View File

@ -786,19 +786,6 @@ check_prog(
paths=clang_search_path,
)
option("--enable-dtrace", help="Build with dtrace support")
dtrace = check_header(
"sys/sdt.h",
when="--enable-dtrace",
onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
)
set_config("HAVE_DTRACE", True, when=dtrace)
set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
option("--disable-icf", help="Disable Identical Code Folding")
add_old_configure_assignment(

View File

@ -277,31 +277,12 @@ dnl ========================================================
dnl System overrides of the defaults for target
dnl ========================================================
MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
case "$target" in
*-darwin*)
MOZ_OPTIMIZE_FLAGS="-O3"
DSO_LDOPTS=''
dnl DTrace and -dead_strip don't interact well. See bug 403132.
dnl ===================================================================
if test "x$enable_dtrace" = "xyes"; then
echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
else
dnl check for the presence of the -dead_strip linker flag
AC_MSG_CHECKING([for -dead_strip option to ld])
_SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-dead_strip"
AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
if test -n "$_HAVE_DEAD_STRIP" ; then
AC_MSG_RESULT([yes])
MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
else
AC_MSG_RESULT([no])
fi
LDFLAGS=$_SAVE_LDFLAGS
fi
MOZ_FIX_LINK_PATHS=
;;