Backed out 2 changesets (bug 1292046) for android build failures a=backout
authorWes Kocher <wkocher@mozilla.com>
Thu, 04 Aug 2016 14:22:54 -0700
changeset 333930 122387c4a8c70fe49cfcd256a5087e55f0ab8c91
parent 333929 442051d3d83ab45c9a3a50a6c26458d42b3bab0a
child 333931 73dff614932f28779efd629ff91053a569ff880f
push id10033
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:50:26 +0000
treeherdermozilla-aurora@5dddbefdf759 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1292046
milestone51.0a1
backs out3263785341f23998957c09305b66d3dda4c36329
a1b9e1631661f11244148997f00fcd73c532803d
Backed out 2 changesets (bug 1292046) for android build failures a=backout Backed out changeset 3263785341f2 (bug 1292046) Backed out changeset a1b9e1631661 (bug 1292046)
build/autoconf/toolchain.m4
build/moz.configure/checks.configure
build/moz.configure/compilechecks.configure
build/moz.configure/compilers-util.configure
build/moz.configure/toolchain.configure
old-configure.in
python/mozbuild/mozbuild/test/configure/test_header_checks.py
python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -44,21 +44,44 @@ fi
 AC_SUBST(CLANG_CXX)
 AC_SUBST(CLANG_CL)
 ])
 
 AC_DEFUN([MOZ_CROSS_COMPILER],
 [
 echo "cross compiling from $host to $target"
 
+_SAVE_CC="$CC"
+_SAVE_CFLAGS="$CFLAGS"
+_SAVE_LDFLAGS="$LDFLAGS"
+
 if test -z "$HOST_AR_FLAGS"; then
     HOST_AR_FLAGS="$AR_FLAGS"
 fi
 AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
 AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
+CC="$HOST_CC"
+CFLAGS="$HOST_CFLAGS"
+LDFLAGS="$HOST_LDFLAGS"
+
+AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
+
+CC="$HOST_CXX"
+CFLAGS="$HOST_CXXFLAGS"
+AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
+AC_TRY_COMPILE([], [return(0);],
+    [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
+    AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
+
+CC=$_SAVE_CC
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
 
 dnl AC_CHECK_PROGS manually goes through $PATH, and as such fails to handle
 dnl absolute or relative paths. Relative paths wouldn't work anyways, but
 dnl absolute paths would. Trick AC_CHECK_PROGS into working in that case by
 dnl adding / to PATH. This is temporary until this moves to moz.configure
 dnl (soon).
 _SAVE_PATH=$PATH
 case "${TOOLCHAIN_PREFIX}" in
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -55,17 +55,17 @@ def checking(what, callback=None):
                     error = e.message
                 display_ret = callback(ret) if callback else ret
                 if display_ret is True:
                     log.info('yes')
                 elif display_ret is False or display_ret is None:
                     log.info('no')
                 else:
                     log.info(display_ret)
-                if error is not None:
+                if error:
                     die(error)
             return ret
         return wrapped
     return decorator
 
 
 # Template to check for programs in $PATH.
 # - `var` is the name of the variable that will be set with `set_config` when
--- a/build/moz.configure/compilechecks.configure
+++ b/build/moz.configure/compilechecks.configure
@@ -13,24 +13,57 @@
 # - `body` is the code that will appear in the main function of the generated
 #   test program. `return 0;` is appended to the function body automatically.
 # - `language` is the language selection, so that the appropriate compiler is
 #   used.
 # - `flags` are the flags to be passed to the compiler, in addition to `-c`.
 # - `check_msg` is the message to be printed to accompany compiling the test
 #   program.
 @template
+@imports('textwrap')
 def try_compile(includes=None, body='', language='C++', flags=None, check_msg=None):
-    compiler = {
-        'C': c_compiler,
-        'C++': cxx_compiler,
-    }[language]
+    includes = includes or []
+    source_lines = ['#include <%s>' % f for f in includes]
+    source = '\n'.join(source_lines) + '\n'
+    source += textwrap.dedent('''\
+        int
+        main(void)
+        {
+        %s
+          ;
+          return 0;
+        }
+    ''' % body)
+
+    if check_msg:
+        def checking_fn(fn):
+            return checking(check_msg, callback=lambda r: r is not None)(fn)
+    else:
+        def checking_fn(fn):
+            return fn
 
-    return compiler.try_compile(includes, body, flags, check_msg)
+    def get_flags():
+        if flags:
+            return flags[:]
 
+    @depends(cxx_compiler, c_compiler, extra_toolchain_flags)
+    @checking_fn
+    def check(cxx_info, c_info, extra_flags):
+        flags = get_flags() or []
+        flags += extra_flags
+        flags.append('-c')
+
+        info = {
+            'C': c_info,
+            'C++': cxx_info,
+        }[language]
+        return try_invoke_compiler(info.wrapper + [info.compiler] + info.flags,
+                                   language, source, flags,
+                                   onerror=lambda: None)
+    return check
 
 # Checks for the presence of the given header on the target system by compiling
 # a test program including that header. The return value of the template is a
 # check function returning True if the header is present, and None if it is not.
 # The value of this check function is also used to set a variable (with set_define)
 # corresponding to the checked header. For instance, HAVE_MALLOC_H will be set in
 # defines if check_header if called with 'malloc.h' as input and malloc.h is
 # present on the target.
deleted file mode 100644
--- a/build/moz.configure/compilers-util.configure
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-@template
-@imports('textwrap')
-@imports(_from='mozbuild.configure', _import='DependsFunction')
-def compiler_class(compiler):
-    class Compiler(DependsFunction):
-        # Generates a test program and attempts to compile it. In case of
-        # failure, the resulting check will return None. If the test program
-        # succeeds, it will return the output of the test program.
-        # - `includes` are the includes (as file names) that will appear at the
-        #   top of the generated test program.
-        # - `body` is the code that will appear in the main function of the
-        #   generated test program. `return 0;` is appended to the function
-        #   body automatically.
-        # - `flags` are the flags to be passed to the compiler, in addition to
-        #   `-c`.
-        # - `check_msg` is the message to be printed to accompany compiling the
-        #   test program.
-        def try_compile(self, includes=None, body='', flags=None,
-                        check_msg=None, onerror=lambda: None):
-            includes = includes or []
-            source_lines = ['#include <%s>' % f for f in includes]
-            source = '\n'.join(source_lines) + '\n'
-            source += textwrap.dedent('''\
-                int
-                main(void)
-                {
-                %s
-                  ;
-                  return 0;
-                }
-            ''' % body)
-
-            if check_msg:
-                def checking_fn(fn):
-                    return checking(check_msg,
-                                    callback=lambda r: r is not None)(fn)
-            else:
-                def checking_fn(fn):
-                    return fn
-
-            def get_flags():
-                if flags:
-                    return flags[:]
-
-            @depends(self, extra_toolchain_flags)
-            @checking_fn
-            def func(compiler, extra_flags):
-                flags = get_flags() or []
-                flags += extra_flags
-                flags.append('-c')
-
-                return try_invoke_compiler(
-                    compiler.wrapper + [compiler.compiler] + compiler.flags,
-                    compiler.language, source, flags, onerror=onerror)
-
-            return func
-
-    compiler.__class__ = Compiler
-    return compiler
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -166,18 +166,16 @@ def toolchain_prefix(value, target, host
         return '%s-' % target.toolchain
 
 set_config('TOOLCHAIN_PREFIX', toolchain_prefix)
 add_old_configure_assignment('TOOLCHAIN_PREFIX', toolchain_prefix)
 
 
 # Compilers
 # ==============================================================
-include('compilers-util.configure')
-
 def try_preprocess(compiler, language, source):
     return try_invoke_compiler(compiler, language, source, ['-E'])
 
 @imports(_from='mozbuild.configure.constants', _import='CompilerType')
 @imports(_from='mozbuild.configure.constants',
          _import='CPU_preprocessor_checks')
 @imports(_from='mozbuild.configure.constants',
          _import='kernel_preprocessor_checks')
@@ -530,17 +528,17 @@ def compiler(language, host_or_target, c
         ('C++', host): 'HOST_CXX',
     }[language, host_or_target]
 
     default_compilers = {
         'C': lambda: default_c_compilers(host_or_target),
         'C++': lambda: default_cxx_compilers(c_compiler),
     }[language]()
 
-    what='the %s %s compiler' % (host_or_target_str, language)
+    what='the %s %s compiler' % (host_or_target_str, language),
 
     option(env=var, nargs=1, help='Path to %s' % what)
 
     # Handle the compiler given by the user through one of the CC/CXX/HOST_CC/
     # HOST_CXX variables.
     @depends_if(var)
     @imports(_from='itertools', _import='takewhile')
     @imports(_from='mozbuild.shellutil', _import='split', _as='shell_split')
@@ -694,17 +692,16 @@ def compiler(language, host_or_target, c
                     'Windows_Build_Prerequisites' % info.version)
 
         return namespace(
             wrapper=wrapper,
             compiler=compiler,
             flags=flags,
             type=info.type,
             version=info.version,
-            language=language,
         )
 
     @depends(valid_compiler)
     @checking('%s version' % what)
     def compiler_version(compiler):
         return compiler.version
 
     if language == 'C++':
@@ -733,36 +730,16 @@ def compiler(language, host_or_target, c
     # Set CC_TYPE/CC_VERSION/HOST_CC_TYPE/HOST_CC_VERSION to allow
     # old-configure to do some of its still existing checks.
     if language == 'C':
         add_old_configure_assignment(
             '%s_TYPE' % var, delayed_getattr(valid_compiler, 'type'))
         add_old_configure_assignment(
             '%s_VERSION' % var, delayed_getattr(valid_compiler, 'version'))
 
-    valid_compiler = compiler_class(valid_compiler)
-
-    kwargs = {
-        'C': {
-            'includes': ['stdio.h'],
-            'body': 'printf("Hello World\\n");',
-        },
-        'C++': {
-            'includes': ['new'],
-            'body': 'unsigned *test = new unsigned(42);',
-        },
-    }[language]
-
-    def compiler_error():
-        raise FatalCheckError('Failed compiling a simple %s source with %s'
-                              % (language, what))
-
-    valid_compiler.try_compile(check_msg='%s works' % what,
-                               onerror=compiler_error, **kwargs)
-
     return valid_compiler
 
 
 c_compiler = compiler('C', target)
 cxx_compiler = compiler('C++', target, c_compiler=c_compiler)
 host_c_compiler = compiler('C', host, other_compiler=c_compiler)
 host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
                              other_compiler=cxx_compiler,
--- a/old-configure.in
+++ b/old-configure.in
@@ -260,16 +260,27 @@ case "$target" in
     if test "$GCC" != "yes"; then
         # Check to see if we are really running in a msvc environemnt
         _WIN32_MSVC=1
         AC_CHECK_PROGS(MIDL, midl)
 
         # Make sure compilers are valid
         CFLAGS="$CFLAGS -TC -nologo"
         CXXFLAGS="$CXXFLAGS -TP -nologo"
+        AC_LANG_SAVE
+        AC_LANG_C
+        AC_TRY_COMPILE([#include <stdio.h>],
+            [ printf("Hello World\n"); ],,
+            AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
+
+        AC_LANG_CPLUSPLUS
+        AC_TRY_COMPILE([#include <new.h>],
+            [ unsigned *test = new unsigned(42); ],,
+            AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
+        AC_LANG_RESTORE
 
         changequote(,)
         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
         changequote([,])
 
         _MSC_VER=`echo ${CC_VERSION} | cut -c 1-2,4-5`
 
         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
--- a/python/mozbuild/mozbuild/test/configure/test_header_checks.py
+++ b/python/mozbuild/mozbuild/test/configure/test_header_checks.py
@@ -39,50 +39,42 @@ class TestHeaderChecks(unittest.TestCase
                         expected_flags=None):
 
         paths = {
             os.path.abspath('/usr/bin/mockcc'): self.get_mock_compiler(
                 expected_test_content=expected_test_content,
                 expected_flags=expected_flags),
         }
 
-        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
-
         mock_compiler_defs = textwrap.dedent('''\
             @depends('--help')
-            def extra_toolchain_flags(_):
-                return []
-
-            include('%s/compilers-util.configure')
-
-            @compiler_class
-            @depends('--help')
             def c_compiler(_):
                 return namespace(
                     flags=[],
                     compiler=os.path.abspath('/usr/bin/mockcc'),
                     wrapper=[],
-                    language='C',
                 )
 
-            @compiler_class
             @depends('--help')
             def cxx_compiler(_):
                 return namespace(
                     flags=[],
                     compiler=os.path.abspath('/usr/bin/mockcc'),
                     wrapper=[],
-                    language='C++',
                 )
-        ''' % base_dir)
+            @depends('--help')
+            def extra_toolchain_flags(_):
+                return []
+        ''')
 
         config = {}
         out = StringIO()
         sandbox = ConfigureTestSandbox(paths, config, {}, ['/bin/configure'],
                                        out, out)
+        base_dir = os.path.join(topsrcdir, 'build', 'moz.configure')
         sandbox.include_file(os.path.join(base_dir, 'util.configure'))
         sandbox.include_file(os.path.join(base_dir, 'checks.configure'))
         exec_(mock_compiler_defs, sandbox)
         sandbox.include_file(os.path.join(base_dir, 'compilechecks.configure'))
 
         status = 0
         try:
             exec_(command, sandbox)
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
@@ -306,60 +306,53 @@ class LinuxToolchainTest(BaseToolchainTe
     GCC_4_7_RESULT = ('Only GCC 4.8 or newer is supported '
                       '(found version 4.7.3).')
     GXX_4_7_RESULT = GCC_4_7_RESULT
     GCC_4_9_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='4.9.3',
         type='gcc',
         compiler='/usr/bin/gcc',
-        language='C',
     )
     GXX_4_9_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='4.9.3',
         type='gcc',
         compiler='/usr/bin/g++',
-        language='C++',
     )
     GCC_5_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='5.2.1',
         type='gcc',
         compiler='/usr/bin/gcc-5',
-        language='C',
     )
     GXX_5_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='5.2.1',
         type='gcc',
         compiler='/usr/bin/g++-5',
-        language='C++',
     )
     CLANG_3_3_RESULT = CompilerResult(
         flags=[],
         version='3.3.0',
         type='clang',
         compiler='/usr/bin/clang-3.3',
-        language='C',
     )
     CLANGXX_3_3_RESULT = 'Only clang/llvm 3.6 or newer is supported.'
     CLANG_3_6_RESULT = CompilerResult(
         flags=['-std=gnu99'],
         version='3.6.2',
         type='clang',
         compiler='/usr/bin/clang',
-        language='C',
     )
     CLANGXX_3_6_RESULT = CompilerResult(
         flags=['-std=gnu++11'],
         version='3.6.2',
         type='clang',
         compiler='/usr/bin/clang++',
-        language='C++',
     )
 
     def test_gcc(self):
         # We'll try gcc and clang, and find gcc first.
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.GCC_4_9_RESULT,
             'cxx_compiler': self.GXX_4_9_RESULT,
         })
@@ -755,55 +748,45 @@ class WindowsToolchainTest(BaseToolchain
         'This version (19.00.23506) of the MSVC compiler is not supported.\n'
         'You must install Visual C++ 2015 Update 2 or newer in order to build.\n'
         'See https://developer.mozilla.org/en/Windows_Build_Prerequisites')
     VS_2015u2_RESULT = CompilerResult(
         flags=[],
         version='19.00.23918',
         type='msvc',
         compiler='/usr/bin/cl',
-        language='C',
-    )
-    VSXX_2015u2_RESULT = CompilerResult(
-        flags=[],
-        version='19.00.23918',
-        type='msvc',
-        compiler='/usr/bin/cl',
-        language='C++',
     )
     CLANG_CL_3_9_RESULT = CompilerResult(
         flags=['-Xclang', '-std=gnu99',
                '-fms-compatibility-version=18.00.30723', '-fallback'],
         version='18.00.30723',
         type='clang-cl',
         compiler='/usr/bin/clang-cl',
-        language='C',
     )
     CLANGXX_CL_3_9_RESULT = CompilerResult(
         flags=['-fms-compatibility-version=18.00.30723', '-fallback'],
         version='18.00.30723',
         type='clang-cl',
         compiler='/usr/bin/clang-cl',
-        language='C++',
     )
     CLANG_3_3_RESULT = LinuxToolchainTest.CLANG_3_3_RESULT
     CLANGXX_3_3_RESULT = LinuxToolchainTest.CLANGXX_3_3_RESULT
     CLANG_3_6_RESULT = LinuxToolchainTest.CLANG_3_6_RESULT
     CLANGXX_3_6_RESULT = LinuxToolchainTest.CLANGXX_3_6_RESULT
     GCC_4_7_RESULT = LinuxToolchainTest.GCC_4_7_RESULT
     GCC_4_9_RESULT = LinuxToolchainTest.GCC_4_9_RESULT
     GXX_4_9_RESULT = LinuxToolchainTest.GXX_4_9_RESULT
     GCC_5_RESULT = LinuxToolchainTest.GCC_5_RESULT
     GXX_5_RESULT = LinuxToolchainTest.GXX_5_RESULT
 
     # VS2015u2 or greater is required.
     def test_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.VS_2015u2_RESULT,
-            'cxx_compiler': self.VSXX_2015u2_RESULT,
+            'cxx_compiler': self.VS_2015u2_RESULT,
         })
 
     def test_unsupported_msvc(self):
         self.do_toolchain_test(self.PATHS, {
             'c_compiler': self.VS_2015u1_RESULT,
         }, environ={
             'CC': '/opt/VS_2015u1/bin/cl',
         })
--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
+++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py
@@ -343,28 +343,27 @@ class CompilerResult(ReadOnlyNamespace):
     '''Helper of convenience to manipulate toolchain results in unit tests
 
     When adding a dict, the result is a new CompilerResult with the values
     from the dict replacing those from the CompilerResult, except for `flags`,
     where the value from the dict extends the `flags` in `self`.
     '''
 
     def __init__(self, wrapper=None, compiler='', version='', type='',
-                 language='', flags=None):
+                 flags=None):
         if flags is None:
             flags = []
         if wrapper is None:
             wrapper = []
         super(CompilerResult, self).__init__(
             flags=flags,
             version=version,
             type=type,
             compiler=mozpath.abspath(compiler),
             wrapper=wrapper,
-            language=language,
         )
 
     def __add__(self, other):
         assert isinstance(other, dict)
         result = copy.deepcopy(self.__dict__)
         for k, v in other.iteritems():
             if k == 'flags':
                 result.setdefault(k, []).extend(v)
@@ -376,57 +375,52 @@ class CompilerResult(ReadOnlyNamespace):
 class TestCompilerResult(unittest.TestCase):
     def test_compiler_result(self):
         result = CompilerResult()
         self.assertEquals(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath(''),
             'version': '',
             'type': '',
-            'language': '',
             'flags': [],
         })
 
         result = CompilerResult(
             compiler='/usr/bin/gcc',
             version='4.2.1',
             type='gcc',
-            language='C',
             flags=['-std=gnu99'],
         )
         self.assertEquals(result.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
             'type': 'gcc',
-            'language': 'C',
             'flags': ['-std=gnu99'],
         })
 
         result2 = result + {'flags': ['-m32']}
         self.assertEquals(result2.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc'),
             'version': '4.2.1',
             'type': 'gcc',
-            'language': 'C',
             'flags': ['-std=gnu99', '-m32'],
         })
         # Original flags are untouched.
         self.assertEquals(result.flags, ['-std=gnu99'])
 
         result3 = result + {
             'compiler': '/usr/bin/gcc-4.7',
             'version': '4.7.3',
             'flags': ['-m32'],
         }
         self.assertEquals(result3.__dict__, {
             'wrapper': [],
             'compiler': mozpath.abspath('/usr/bin/gcc-4.7'),
             'version': '4.7.3',
             'type': 'gcc',
-            'language': 'C',
             'flags': ['-std=gnu99', '-m32'],
         })
 
 
 if __name__ == '__main__':
     main()