mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 16:57:36 +00:00
Bug 1879776 - Move -Wa,--noexecstack check to python configure r=glandium
Provide the minimal support from moz.configure to do so. The only observable change of this patch is to permute -fPIC and -Wa,--noexecstack in ASFLAGS. Differential Revision: https://phabricator.services.mozilla.com/D201349
This commit is contained in:
parent
f7c632a681
commit
e4d4f0003c
@ -204,7 +204,7 @@ def check_symbol(symbol, language="C", flags=None, when=None, onerror=lambda: No
|
||||
# when the warning flag is wanted.
|
||||
# - `check`, when not set, skips checking whether the flag is supported and
|
||||
# adds it to the list of flags unconditionally.
|
||||
# - `link`, when set, also perform a linking step.
|
||||
# - `mode`, can be "compile", "link" or "assemble"
|
||||
@template
|
||||
def check_and_add_flags(
|
||||
flag,
|
||||
@ -213,11 +213,13 @@ def check_and_add_flags(
|
||||
compiler=None,
|
||||
when=None,
|
||||
check=True,
|
||||
link=False,
|
||||
mode="compile",
|
||||
):
|
||||
assert mode in ("compile", "link", "assemble")
|
||||
|
||||
if compiler is not None:
|
||||
compilers = (compiler,)
|
||||
elif link:
|
||||
elif mode in ("link", "assemble"):
|
||||
compilers = (c_compiler,)
|
||||
else:
|
||||
compilers = (c_compiler, cxx_compiler)
|
||||
@ -234,20 +236,25 @@ def check_and_add_flags(
|
||||
|
||||
for c in compilers:
|
||||
assert c in {c_compiler, cxx_compiler, host_c_compiler, host_cxx_compiler}
|
||||
if link:
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ("C", flags_collection.ldflags),
|
||||
cxx_compiler: ("C++", flags_collection.ldflags),
|
||||
host_c_compiler: ("host C", flags_collection.host_ldflags),
|
||||
host_cxx_compiler: ("host C++", flags_collection.host_ldflags),
|
||||
}[c]
|
||||
else:
|
||||
if mode == "compile":
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ("C", flags_collection.cflags),
|
||||
cxx_compiler: ("C++", flags_collection.cxxflags),
|
||||
host_c_compiler: ("host C", flags_collection.host_cflags),
|
||||
host_cxx_compiler: ("host C++", flags_collection.host_cxxflags),
|
||||
}[c]
|
||||
elif mode == "assemble":
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ("C", flags_collection.asflags),
|
||||
host_c_compiler: ("host C", flags_collection.host_asflags),
|
||||
}[c]
|
||||
elif mode == "link":
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ("C", flags_collection.ldflags),
|
||||
cxx_compiler: ("C++", flags_collection.ldflags),
|
||||
host_c_compiler: ("host C", flags_collection.host_ldflags),
|
||||
host_cxx_compiler: ("host C++", flags_collection.host_ldflags),
|
||||
}[c]
|
||||
|
||||
result = when
|
||||
|
||||
@ -261,7 +268,7 @@ def check_and_add_flags(
|
||||
|
||||
return flags
|
||||
|
||||
if link:
|
||||
if mode == "link":
|
||||
|
||||
def runner(*args, **kwargs):
|
||||
if c in (c_compiler, cxx_compiler):
|
||||
@ -377,6 +384,27 @@ def add_flag(warning, compiler=None, when=None):
|
||||
check_and_add_flag(warning, compiler, when, check=False)
|
||||
|
||||
|
||||
# Like the compilation checks above, but for asm flags.
|
||||
@dependable
|
||||
def asm_flags():
|
||||
return namespace(asflags=[], host_asflags=[])
|
||||
|
||||
|
||||
# Tests the given assembler flag is supported; if the flag
|
||||
# is supported, add it to the list of compilation flags for the build.
|
||||
# - `flag` is the flag to test
|
||||
# - `when` (optional) is a @depends function or option name conditioning
|
||||
# when the warning flag is wanted.
|
||||
# - `check`, when not set, skips checking whether the flag is supported and
|
||||
# adds it to the list of flags unconditionally. This is only meant for
|
||||
# add_flag().
|
||||
@template
|
||||
def check_and_add_asm_flag(flag, when=None, check=True):
|
||||
return check_and_add_flags(
|
||||
flag, asm_flags, [flag], when=when, check=check, mode="assemble",
|
||||
)
|
||||
|
||||
|
||||
# Like the compilation checks above, but for linker flags.
|
||||
@dependable
|
||||
def linker_flags():
|
||||
@ -394,7 +422,7 @@ def linker_flags():
|
||||
@template
|
||||
def check_and_add_linker_flag(flag, compiler=None, when=None, check=True):
|
||||
return check_and_add_flags(
|
||||
flag, linker_flags, [flag], when=when, check=check, link=True
|
||||
flag, linker_flags, [flag], when=when, check=check, mode="link",
|
||||
)
|
||||
|
||||
|
||||
|
@ -163,6 +163,7 @@ def check_build_id_sha1(developer_options):
|
||||
check_and_add_linker_flag("-Wl,--build-id=uuid", when=check_build_id_uuid)
|
||||
check_and_add_linker_flag("-Wl,--build-id=sha1", when=check_build_id_sha1)
|
||||
|
||||
check_and_add_asm_flag("-Wa,--noexecstack", when=is_gnu_cc)
|
||||
check_and_add_linker_flag("-Wl,-z,noexecstack", when=is_gnu_cc)
|
||||
check_and_add_linker_flag("-Wl,-z,text", when=is_gnu_cc)
|
||||
check_and_add_linker_flag("-Wl,-z,relro", when=is_gnu_cc)
|
||||
@ -184,5 +185,7 @@ def check_Bsymbolic(enable_asan, is_gnu_cc):
|
||||
check_and_add_linker_flag("-Wl,-Bsymbolic", when=check_Bsymbolic)
|
||||
|
||||
# Please keep these last in this file.
|
||||
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_HOST_LDFLAGS", linker_flags.host_ldflags)
|
||||
|
@ -194,14 +194,6 @@ if test "$GNU_CC"; then
|
||||
ASFLAGS="$ASFLAGS -fPIC"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for --noexecstack option to as])
|
||||
_SAVE_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Wa,--noexecstack"
|
||||
AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
|
||||
[ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
|
||||
AC_MSG_RESULT([no]))
|
||||
CFLAGS=$_SAVE_CFLAGS
|
||||
|
||||
_DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
|
||||
fi
|
||||
|
||||
@ -913,6 +905,10 @@ CXXFLAGS=`echo \
|
||||
$_COMPILATION_CXXFLAGS \
|
||||
$CXXFLAGS`
|
||||
|
||||
ASFLAGS=`echo \
|
||||
$_COMPILATION_ASFLAGS \
|
||||
$ASFLAGS`
|
||||
|
||||
COMPILE_CFLAGS=`echo \
|
||||
$_DEFINES_CFLAGS \
|
||||
$COMPILE_CFLAGS`
|
||||
|
@ -193,14 +193,6 @@ if test "$GNU_CC"; then
|
||||
ASFLAGS="$ASFLAGS -fPIC"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for --noexecstack option to as])
|
||||
_SAVE_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Wa,--noexecstack"
|
||||
AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
|
||||
[ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
|
||||
AC_MSG_RESULT([no]))
|
||||
CFLAGS=$_SAVE_CFLAGS
|
||||
|
||||
AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
|
||||
HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
|
||||
_SAVE_LDFLAGS=$LDFLAGS
|
||||
@ -1212,6 +1204,10 @@ CXXFLAGS=`echo \
|
||||
$_COMPILATION_CXXFLAGS \
|
||||
$CXXFLAGS`
|
||||
|
||||
ASFLAGS=`echo \
|
||||
$_COMPILATION_ASFLAGS \
|
||||
$ASFLAGS`
|
||||
|
||||
COMPILE_CFLAGS=`echo \
|
||||
$_DEFINES_CFLAGS \
|
||||
$COMPILE_CFLAGS`
|
||||
|
Loading…
x
Reference in New Issue
Block a user