Bug 1397263 - move GNU_AS checks to toolchain.configure; r=glandium

The GNU_AS check in old-configure depended on running with the value
of $AS before it gets reset to just be the C compiler, which breaks when
we move setting AS into moz.configure.

This patch moves the GNU_AS check to toolchain.configure and changes it
so that it works when the assembler is the C compiler.  We do have to
fix things slightly for clang, because the previous check was
succeeding, but not because of clang: it was detecting the presence of
"GNU" in the output for GNU ld/gold and a message about the GNU GPL.
This commit is contained in:
Ted Mielczarek 2018-10-03 20:29:29 -04:00
parent f05bb2799a
commit 5beac189a8
4 changed files with 26 additions and 9 deletions

View File

@ -14,8 +14,6 @@ define([AC_HEADER_STDC], [])
AC_DEFUN([MOZ_TOOL_VARIABLES],
[
GNU_AS=
GNU_CC=
GNU_CXX=
if test "$CC_TYPE" = "gcc"; then
@ -23,11 +21,6 @@ if test "$CC_TYPE" = "gcc"; then
GNU_CXX=1
fi
if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then
GNU_AS=1
fi
rm -f conftest.out
CLANG_CC=
CLANG_CXX=
CLANG_CL=

View File

@ -1869,6 +1869,32 @@ def as_with_flags(as_info, assembler, provided_assembler, c_compiler):
add_old_configure_assignment('AS', as_with_flags)
@depends(assembler, c_compiler, extra_toolchain_flags)
@imports('subprocess')
@imports(_from='os', _import='devnull')
def gnu_as(assembler, c_compiler, toolchain_flags):
# clang uses a compatible GNU assembler.
if c_compiler.type == 'clang':
return True
if c_compiler.type == 'gcc':
cmd = [assembler] + c_compiler.flags
if toolchain_flags:
cmd += toolchain_flags
cmd += ['-Wa,--version', '-c', '-o', devnull, '-x', 'assembler', '-']
# We don't actually have to provide any input on stdin, `Popen.communicate` will
# close the stdin pipe.
# clang will error if it uses its integrated assembler for this target,
# so handle failures gracefully.
if 'GNU' in check_cmd_output(*cmd, stdin=subprocess.PIPE, onerror=lambda: '').decode('utf-8'):
return True
set_config('GNU_AS', gnu_as)
add_old_configure_assignment('GNU_AS', gnu_as)
@depends(as_info, target)
def as_dash_c_flag(as_info, target):
# armasm64 doesn't understand -c.

View File

@ -302,7 +302,6 @@ AC_SUBST(QEMU_CANT_RUN_JS_SHELL)
AC_SUBST(_MSC_VER)
AC_SUBST(GNU_AS)
AC_SUBST(GNU_CC)
AC_SUBST(GNU_CXX)

View File

@ -333,7 +333,6 @@ fi # COMPILE_ENVIRONMENT
AC_SUBST(_MSC_VER)
AC_SUBST(GNU_AS)
AC_SUBST(GNU_CC)
AC_SUBST(GNU_CXX)