Bug 1397263 - move GNU_AS checks to toolchain.configure; r=glandium
authorTed Mielczarek <ted@mielczarek.org>
Wed, 03 Oct 2018 20:29:29 -0400
changeset 439566 23f384237f7320a5f5ef99f19781feb0227faf7e
parent 439565 b3ad0438392892aeab8c88826d347164640ba602
child 439567 237dbec378d81d707afbf97e1818fea97c972844
push id34779
push usernbeleuzu@mozilla.com
push dateThu, 04 Oct 2018 15:49:20 +0000
treeherdermozilla-central@f66e525e6978 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1397263
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
build/autoconf/toolchain.m4
build/moz.configure/toolchain.configure
js/src/old-configure.in
old-configure.in
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -9,30 +9,23 @@ dnl However, theses checks are not neces
 dnl the corresponding variables already, so just skip those tests
 dnl entirely.
 define([AC_PROG_CPP],[])
 define([AC_PROG_CXXCPP],[])
 define([AC_HEADER_STDC], [])
 
 AC_DEFUN([MOZ_TOOL_VARIABLES],
 [
-GNU_AS=
-
 GNU_CC=
 GNU_CXX=
 if test "$CC_TYPE" = "gcc"; then
     GNU_CC=1
     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=
 if test "$CC_TYPE" = "clang"; then
     GNU_CC=1
     GNU_CXX=1
     CLANG_CC=1
     CLANG_CXX=1
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -1864,16 +1864,42 @@ def as_with_flags(as_info, assembler, pr
     assert as_info.type == 'gcc'
 
     # Need to add compiler wrappers and flags as appropriate.
     return c_compiler.wrapper + [assembler] + c_compiler.flags
 
 
 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.
     if as_info.type == 'masm' and target.cpu == 'aarch64':
         return ''
     else:
         return '-c'
 
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -297,17 +297,16 @@ if test -n "$SBCONF"; then
     if test $_sb_version_major -eq 1 -a $_sb_version_minor -eq 0 -a $_sb_version_point -le 16; then
         QEMU_CANT_RUN_JS_SHELL=1
     fi
 fi
 AC_SUBST(QEMU_CANT_RUN_JS_SHELL)
 
 AC_SUBST(_MSC_VER)
 
-AC_SUBST(GNU_AS)
 AC_SUBST(GNU_CC)
 AC_SUBST(GNU_CXX)
 
 dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
 if test "$COMPILE_ENVIRONMENT"; then
 
--- a/old-configure.in
+++ b/old-configure.in
@@ -328,17 +328,16 @@ if test -n "$_WIN32_MSVC"; then
     AC_DEFINE(HAVE_IO_H)
     AC_DEFINE(HAVE_ISATTY)
 fi
 
 fi # COMPILE_ENVIRONMENT
 
 AC_SUBST(_MSC_VER)
 
-AC_SUBST(GNU_AS)
 AC_SUBST(GNU_CC)
 AC_SUBST(GNU_CXX)
 
 AC_SUBST_LIST(STL_FLAGS)
 AC_SUBST(WRAP_STL_INCLUDES)
 
 dnl ========================================================
 dnl Checks for programs.