Bug 1515257 - Move --with-system-libvpx to python configure. r=firefox-build-system-reviewers,ted
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 19 Dec 2018 11:39:08 +0000
changeset 508522 1a8798cea67c7c12354545172447be1c70cd6549
parent 508521 384ba32c3440caa85383622f198d30b618c2f1f1
child 508523 b15b5b6dbce20140369dbe829b26f7fdbb0bf93a
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, ted
bugs1515257
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 1515257 - Move --with-system-libvpx to python configure. r=firefox-build-system-reviewers,ted Depends on D14951 Differential Revision: https://phabricator.services.mozilla.com/D14952
build/moz.configure/old.configure
old-configure.in
toolkit/moz.configure
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -248,17 +248,16 @@ def old_configure_options(*options):
     '--with-nss-prefix',
     '--with-qemu-exe',
     '--with-sixgill',
     '--with-soft-float',
     '--with-system-bz2',
     '--with-system-icu',
     '--with-system-jpeg',
     '--with-system-libevent',
-    '--with-system-libvpx',
     '--with-system-nspr',
     '--with-system-nss',
     '--with-system-png',
     '--with-system-zlib',
     '--with-thumb',
     '--with-thumb-interwork',
     '--with-unify-dist',
     '--with-user-appdir',
--- a/old-configure.in
+++ b/old-configure.in
@@ -1803,18 +1803,16 @@ MOZ_ARG_HEADER(Application)
 
 ENABLE_SYSTEM_EXTENSION_DIRS=1
 MOZ_BRANDING_DIRECTORY=
 MOZ_OFFICIAL_BRANDING=
 MOZ_AUTH_EXTENSION=1
 if test "$MOZ_IOS"; then
    MOZ_AUTH_EXTENSION=
 fi
-VPX_USE_YASM=
-VPX_ASFLAGS=
 LIBJPEG_TURBO_AS=
 LIBJPEG_TURBO_ASFLAGS=
 MOZ_PREF_EXTENSIONS=1
 MOZ_SPELLCHECK=1
 MOZ_TOOLKIT_SEARCH=1
 MOZ_UNIVERSALCHARDET=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
@@ -2211,123 +2209,16 @@ if test -n "$MOZ_APPLEMEDIA"; then
   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
   LDFLAGS="$LDFLAGS -framework AudioToolbox"
   dnl Verify CoreMedia is available.
   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
 fi
 fi # COMPILE_ENVIRONMENT
 
-dnl system libvpx Support
-dnl ========================================================
-MOZ_ARG_WITH_BOOL(system-libvpx,
-[  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
-    MOZ_SYSTEM_LIBVPX=1)
-
-MOZ_LIBVPX_CFLAGS=
-MOZ_LIBVPX_LIBS=
-
-_SAVE_CFLAGS=$CFLAGS
-_SAVE_LIBS=$LIBS
-if test -n "$MOZ_SYSTEM_LIBVPX"; then
-    dnl ============================
-    dnl === libvpx Version check ===
-    dnl ============================
-    dnl Check to see if we have a system libvpx package.
-    PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.5.0)
-
-    CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
-    LIBS="$LIBS $MOZ_LIBVPX_LIBS"
-
-    MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
-     [AC_MSG_ERROR([Couldn't find vpx/vpx_decoder.h which is required for build with system libvpx. Use --without-system-libvpx to build with in-tree libvpx.])])
-
-    AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
-     [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
-fi
-CFLAGS=$_SAVE_CFLAGS
-LIBS=$_SAVE_LIBS
-
-AC_SUBST(MOZ_SYSTEM_LIBVPX)
-AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
-AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
-
-if test -z "$MOZ_SYSTEM_LIBVPX"; then
-
-    dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
-    dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
-    dnl We currently require gcc on all arm platforms.
-
-    dnl See if we have assembly on this platform.
-    case "$OS_ARCH:$CPU_ARCH" in
-    Darwin:x86)
-      VPX_USE_YASM=1
-    ;;
-    Darwin:x86_64)
-      VPX_USE_YASM=1
-    ;;
-    WINNT:x86_64)
-      VPX_USE_YASM=1
-    ;;
-    WINNT:x86)
-      dnl Check for yasm 1.1 or greater.
-      if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
-        AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but it appears not to be installed.  Install it (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
-      elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
-        AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
-      else
-        VPX_USE_YASM=1
-        dnl The encoder needs obj_int_extract to get asm offsets.
-      fi # COMPILE_ENVIRONMENT and others
-    ;;
-    *:arm*)
-      if test -n "$GNU_AS" ; then
-        dnl These flags are a lie; they're just used to enable the requisite
-        dnl opcodes; actual arch detection is done at runtime.
-        VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
-        dnl Building with -mfpu=neon requires either the "softfp" or the
-        dnl "hardfp" ABI. Depending on the compiler's default target, and the
-        dnl CFLAGS, the default ABI might be neither, in which case it is the
-        dnl "softfloat" ABI.
-        dnl The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
-        dnl we can safely mix code built with both ABIs. So, if we detect
-        dnl that compiling uses the "softfloat" ABI, force the use of the
-        dnl "softfp" ABI instead.
-        dnl Confusingly, the __SOFTFP__ preprocessor variable indicates the
-        dnl "softfloat" ABI, not the "softfp" ABI.
-        dnl Note: VPX_ASFLAGS is also used in CFLAGS.
-        AC_TRY_COMPILE([],
-          [#ifndef __SOFTFP__
-           #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
-           #endif],
-           VPX_ASFLAGS="$VPX_ASFLAGS -mfloat-abi=softfp"
-           )
-      fi
-    ;;
-    *:x86)
-      if $CC -E -dM -</dev/null | grep -q __ELF__; then
-        VPX_USE_YASM=1
-      fi
-    ;;
-    *:x86_64)
-      if $CC -E -dM -</dev/null | grep -q __ELF__; then
-        VPX_USE_YASM=1
-      fi
-    ;;
-    esac
-
-    if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_USE_YASM" -a -z "$YASM"; then
-      AC_MSG_ERROR([yasm is a required build tool for this architecture when webm is enabled. You may either install yasm or --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
-    fi # COMPILE_ENVIRONMENT and others
-
-    if test -n "$VPX_USE_YASM" && test "$OS_ARCH:$CPU_ARCH" != "WINNT:x86_64"; then
-      VPX_ASFLAGS="-DPIC"
-    fi
-fi
-
 dnl ========================================================
 dnl = Handle dependent MEDIA defines
 dnl ========================================================
 
 MOZ_WEBM_ENCODER=1
 AC_DEFINE(MOZ_WEBM_ENCODER)
 AC_SUBST(MOZ_WEBM_ENCODER)
 
@@ -4130,18 +4021,16 @@ 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(VPX_USE_YASM)
-AC_SUBST_LIST(VPX_ASFLAGS)
 AC_SUBST(LIBJPEG_TURBO_USE_YASM)
 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
 AC_SUBST(MOZ_LIBAV_FFT)
 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
 AC_SUBST(MOZ_DEVTOOLS)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -1273,8 +1273,84 @@ set_config('MOZ_LAYOUT_DEBUGGER', depend
 # Shader Compiler for Windows (and MinGW Cross Compile)
 # ==============================================================
 
 with only_when(compile_environment):
     fxc = check_prog('FXC', ('fxc.exe', 'fxc2.exe'), when=depends(target)
                      (lambda t: t.kernel == 'WINNT'))
     wine = check_prog('WINE', ['wine'], when=depends(target, host)
                       (lambda t, h: t.kernel == 'WINNT' and h.kernel == 'Linux'))
+
+
+# VPX
+# ===
+
+with only_when(compile_environment):
+    option('--with-system-libvpx',
+           help='Use system libvpx (located with pkgconfig)')
+
+    with only_when('--with-system-libvpx'):
+        vpx = pkg_check_modules('MOZ_LIBVPX', 'vpx >= 1.5.0')
+
+        check_header('vpx/vpx_decoder.h', flags=vpx.cflags, onerror=lambda: die(
+            "Couldn't find vpx/vpx_decoder.h, which is required to build "
+            "with system libvpx. Use --without-system-libvpx to build "
+            "with in-tree libvpx."))
+
+        check_symbol('vpx_codec_dec_init_ver', flags=vpx.libs, onerror=lambda: die(
+            "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
+            "not found"
+        ))
+
+        set_config('MOZ_SYSTEM_LIBVPX', True)
+
+
+    @depends('--with-system-libvpx', target, yasm_version, gnu_as)
+    def in_tree_vpx(system_libvpx, target, yasm_version, gnu_as):
+        if system_libvpx:
+            return
+
+        use_yasm = (target.cpu in ('x86', 'x86_64')) or None
+        arm_asm = (target.cpu == 'arm' and gnu_as) or None
+
+        if use_yasm:
+            if not yasm_version:
+                die('Yasm is required to build on this architecture.')
+            if target.kernel == 'WINNT' and yasm_version < '1.1':
+                die('Yasm 1.1 or greater is required to build libvpx for Windows.')
+
+        return namespace(arm_asm=arm_asm, use_yasm=use_yasm)
+
+
+    # Building with -mfpu=neon requires either the "softfp" or the
+    # "hardfp" ABI. Depending on the compiler's default target, and the
+    # CFLAGS, the default ABI might be neither, in which case it is the
+    # "softfloat" ABI.
+    # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
+    # we can safely mix code built with both ABIs. So, if we detect
+    # that compiling uses the "softfloat" ABI, force the use of the
+    # "softfp" ABI instead.
+    # Confusingly, the __SOFTFP__ preprocessor variable indicates the
+    # "softfloat" ABI, not the "softfp" ABI.
+    # Note: VPX_ASFLAGS is also used in CFLAGS.
+    softfp = cxx_compiler.try_compile(body='''
+        #ifndef __SOFTFP__
+        #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
+        #endif''', when=in_tree_vpx.arm_asm)
+
+
+    @depends(in_tree_vpx, softfp, target)
+    def vpx_as_flags(vpx, softfp, target):
+        flags = []
+        if vpx and vpx.arm_asm:
+            # These flags are a lie; they're just used to enable the requisite
+            # opcodes; actual arch detection is done at runtime.
+            flags = ['-march=armv7-a', '-mfpu=neon']
+            if softfp:
+                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)