Bug 1519047 - Move FFVPX_ASFLAGS and related variables to python configure. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 18:17:36 +0000
changeset 513556 8bac283f6c7e
parent 513555 daf50f25895d
child 513557 c41c32486c7e
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1519047
milestone66.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 1519047 - Move FFVPX_ASFLAGS and related variables to python configure. r=nalexander This also moves the corresponding ASFLAGS from moz.build to python configure. Differential Revision: https://phabricator.services.mozilla.com/D16320
media/ffvpx/ffvpxcommon.mozbuild
old-configure.in
toolkit/moz.configure
--- a/media/ffvpx/ffvpxcommon.mozbuild
+++ b/media/ffvpx/ffvpxcommon.mozbuild
@@ -6,49 +6,26 @@
 
 # Add assembler flags and includes
 ASFLAGS += CONFIG['FFVPX_ASFLAGS']
 ASFLAGS += ['-I%s/media/ffvpx/' % TOPSRCDIR]
 ASFLAGS += ['-I%s/media/ffvpx/libavcodec/x86/' % TOPSRCDIR]
 ASFLAGS += ['-I%s/media/ffvpx/libavutil/x86/' % TOPSRCDIR]
 
 if CONFIG['FFVPX_ASFLAGS']:
+    if CONFIG['FFVPX_USE_YASM']:
+        USE_YASM = True
+
     if CONFIG['OS_ARCH'] == 'WINNT':
-        USE_YASM = True
        # Fix inline symbols and math defines for windows.
         DEFINES['_USE_MATH_DEFINES'] = True
         DEFINES['inline'] = "__inline"
-        # 32-bit windows need to prefix symbols with an underscore.
-        if CONFIG['CPU_ARCH'] == 'x86':
-            ASFLAGS += ['-DPREFIX']
-            ASFLAGS += ['-Pconfig_win32.asm']
-        else:
-            ASFLAGS += ['-Pconfig_win64.asm']
-    elif CONFIG['OS_ARCH'] == 'Darwin':
-        USE_YASM = True
-        # 32/64-bit macosx assemblers need to prefix symbols with an underscore.
-        ASFLAGS += [
-            '-Pconfig_darwin64.asm',
-            '-DPREFIX'
-        ]
-    elif CONFIG['CPU_ARCH'] != 'arm' and CONFIG['CPU_ARCH'] != 'aarch4':
-        USE_YASM = True
-        # Default to unix, similar to how ASFLAGS setup works in configure.in
-        ASFLAGS += ['-Pconfig_unix64.asm']
 
-    if USE_YASM:
-        # default disabled components
-        ASFLAGS += ['-Pdefaults_disabled.asm']
-        if int(CONFIG['YASM_MAJOR_VERSION']) == 1 and int(CONFIG['YASM_MINOR_VERSION']) < 2:
-            DEFINES['YASM_MISSING_AVX2'] = True
-            ASFLAGS += [
-                '-DHAVE_AVX2=0',
-                '-DHAVE_AVX2_INTERNAL=0',
-                '-DHAVE_AVX2_EXTERNAL=0',
-            ]
+    if USE_YASM and not CONFIG['YASM_HAS_AVX2']:
+        DEFINES['YASM_MISSING_AVX2'] = True
 
 
 LOCAL_INCLUDES += ['/media/ffvpx']
 
 # We allow warnings for third-party code that can be updated from upstream.
 AllowCompilerWarnings()
 
 # Suppress warnings in third-party code.
--- a/old-configure.in
+++ b/old-configure.in
@@ -2238,58 +2238,16 @@ if test -n "$MOZ_CRASHREPORTER"; then
     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
       MOZ_CRASHREPORTER_INJECTOR=1
       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
     fi
   fi
 fi
 
 dnl ========================================================
-dnl = FFmpeg's ffvpx configuration
-dnl ========================================================
-
-MOZ_FFVPX=
-MOZ_FFVPX_FLACONLY=
-case "$CPU_ARCH" in
-  x86|x86_64)
-      MOZ_FFVPX=1
-      dnl Use same conditional as MOZ_LIBAV_FFT to enable FFmpeg's ffvpx assembly decoder.
-      if test -n "$LIBAV_FFT_ASFLAGS"; then
-          FFVPX_ASFLAGS=$LIBAV_FFT_ASFLAGS
-      else
-          dnl On x86 system with assembly optimizations disabled, the ffvp9 and
-          dnl ffvp8 decoders give worse performance than libvpx ones. So we only
-          dnl enable the FFmpeg FLAC decoder on those machines.
-          MOZ_FFVPX_FLACONLY=1
-      fi
-  ;;
-  arm*|aarch64)
-      case "$OS_TARGET" in
-        WINNT)
-          dnl don't set up anything special
-          ;;
-        *)
-          MOZ_FFVPX=1
-          MOZ_FFVPX_FLACONLY=1
-          dnl Use same conditional as MOZ_LIBVPX to enable FFmpeg's ffvpx assembly decoder.
-          dnl aarch 64 FLAC decoder for now will be C only.
-          FFVPX_ASFLAGS=$VPX_ASFLAGS
-          ;;
-      esac
-  ;;
-esac
-
-if test -n "$MOZ_FFVPX"; then
-  AC_DEFINE(MOZ_FFVPX)
-fi
-if test -n "$MOZ_FFVPX_FLACONLY"; then
-  AC_DEFINE(MOZ_FFVPX_FLACONLY)
-fi
-
-dnl ========================================================
 dnl = Enable compilation of specific extension modules
 dnl ========================================================
 
 MOZ_ARG_ENABLE_STRING(extensions,
 [  --enable-extensions     Enable extensions],
 [ for option in `echo $enableval | sed 's/,/ /g'`; do
     if test "$option" = "yes" -o "$option" = "all"; then
         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
@@ -3607,19 +3565,16 @@ AC_SUBST_LIST(DSO_PIC_CFLAGS)
 AC_SUBST(DSO_LDOPTS)
 AC_SUBST(BIN_SUFFIX)
 AC_SUBST(USE_N32)
 AC_SUBST(CC_VERSION)
 AC_SUBST(NS_ENABLE_TSF)
 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
 
-AC_SUBST(MOZ_FFVPX)
-AC_SUBST(MOZ_FFVPX_FLACONLY)
-AC_SUBST_LIST(FFVPX_ASFLAGS)
 AC_SUBST(MOZ_DEVTOOLS)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
 
 AC_SUBST(DMG_TOOL)
 
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -1375,17 +1375,16 @@ with only_when(compile_environment):
                 flags.append('-mfloat-abi=softfp')
         elif vpx and vpx.use_yasm and target.os != 'WINNT' and target.cpu != 'x86_64':
             flags = ['-DPIC']
         return flags
 
 
     set_config('VPX_USE_YASM', in_tree_vpx.use_yasm)
     set_config('VPX_ASFLAGS', vpx_as_flags)
-    add_old_configure_assignment('VPX_ASFLAGS', vpx_as_flags)
 
 
 # JPEG
 # ====
 
 with only_when(compile_environment):
     option('--with-system-jpeg', nargs='?',
            help='Use system libjpeg (installed at given prefix)')
@@ -1506,27 +1505,95 @@ with only_when(compile_environment):
             else:
                 need_yasm = Version('1.1')
             return namespace(flags=flags, need_yasm=need_yasm)
 
 
     set_config('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
     set_define('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
     set_config('LIBAV_FFT_ASFLAGS', libav_fft.flags)
-    add_old_configure_assignment('LIBAV_FFT_ASFLAGS', libav_fft.flags)
+
+
+# FFmpeg's ffvpx configuration
+# ==============================================================
+with only_when(compile_environment):
+    @depends_if(yasm_version)
+    def yasm_has_avx2(yasm_version):
+        return yasm_version >= '1.2'
+
+
+    set_config('YASM_HAS_AVX2', yasm_has_avx2)
+
+
+    @depends(yasm_has_avx2, libav_fft, vpx_as_flags, target)
+    def ffvpx(yasm_has_avx2, libav_fft, vpx_as_flags, target):
+        enable = flac_only = use_yasm = False
+        flags = []
+        if target.cpu in ('x86', 'x86_64'):
+            enable = True
+            if libav_fft and libav_fft.flags:
+                use_yasm = True
+                flags.extend(libav_fft.flags)
+                if target.kernel == 'WINNT':
+                    if target.cpu == 'x86':
+                        # 32-bit windows need to prefix symbols with an underscore.
+                        flags.extend(('-DPREFIX', '-Pconfig_win32.asm'))
+                    else:
+                        flags.append('-Pconfig_win64.asm')
+                elif target.kernel == 'Darwin':
+                    # 32/64-bit macosx assemblers need to prefix symbols with an
+                    # underscore.
+                    flags.extend(('-DPREFIX', '-Pconfig_darwin64.asm'))
+                else:
+                    # Default to unix.
+                    flags.append('-Pconfig_unix64.asm')
+            else:
+                flac_only = True
+        elif target.cpu in ('arm', 'aarch64') and \
+                target.kernel not in ('WINNT', 'Darwin'):
+            enable = flac_only = True
+            flags.extend(vpx_as_flags)
+
+        if use_yasm:
+            # default disabled components
+            flags.append('-Pdefaults_disabled.asm')
+            if not yasm_has_avx2:
+                flags.extend((
+                    '-DHAVE_AVX2=0',
+                    '-DHAVE_AVX2_INTERNAL=0',
+                    '-DHAVE_AVX2_EXTERNAL=0',
+                ))
+
+        return namespace(
+            enable=enable,
+            use_yasm=use_yasm,
+            flac_only=flac_only,
+            flags=flags,
+        )
+
+
+    set_config('MOZ_FFVPX', True, when=ffvpx.enable)
+    set_define('MOZ_FFVPX', True, when=ffvpx.enable)
+    set_config('MOZ_FFVPX_FLACONLY', True, when=ffvpx.flac_only)
+    set_define('MOZ_FFVPX_FLACONLY', True, when=ffvpx.flac_only)
+    set_config('FFVPX_ASFLAGS', ffvpx.flags)
+    set_config('FFVPX_USE_YASM', True, when=ffvpx.use_yasm)
 
 
 @depends(yasm_version, in_tree_vpx.need_yasm, in_tree_jpeg.use_yasm,
-         libav_fft.need_yasm)
+         libav_fft.need_yasm, ffvpx.use_yasm)
 @imports(_from='__builtin__', _import='sorted')
-def valid_yasm_version(yasm_version, for_vpx, for_jpeg, for_libav):
+def valid_yasm_version(yasm_version, for_vpx, for_jpeg, for_libav,
+                       for_ffvpx=False):
+    # Note: the default for for_ffvpx above only matters for unit tests.
     requires = {
         'vpx': for_vpx,
         'jpeg': for_jpeg,
         'libav': for_libav,
+        'ffvpx': for_ffvpx,
     }
     requires = {k: v for (k, v) in requires.items() if v}
     if requires and not yasm_version:
         items = sorted(requires.keys())
         if len(items) > 1:
             what = ' and '.join((', '.join(items[:-1]), items[-1]))
         else:
             what = items[0]