Bug 1165654 - Cleanup how libjpeg-turbo assembly build variables are set. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 17 May 2015 09:37:06 +0900
changeset 244693 45ecf64767d6a7af75a94f78cc07f55781272735
parent 244692 39f481e86829ce28a557a0d0a1985f3abcd31030
child 244694 eda5deaf71b90ea9173eb7893b94c72415039d98
push id13044
push usercbook@mozilla.com
push dateWed, 20 May 2015 14:10:38 +0000
treeherderfx-team@32382625e449 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1165654
milestone41.0a1
Bug 1165654 - Cleanup how libjpeg-turbo assembly build variables are set. r=mshal Most notably, always set LIBJPEG_TURBO_AS if LIBJPEG_TURBO_ASFLAGS is set.
configure.in
media/libjpeg/moz.build
--- a/configure.in
+++ b/configure.in
@@ -3852,21 +3852,16 @@ MOZ_WEBSPEECH=1
 VPX_AS=
 VPX_ASFLAGS=
 VPX_AS_CONVERSION=
 VPX_ASM_SUFFIX=
 VPX_X86_ASM=
 VPX_ARM_ASM=
 LIBJPEG_TURBO_AS=
 LIBJPEG_TURBO_ASFLAGS=
-LIBJPEG_TURBO_X86_ASM=
-LIBJPEG_TURBO_X64_ASM=
-LIBJPEG_TURBO_ARM_ASM=
-LIBJPEG_TURBO_ARM64_ASM=
-LIBJPEG_TURBO_MIPS_ASM=
 MOZ_PERMISSIONS=1
 MOZ_PLACES=1
 MOZ_SOCIAL=1
 MOZ_PREF_EXTENSIONS=1
 MOZ_PROFILELOCKING=1
 MOZ_REFLOW_PERF=
 MOZ_SAFE_BROWSING=
 MOZ_HELP_VIEWER=
@@ -6096,65 +6091,57 @@ if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_
 fi
 
 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
 dnl files.
 
 if test -n "$MOZ_LIBJPEG_TURBO"; then
 
   dnl Do we support libjpeg-turbo on this platform?
-  case "$OS_ARCH:$OS_TEST" in
-  Darwin:i?86)
+  case "$OS_ARCH:$CPU_ARCH" in
+  Darwin:x86)
     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
-    LIBJPEG_TURBO_X86_ASM=1
   ;;
   Darwin:x86_64)
     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
-    LIBJPEG_TURBO_X64_ASM=1
   ;;
-  WINNT:x86|WINNT:i?86)
+  WINNT:x86)
     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
-    LIBJPEG_TURBO_X86_ASM=1
   ;;
   WINNT:x86_64)
     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
-    LIBJPEG_TURBO_X64_ASM=1
   ;;
-  *:arm*)
+  *:arm)
     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
-    LIBJPEG_TURBO_ARM_ASM=1
   ;;
-  *:aarch64*)
+  *:aarch64)
     LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
-    LIBJPEG_TURBO_ARM64_ASM=1
   ;;
-  *:mips*)
+  *:mips)
     LIBJPEG_TURBO_ASFLAGS="-mdspr2"
-    LIBJPEG_TURBO_MIPS_ASM=1
   ;;
-  *:x86|*:i?86)
+  *:x86)
     if $CC -E -dM -</dev/null | grep -q __ELF__; then
       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
-      LIBJPEG_TURBO_X86_ASM=1
     fi
   ;;
   *:x86_64)
     if $CC -E -dM -</dev/null | grep -q __ELF__; then
       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
-      LIBJPEG_TURBO_X64_ASM=1
     fi
   ;;
   esac
-
-fi
-
+fi
+
+if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
+  case "$CPU_ARCH" in
 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
 dnl it doesn't exist or we have too old of a version.
-if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
+  x86_64|x86)
     LIBJPEG_TURBO_AS=$YASM
 
     if test -z "$LIBJPEG_TURBO_AS" ; then
         AC_MSG_ERROR([Yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have Yasm installed.  Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
     fi
 
     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
     dnl on Linux and 1.1 or newer everywhere else.
@@ -6162,31 +6149,22 @@ if test -n "$LIBJPEG_TURBO_X86_ASM" -o -
         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -eq "0" -a "$_YASM_RELEASE" -lt "1" \) ; then
             AC_MSG_ERROR([Yasm 1.0.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
         fi
     else
         if test "$_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 with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
         fi
     fi
-fi
-
-dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
-dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
-if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
-    echo "Using $AS as the assembler for ARM code."
+  ;;
+dnl On other platforms, use the C compiler as the assembler.
+  *)
     LIBJPEG_TURBO_AS=$AS
-fi
-
-if test -n "$LIBJPEG_TURBO_X86_ASM"; then
-    AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
-elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
-    AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
-elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
-    AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
+  ;;
+  esac
 elif test -n "$MOZ_LIBJPEG_TURBO"; then
     dnl Warn if we're not building the optimized routines, even though the user
     dnl didn't specify --disable-libjpeg-turbo.
     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
 fi
 
 dnl ========================================================
 dnl = Enable compilation of specific extension modules
@@ -8866,21 +8844,16 @@ AC_SUBST(VPX_AS_CONVERSION)
 AC_SUBST(VPX_ASM_SUFFIX)
 AC_SUBST(VPX_X86_ASM)
 AC_SUBST(VPX_ARM_ASM)
 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
 AC_SUBST(MOZ_CODE_COVERAGE)
 AC_SUBST(LIBJPEG_TURBO_AS)
 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
-AC_SUBST(LIBJPEG_TURBO_X86_ASM)
-AC_SUBST(LIBJPEG_TURBO_X64_ASM)
-AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
-AC_SUBST(LIBJPEG_TURBO_ARM64_ASM)
-AC_SUBST(LIBJPEG_TURBO_MIPS_ASM)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
 AC_SUBST(SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE)
 
 AC_SUBST(MOZ_ENABLE_SZIP)
 AC_SUBST(MOZ_SZIP_FLAGS)
 
--- a/media/libjpeg/moz.build
+++ b/media/libjpeg/moz.build
@@ -8,72 +8,16 @@ EXPORTS += [
     'jconfig.h',
     'jerror.h',
     'jinclude.h',
     'jmorecfg.h',
     'jpegint.h',
     'jpeglib.h',
 ]
 
-if CONFIG['LIBJPEG_TURBO_X64_ASM']:
-    SOURCES += [
-        'simd/jccolor-sse2-64.asm',
-        'simd/jcgray-sse2-64.asm',
-        'simd/jcsample-sse2-64.asm',
-        'simd/jdcolor-sse2-64.asm',
-        'simd/jdmerge-sse2-64.asm',
-        'simd/jdsample-sse2-64.asm',
-        'simd/jfdctflt-sse-64.asm',
-        'simd/jfdctfst-sse2-64.asm',
-        'simd/jfdctint-sse2-64.asm',
-        'simd/jidctflt-sse2-64.asm',
-        'simd/jidctfst-sse2-64.asm',
-        'simd/jidctint-sse2-64.asm',
-        'simd/jidctred-sse2-64.asm',
-        'simd/jquantf-sse2-64.asm',
-        'simd/jquanti-sse2-64.asm',
-]
-
-if CONFIG['LIBJPEG_TURBO_X86_ASM']:
-    SOURCES += [
-        'simd/jccolor-mmx.asm',
-        'simd/jccolor-sse2.asm',
-        'simd/jcgray-mmx.asm',
-        'simd/jcgray-sse2.asm',
-        'simd/jcsample-mmx.asm',
-        'simd/jcsample-sse2.asm',
-        'simd/jdcolor-mmx.asm',
-        'simd/jdcolor-sse2.asm',
-        'simd/jdmerge-mmx.asm',
-        'simd/jdmerge-sse2.asm',
-        'simd/jdsample-mmx.asm',
-        'simd/jdsample-sse2.asm',
-        'simd/jfdctflt-3dn.asm',
-        'simd/jfdctflt-sse.asm',
-        'simd/jfdctfst-mmx.asm',
-        'simd/jfdctfst-sse2.asm',
-        'simd/jfdctint-mmx.asm',
-        'simd/jfdctint-sse2.asm',
-        'simd/jidctflt-3dn.asm',
-        'simd/jidctflt-sse.asm',
-        'simd/jidctflt-sse2.asm',
-        'simd/jidctfst-mmx.asm',
-        'simd/jidctfst-sse2.asm',
-        'simd/jidctint-mmx.asm',
-        'simd/jidctint-sse2.asm',
-        'simd/jidctred-mmx.asm',
-        'simd/jidctred-sse2.asm',
-        'simd/jquant-3dn.asm',
-        'simd/jquant-mmx.asm',
-        'simd/jquant-sse.asm',
-        'simd/jquantf-sse2.asm',
-        'simd/jquanti-sse2.asm',
-        'simd/jsimdcpu.asm',
-]
-
 SOURCES += [
     'jcomapi.c',
     'jdapimin.c',
     'jdapistd.c',
     'jdatadst.c',
     'jdatasrc.c',
     'jdcoefct.c',
     'jdcolor.c',
@@ -117,39 +61,88 @@ SOURCES += [
     'jcmaster.c',
     'jcparam.c',
     'jcphuff.c',
     'jcprepct.c',
     'jcsample.c',
     'jctrans.c',
 ]
 
-if CONFIG['LIBJPEG_TURBO_ARM_ASM']:
-    SOURCES += [
-        'simd/jsimd_arm.c',
-        'simd/jsimd_arm_neon.S',
-    ]
-elif CONFIG['LIBJPEG_TURBO_ARM64_ASM']:
-    SOURCES += [
-        'simd/jsimd_arm64.c',
-        'simd/jsimd_arm64_neon.S',
-    ]
-elif CONFIG['LIBJPEG_TURBO_MIPS_ASM']:
-    SOURCES += [
-        'simd/jsimd_mips.c',
-        'simd/jsimd_mips_dspr2.S',
-    ]
-elif CONFIG['LIBJPEG_TURBO_X64_ASM']:
-    SOURCES += [
-        'simd/jsimd_x86_64.c',
-    ]
-elif CONFIG['LIBJPEG_TURBO_X86_ASM']:
-    SOURCES += [
-        'simd/jsimd_i386.c',
-    ]
+if CONFIG['LIBJPEG_TURBO_AS']:
+    if CONFIG['CPU_ARCH'] == 'arm':
+        SOURCES += [
+            'simd/jsimd_arm.c',
+            'simd/jsimd_arm_neon.S',
+        ]
+    elif CONFIG['CPU_ARCH'] == 'aarch64':
+        SOURCES += [
+            'simd/jsimd_arm64.c',
+            'simd/jsimd_arm64_neon.S',
+        ]
+    elif CONFIG['CPU_ARCH'] == 'mips':
+        SOURCES += [
+            'simd/jsimd_mips.c',
+            'simd/jsimd_mips_dspr2.S',
+        ]
+    elif CONFIG['CPU_ARCH'] == 'x86_64':
+        SOURCES += [
+            'simd/jccolor-sse2-64.asm',
+            'simd/jcgray-sse2-64.asm',
+            'simd/jcsample-sse2-64.asm',
+            'simd/jdcolor-sse2-64.asm',
+            'simd/jdmerge-sse2-64.asm',
+            'simd/jdsample-sse2-64.asm',
+            'simd/jfdctflt-sse-64.asm',
+            'simd/jfdctfst-sse2-64.asm',
+            'simd/jfdctint-sse2-64.asm',
+            'simd/jidctflt-sse2-64.asm',
+            'simd/jidctfst-sse2-64.asm',
+            'simd/jidctint-sse2-64.asm',
+            'simd/jidctred-sse2-64.asm',
+            'simd/jquantf-sse2-64.asm',
+            'simd/jquanti-sse2-64.asm',
+            'simd/jsimd_x86_64.c',
+        ]
+    elif CONFIG['CPU_ARCH'] == 'x86':
+        SOURCES += [
+            'simd/jccolor-mmx.asm',
+            'simd/jccolor-sse2.asm',
+            'simd/jcgray-mmx.asm',
+            'simd/jcgray-sse2.asm',
+            'simd/jcsample-mmx.asm',
+            'simd/jcsample-sse2.asm',
+            'simd/jdcolor-mmx.asm',
+            'simd/jdcolor-sse2.asm',
+            'simd/jdmerge-mmx.asm',
+            'simd/jdmerge-sse2.asm',
+            'simd/jdsample-mmx.asm',
+            'simd/jdsample-sse2.asm',
+            'simd/jfdctflt-3dn.asm',
+            'simd/jfdctflt-sse.asm',
+            'simd/jfdctfst-mmx.asm',
+            'simd/jfdctfst-sse2.asm',
+            'simd/jfdctint-mmx.asm',
+            'simd/jfdctint-sse2.asm',
+            'simd/jidctflt-3dn.asm',
+            'simd/jidctflt-sse.asm',
+            'simd/jidctflt-sse2.asm',
+            'simd/jidctfst-mmx.asm',
+            'simd/jidctfst-sse2.asm',
+            'simd/jidctint-mmx.asm',
+            'simd/jidctint-sse2.asm',
+            'simd/jidctred-mmx.asm',
+            'simd/jidctred-sse2.asm',
+            'simd/jquant-3dn.asm',
+            'simd/jquant-mmx.asm',
+            'simd/jquant-sse.asm',
+            'simd/jquantf-sse2.asm',
+            'simd/jquanti-sse2.asm',
+            'simd/jsimd_i386.c',
+            'simd/jsimdcpu.asm',
+        ]
 else: # No SIMD support?
     SOURCES += [
         'jsimd_none.c',
     ]
 
 ASFLAGS += CONFIG['LIBJPEG_TURBO_ASFLAGS']
 ASFLAGS += ['-I%s/media/libjpeg/simd/' % TOPSRCDIR]