bug 1397263 - move GNU_AS checks to toolchain.configure. r?build draft
authorTed Mielczarek <ted@mielczarek.org>
Mon, 04 Dec 2017 09:48:35 -0500
changeset 706970 fbd0dde82d115128b03a2bcfc02f5d1580574e10
parent 706969 5db4c743f9f4d0fe772f52c34c44db16e7e933a0
child 742811 a6bdfde64960f9ff4462ea0713356a62a833cd68
push id91972
push userbmo:ted@mielczarek.org
push dateMon, 04 Dec 2017 15:07:44 +0000
reviewersbuild
bugs1397263
milestone59.0a1
bug 1397263 - move GNU_AS checks to toolchain.configure. r?build 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. MozReview-Commit-ID: KXBqoCYIIsj
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
@@ -1524,16 +1524,37 @@ def as_names(target, c_compiler):
         return (ml, )
     # When building with anything but MSVC, we just use the C compiler as the assembler.
     return (c_compiler.compiler, )
 
 
 assembler = check_prog('AS', as_names)
 add_old_configure_assignment('AS', assembler)
 
+@depends(assembler, c_compiler, extra_toolchain_flags)
+@imports('subprocess')
+@imports(_from='os', _import='devnull')
+def gnu_as(assembler, c_compiler, toolchain_flags):
+    if c_compiler.type in ('gcc', 'clang'):
+        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)
+
+# This only exists so directories using yasm can unset it.
+set_config('AS_DASH_C_FLAG', '-c')
 
 # clang plugin handling
 # ==============================================================
 
 js_option('--enable-clang-plugin', env='ENABLE_CLANG_PLUGIN',
           help="Enable building with the mozilla clang plugin")
 
 add_old_configure_assignment('ENABLE_CLANG_PLUGIN',
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -289,17 +289,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
@@ -339,17 +339,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)
 AC_SUBST(MOZ_MSVC_STL_WRAP_RAISE)
 
 dnl ========================================================