bug 1397263 - Move AS and MIDL checks to toolchain.configure. r?build draft
authorTed Mielczarek <ted@mielczarek.org>
Wed, 06 Sep 2017 08:56:21 -0400
changeset 706968 8e6b1c7e229530e6dd612345b625ae80a3ad39db
parent 705606 ba283baf4e98aa3a5f45a17981077b98697aa73a
child 706969 5db4c743f9f4d0fe772f52c34c44db16e7e933a0
push id91972
push userbmo:ted@mielczarek.org
push dateMon, 04 Dec 2017 15:07:44 +0000
reviewersbuild
bugs1397263
milestone59.0a1
bug 1397263 - Move AS and MIDL checks to toolchain.configure. r?build This is a fairly straightforward port of the AS and MIDL tool checks from old-configure to toolchain.configure. AS is a little quirky in that we currently do a normal-looking check for it, but then override that value to be the C compiler for non-Windows builds, and ml[64] for Windows builds. After migrating those checks, the only things left in the MOZ_DEFAULT_COMPILER macro in compiler-opts.m4 were some unused bits, so I removed them: * Setting of CPP/CXXCPP, which are set in toolchain.configure now * Setting HOST_LDFLAGS to empty, which doesn't seem particularly useful. There was also a quirky old test that the assembler was ml[64] when js-ctypes is enabled that I removed, I don't think it provides any value since this patch will ensure that we're using the right assembler for Windows builds. MozReview-Commit-ID: F2BjDcZKAwj
build/autoconf/compiler-opts.m4
build/autoconf/ios.m4
build/autoconf/toolchain.m4
build/moz.configure/toolchain.configure
js/src/old-configure.in
old-configure.in
--- a/build/autoconf/compiler-opts.m4
+++ b/build/autoconf/compiler-opts.m4
@@ -1,44 +1,14 @@
 dnl This Source Code Form is subject to the terms of the Mozilla Public
 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 dnl Add compiler specific options
 
-AC_DEFUN([MOZ_DEFAULT_COMPILER],
-[
-dnl Default to MSVC for win32 and gcc-4.2 for darwin
-dnl ==============================================================
-if test -z "$CROSS_COMPILE"; then
-case "$target" in
-*-mingw*)
-    if test -z "$CPP"; then CPP="$CC -E -nologo"; fi
-    if test -z "$CXXCPP"; then CXXCPP="$CXX -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
-    if test -z "$AS"; then
-        case "${target_cpu}" in
-        i*86)
-            AS=ml;
-            ;;
-        x86_64)
-            AS=ml64;
-            ;;
-        esac
-    fi
-    if test -z "$MIDL"; then MIDL=midl; fi
-
-    # need override this flag since we don't use $(LDFLAGS) for this.
-    if test -z "$HOST_LDFLAGS" ; then
-        HOST_LDFLAGS=" "
-    fi
-    ;;
-esac
-fi
-])
-
 dnl ============================================================================
 dnl C++ rtti
 dnl We don't use it in the code, but it can be usefull for debugging, so give
 dnl the user the option of enabling it.
 dnl ============================================================================
 AC_DEFUN([MOZ_RTTI],
 [
 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
--- a/build/autoconf/ios.m4
+++ b/build/autoconf/ios.m4
@@ -92,16 +92,15 @@ if test -n "$ios_sdk"; then
                 ;;
    esac
    ARGS=" $ARGS -isysroot $ios_sdk_path $ios_target_arg"
    # Now find our tools
    MOZ_IOS_PATH_PROG(CC, clang, $ARGS)
    MOZ_IOS_PATH_PROG(CXX, clang++, $ARGS)
    export CPP="$CC -E"
    MOZ_IOS_PATH_PROG(AR)
-   MOZ_IOS_PATH_PROG(AS, as, $ARGS)
    MOZ_IOS_PATH_PROG(OTOOL)
    MOZ_IOS_PATH_PROG(STRIP)
    export PKG_CONFIG_PATH=${ios_sdk_path}/usr/lib/pkgconfig/
 fi
 
 AC_SUBST(MOZ_IOS)
 ])
--- a/build/autoconf/toolchain.m4
+++ b/build/autoconf/toolchain.m4
@@ -72,17 +72,16 @@ case "${TOOLCHAIN_PREFIX}" in
     PATH="/:$PATH"
     ;;
 esac
 AC_PROG_CC
 AC_PROG_CXX
 
 AC_CHECK_PROGS(RANLIB, "${TOOLCHAIN_PREFIX}ranlib", :)
 AC_CHECK_PROGS(AR, "${TOOLCHAIN_PREFIX}ar", :)
-AC_CHECK_PROGS(AS, "${TOOLCHAIN_PREFIX}as", :)
 AC_CHECK_PROGS(LIPO, "${TOOLCHAIN_PREFIX}lipo", :)
 AC_CHECK_PROGS(STRIP, "${TOOLCHAIN_PREFIX}strip", :)
 AC_CHECK_PROGS(WINDRES, "${TOOLCHAIN_PREFIX}windres", :)
 AC_CHECK_PROGS(OTOOL, "${TOOLCHAIN_PREFIX}otool", :)
 AC_CHECK_PROGS(INSTALL_NAME_TOOL, "${TOOLCHAIN_PREFIX}install_name_tool", :)
 AC_CHECK_PROGS(OBJCOPY, "${TOOLCHAIN_PREFIX}objcopy", :)
 PATH=$_SAVE_PATH
 ])
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -314,16 +314,20 @@ def first_toolchain_prefix(toolchain_pre
     # or when cross-compiling for Android.
     if toolchain_prefix and (target.os == 'Android' or len(toolchain_prefix) == 1):
         return toolchain_prefix[0]
 
 
 set_config('TOOLCHAIN_PREFIX', first_toolchain_prefix)
 add_old_configure_assignment('TOOLCHAIN_PREFIX', first_toolchain_prefix)
 
+# A helper for generating toolchain-prefixed tool names.
+def with_toolchain_prefix(name, toolchain_prefix):
+    return tuple('%s%s' % (p, name) for p in toolchain_prefix)
+
 
 # Compilers
 # ==============================================================
 include('compilers-util.configure')
 
 
 def try_preprocess(compiler, language, source):
     return try_invoke_compiler(compiler, language, source, ['-E'])
@@ -1502,16 +1506,37 @@ def select_linker(linker, c_compiler, de
         else:
             die("Could not use lld as linker")
 
 
 set_config('LD_IS_BFD', depends(select_linker.KIND)
            (lambda x: x == 'bfd' or None))
 set_config('LINKER_LDFLAGS', select_linker.LINKER_FLAG)
 
+# Assembler detection
+# ==============================================================
+
+@depends(target, c_compiler)
+def as_names(target, c_compiler):
+    if c_compiler.type in ('msvc', 'clang-cl'):
+        ml = {
+            'x86': 'ml',
+            'x86_64': 'ml64',
+        }.get(target.cpu)
+        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)
+
+
+# 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',
                              depends_if('--enable-clang-plugin')(lambda _: True))
 
 js_option('--enable-mozsearch-plugin', env='ENABLE_MOZSEARCH_PLUGIN',
@@ -1521,17 +1546,33 @@ add_old_configure_assignment('ENABLE_MOZ
                              depends_if('--enable-mozsearch-plugin')(lambda _: True))
 
 # Code Coverage
 # ==============================================================
 
 js_option('--enable-coverage', env='MOZ_CODE_COVERAGE',
           help='Enable code coverage')
 
-
 @depends('--enable-coverage')
 def code_coverage(value):
     if value:
         return True
 
 
 set_config('MOZ_CODE_COVERAGE', code_coverage)
 set_define('MOZ_CODE_COVERAGE', code_coverage)
+
+
+@depends(c_compiler, toolchain_prefix)
+def midl_names(c_compiler, toolchain_prefix):
+    if c_compiler.type in ['gcc', 'clang']:
+        # mingw
+        widl = ('widl', )
+        if toolchain_prefix:
+            widl = with_toolchain_prefix('widl', toolchain_prefix) + widl
+        return widl
+    else:
+        return ('midl',)
+
+midl = check_prog('MIDL', midl_names, when=depends(target)(lambda t: t.kernel == 'WINNT'))
+
+# Needed until we move MIDL_FLAGS and --disable-accessibility from old-configure
+add_old_configure_assignment('MIDL', midl)
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -58,18 +58,16 @@ dnl ====================================
 MISSING_X=
 
 dnl Initialize the Pthread test variables early so they can be
 dnl  overridden by each platform.
 dnl ========================================================
 USE_PTHREADS=
 _PTHREAD_LDFLAGS=""
 
-MOZ_DEFAULT_COMPILER
-
 if test -z "$JS_STANDALONE"; then
   autoconfmk=autoconf-js.mk
 fi
 AC_SUBST(autoconfmk)
 
 if test -n "$JS_STANDALONE"; then
   jsconfdefs=$_objdir/js/src/js-confdefs.h
 else
@@ -103,17 +101,16 @@ if test "$COMPILE_ENVIRONMENT"; then
 #     - $target (in its correct usage) is for compilers who generate code for a
 #       different platform than $host, so it would not be used by Mozilla.
 if test "$target" != "$host"; then
     MOZ_CROSS_COMPILER
 else
     AC_PROG_CC
     AC_PROG_CXX
     AC_PROG_RANLIB
-    MOZ_PATH_PROGS(AS, $AS as, $CC)
     AC_CHECK_PROGS(AR, ar, :)
     AC_CHECK_PROGS(STRIP, strip, :)
     AC_CHECK_PROGS(WINDRES, windres, :)
     if test -z "$HOST_CC"; then
         HOST_CC='$(CC)'
     fi
     if test -z "$HOST_CXX"; then
         HOST_CXX='$(CXX)'
@@ -403,20 +400,17 @@ AC_SUBST(MOZJS_MAJOR_VERSION)
 AC_SUBST(MOZJS_MINOR_VERSION)
 AC_SUBST(MOZJS_PATCH_VERSION)
 AC_SUBST(MOZJS_ALPHA)
 
 
 dnl ========================================================
 dnl set the defaults first
 dnl ========================================================
-AS_BIN=$AS
 AR_EXTRACT='$(AR) x'
-AS='$(CC)'
-AS_DASH_C_FLAG='-c'
 DIRENT_INO=d_ino
 MOZ_USER_DIR=".mozilla"
 
 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
 
 dnl Configure platform-specific CPU architecture compiler options.
 dnl ==============================================================
 MOZ_ARCH_OPTS
@@ -677,19 +671,16 @@ case "$target" in
         MOZ_FIX_LINK_PATHS=
 
         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
         WIN32_GUI_EXE_LDFLAGS=-mwindows
     else
         TARGET_COMPILER_ABI=msvc
         HOST_CC='$(CC)'
         HOST_CXX='$(CXX)'
-        if test "$AS_BIN"; then
-            AS="$(basename "$AS_BIN")"
-        fi
         AR='lib'
         AR_FLAGS='-NOLOGO -OUT:$@'
         AR_EXTRACT=
         RANLIB='echo not_ranlib'
         STRIP='echo not_strip'
         PKG_SKIP_STRIP=1
         MKSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
         MKCSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
@@ -1930,24 +1921,16 @@ AC_SUBST_LIST(EDITLINE_LIBS)
 
 dnl ========================================================
 dnl =
 dnl = Standalone module options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
 
-if test "$JS_HAS_CTYPES"; then
-  dnl JS_HAS_CTYPES is defined by Python configure. This check remains
-  dnl as long as determining $AS remains in old-configure.
-  dnl Error out if we're on MSVC and MASM is unavailable.
-  if test -n "$_MSC_VER" -a \( "$AS" != "ml.exe" -a "$AS" != "ml64.exe" \); then
-    AC_MSG_ERROR([\"$AS\" is not a suitable assembler to build js-ctypes. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK. Or do not use --enable-ctypes.])
-  fi
-fi
 
 dnl ========================================================
 dnl =
 dnl = Options for generating the shell as a script
 dnl =
 dnl ========================================================
 
 MOZ_ARG_WITH_STRING(qemu-exe,
@@ -1963,19 +1946,17 @@ dnl ====================================
 dnl =
 dnl = Maintainer debug option (no --enable equivalent)
 dnl =
 dnl ========================================================
 
 AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AR_EXTRACT)
-AC_SUBST(AS)
 AC_SUBST_LIST(ASFLAGS)
-AC_SUBST(AS_DASH_C_FLAG)
 AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(WINDRES)
 AC_SUBST(IMPLIB)
 AC_SUBST(FILTER)
 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
 AC_SUBST(WARNINGS_AS_ERRORS)
 AC_SUBST(LIBICONV)
--- a/old-configure.in
+++ b/old-configure.in
@@ -73,18 +73,16 @@ dnl ====================================
 MISSING_X=
 
 dnl Initialize the Pthread test variables early so they can be
 dnl  overridden by each platform.
 dnl ========================================================
 MOZ_USE_PTHREADS=
 _PTHREAD_LDFLAGS=""
 
-MOZ_DEFAULT_COMPILER
-
 if test "$COMPILE_ENVIRONMENT"; then
     MOZ_ANDROID_NDK
 fi # COMPILE_ENVIRONMENT
 
 case "$target" in
 *-android*|*-linuxandroid*)
     AC_DEFINE(ANDROID)
     ;;
@@ -118,17 +116,16 @@ else
     AC_PROG_CC
     case "$target" in
     *-mingw*)
       # Work around the conftest.exe access problem on Windows
       sleep 2
     esac
     AC_PROG_CXX
     AC_PROG_RANLIB
-    MOZ_PATH_PROGS(AS, $AS as, $CC)
     AC_CHECK_PROGS(AR, ar, :)
     AC_CHECK_PROGS(STRIP, strip, :)
     AC_CHECK_PROGS(WINDRES, windres, :)
     AC_CHECK_PROGS(OTOOL, otool, :)
     if test -z "$HOST_RANLIB"; then
         HOST_RANLIB="$RANLIB"
     fi
     if test -z "$HOST_AR"; then
@@ -151,17 +148,16 @@ dnl ====================================
 
 WINVER=601
 
 case "$target" in
 *-mingw*)
     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"); ],,
@@ -325,17 +321,16 @@ case "$target" in
                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
         then
             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
         fi
 
-        AC_CHECK_PROGS(MIDL, $target-widl widl)
         if test -n "$MIDL"; then
             case "$target" in
             i*86-*)
                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
                 ;;
             x86_64-*)
                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
                 ;;
@@ -448,20 +443,17 @@ AC_PATH_XTRA
 
 XCFLAGS="$X_CFLAGS"
 
 fi # COMPILE_ENVIRONMENT
 
 dnl ========================================================
 dnl set the defaults first
 dnl ========================================================
-AS_BIN=$AS
 AR_EXTRACT='$(AR) x'
-AS='$(CC)'
-AS_DASH_C_FLAG='-c'
 DIRENT_INO=d_ino
 MOZ_USER_DIR=".mozilla"
 
 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
 
 MOZ_FS_LAYOUT=unix
 
 dnl Configure platform-specific CPU architecture compiler options.
@@ -903,19 +895,16 @@ case "$target" in
 
         # GCC/binutils can't link to a function if we try to include dllexport function
         # in the same library as dllimport caller. To work around it, we build NSPR
         # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
         # function thunks need to be generated for cross-DLL calls.
         MOZ_FOLD_LIBS_FLAGS="-mnop-fun-dllimport"
     else
         TARGET_COMPILER_ABI=msvc
-        if test "$AS_BIN"; then
-            AS="$(basename "$AS_BIN")"
-        fi
         AR='lib'
         AR_FLAGS='-NOLOGO -OUT:$@'
         AR_EXTRACT=
         RANLIB='echo not_ranlib'
         STRIP='echo not_strip'
         PKG_SKIP_STRIP=1
         MKSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
         MKCSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
@@ -4463,19 +4452,17 @@ dnl ====================================
 dnl =
 dnl = Maintainer debug option (no --enable equivalent)
 dnl =
 dnl ========================================================
 
 AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AR_EXTRACT)
-AC_SUBST(AS)
 AC_SUBST_LIST(ASFLAGS)
-AC_SUBST(AS_DASH_C_FLAG)
 AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(WINDRES)
 AC_SUBST(IMPLIB)
 AC_SUBST(FILTER)
 AC_SUBST(MOZ_AUTH_EXTENSION)
 AC_SUBST(MOZ_PREF_EXTENSIONS)
 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)