Bug 979118 - Add global MMX_FLAGS, SSE_FLAGS and SSE2_FLAGS variables; r=glandium
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Mar 2014 21:55:00 -0400
changeset 193956 812c528dce3a366107e7b6501e80fce2dbff7544
parent 193955 b1500506a6c49ff7afc208e136bdc48c9a6902b4
child 193957 b6ea0ef386f9779093784b47560539e44e86ee35
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs979118
milestone31.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 979118 - Add global MMX_FLAGS, SSE_FLAGS and SSE2_FLAGS variables; r=glandium
build/autoconf/config.status.m4
configure.in
content/base/src/moz.build
gfx/2d/moz.build
gfx/angle/src/libGLESv2/moz.build
gfx/cairo/libpixman/src/moz.build
gfx/qcms/moz.build
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
gfx/thebes/moz.build
gfx/ycbcr/moz.build
intl/uconv/src/moz.build
media/libsoundtouch/src/moz.build
media/libspeex_resampler/src/moz.build
media/libvpx/moz.build
xpcom/string/src/moz.build
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -6,34 +6,49 @@ dnl For use in AC_SUBST replacement
 define([MOZ_DIVERSION_SUBST], 11)
 
 dnl Replace AC_SUBST to store values in a format suitable for python.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_SUBST(),bar)
 define([AC_SUBST],
 [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
+[ifdef([AC_SUBST_LIST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])],
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
     (''' $1 ''', r''' [$]$1 ''')
 AC_DIVERT_POP()dnl
-])])])
+])])])])
 
 dnl Like AC_SUBST, but makes the value available as a set in python,
 dnl with values got from the value of the environment variable, split on
 dnl whitespaces.
 define([AC_SUBST_SET],
 [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
+[ifdef([AC_SUBST_LIST$1], [m4_fatal([Cannot use AC_SUBST_LIST and AC_SUBST_SET on the same variable ($1)])],
 [ifdef([AC_SUBST_SET_$1], ,
 [define([AC_SUBST_SET_$1], )dnl
 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
     (''' $1 ''', set(r''' [$]$1 '''.split()))
 AC_DIVERT_POP()dnl
-])])])
+])])])])
+
+dnl Like AC_SUBST, but makes the value available as a list in python,
+dnl with values got from the value of the environment variable, split on
+dnl whitespaces.
+define([AC_SUBST_LIST],
+[ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])],
+[ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST_SET and AC_SUBST_LIST on the same variable ($1)])],
+[ifdef([AC_SUBST_LIST_$1], ,
+[define([AC_SUBST_LIST_$1], )dnl
+AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
+    (''' $1 ''', list(r''' [$]$1 '''.split()))
+AC_DIVERT_POP()dnl
+])])])])
 
 dnl Wrap AC_DEFINE to store values in a format suitable for python.
 dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h,
 dnl which is #included during some compile checks.
 dnl The necessary comma after the tuple can't be put here because it
 dnl can mess around with things like:
 dnl    AC_SOMETHING(foo,AC_DEFINE(),bar)
 define([_MOZ_AC_DEFINE], defn([AC_DEFINE]))
--- a/configure.in
+++ b/configure.in
@@ -1907,16 +1907,19 @@ case "$target" in
         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
         # The ExceptionHandling framework is needed for Objective-C exception
         # logging code in nsObjCExceptions.h. Currently we only use that in debug
         # builds.
         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
     fi
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
 
+    MMX_FLAGS="-mmmx"
+    SSE_FLAGS="-msse"
+    SSE2_FLAGS="-msse2"
 
     if test "x$lto_is_enabled" = "xyes"; then
         echo "Skipping -dead_strip because lto is enabled."
     dnl DTrace and -dead_strip don't interact well. See bug 403132.
     dnl ===================================================================
     elif test "x$enable_dtrace" = "xyes"; then
         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
     else
@@ -1999,16 +2002,20 @@ ia64*-hpux*)
         MOZ_B2G_FM=1
         MOZ_SYNTH_PICO=1
     else
         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
         MOZ_LINKER=1
     fi
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
 
+    MMX_FLAGS="-mmmx"
+    SSE_FLAGS="-msse"
+    SSE2_FLAGS="-msse2"
+
     MOZ_GFX_OPTIMIZE_MOBILE=1
     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
     ;;
 
 *-*linux*)
     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
     # Similarly for GNU_CXX and INTEL_CXX.
     if test "$INTEL_CC" -o "$INTEL_CXX"; then
@@ -2020,16 +2027,20 @@ ia64*-hpux*)
         4.5.*)
             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
         esac
         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
     fi
 
+    MMX_FLAGS="-mmmx"
+    SSE_FLAGS="-msse"
+    SSE2_FLAGS="-msse2"
+
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
 
     MOZ_MEMORY=1
 
     case "${target_cpu}" in
     alpha*)
         CFLAGS="$CFLAGS -mieee"
         CXXFLAGS="$CXXFLAGS -mieee"
@@ -2065,16 +2076,20 @@ ia64*-hpux*)
         # Use temp file for windres (bug 213281)
         RCFLAGS='-O coff --use-temp-file'
         # mingw doesn't require kernel32, user32, and advapi32 explicitly
         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
         MOZ_FIX_LINK_PATHS=
         DLL_PREFIX=
         IMPORT_LIB_SUFFIX=dll.a
 
+        MMX_FLAGS="-mmmx"
+        SSE_FLAGS="-msse"
+        SSE2_FLAGS="-msse2"
+
         # We use mix of both POSIX and Win32 printf format across the tree, so format
         # warnings are useless on mingw.
         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
     else
         TARGET_COMPILER_ABI=msvc
         HOST_CC='$(CC)'
         HOST_CXX='$(CXX)'
@@ -2266,46 +2281,55 @@ ia64*-hpux*)
     # This will fail on a.out systems prior to 1.5.1_ALPHA.
     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
     if test "$LIBRUNPATH"; then
         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
     fi
     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@'
     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@'
+    MMX_FLAGS="-mmmx"
+    SSE_FLAGS="-msse"
+    SSE2_FLAGS="-msse2"
     ;;
 
 *-openbsd*)
     if test "$SO_VERSION"; then
         DLL_SUFFIX=".so.$SO_VERSION"
     else
         DLL_SUFFIX=".so.1.0"
     fi
     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
     DSO_CFLAGS=''
     DSO_PIC_CFLAGS='-fPIC'
     DSO_LDOPTS='-shared -fPIC'
     if test "$LIBRUNPATH"; then
         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
     fi
+    MMX_FLAGS="-mmmx"
+    SSE_FLAGS="-msse"
+    SSE2_FLAGS="-msse2"
     ;;
 
 *-solaris*)
     AC_DEFINE(SOLARIS)
     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
     MOZ_FIX_LINK_PATHS=
     # $ORIGIN/.. is for shared libraries under components/ to locate shared
     # libraries one level up (e.g. libnspr4.so)
     if test "$SOLARIS_SUNPRO_CC"; then
        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
        LIBS="-lCrun -lCstd -lc $LIBS"
        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
        LDFLAGS="-xildoff $LDFLAGS"
+       MMX_FLAGS="-xarch=mmx -xO4"
+       SSE_FLAGS="-xarch=sse"
+       SSE2_FLAGS="-xarch=ssei2 -xO4"
        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
            _SAVE_LDFLAGS=$LDFLAGS
            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
            AC_TRY_LINK([#include <stdio.h>],
                        [printf("Hello World\n");],
                        ,
                        [LDFLAGS=$_SAVE_LDFLAGS])
        fi
@@ -2359,16 +2383,19 @@ ia64*-hpux*)
        ASFLAGS="$ASFLAGS -fPIC"
        DSO_LDOPTS='-shared'
        WARNINGS_AS_ERRORS='-Werror'
        _WARNINGS_CFLAGS=''
        _WARNINGS_CXXFLAGS=''
        if test "$OS_RELEASE" = "5.3"; then
            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
        fi
+       MMX_FLAGS="-mmmx"
+       SSE_FLAGS="-msse"
+       SSE2_FLAGS="-msse2"
     fi
     if test "$OS_RELEASE" = "5.5.1"; then
         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
     fi
     ;;
 
 *-sunos*)
     DSO_LDOPTS='-Bdynamic'
@@ -2380,16 +2407,20 @@ ia64*-hpux*)
     sunos4.1*)
         DLL_SUFFIX='.so.1.0'
         ;;
     esac
     ;;
 
 esac
 
+AC_SUBST_LIST(MMX_FLAGS)
+AC_SUBST_LIST(SSE_FLAGS)
+AC_SUBST_LIST(SSE2_FLAGS)
+
 case "$target" in
 *-*linux*)
     # Includes linux-android
     AC_DEFINE(XP_LINUX)
     ;;
 esac
 
 AC_SUBST(MOZ_LINKER)
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -46,22 +46,17 @@ if CONFIG['MOZ_WEBRTC']:
     LOCAL_INCLUDES += [
         '/netwerk/sctp/datachannel',
     ]
 
 # Are we targeting x86-32 or x86-64?  If so, we want to include SSE2 code for
 # nsTextFragment.cpp
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += ['nsTextFragmentSSE2.cpp']
-    if CONFIG['GNU_CC']:
-        # gcc requires -msse2 for this file since it uses SSE2 intrinsics.  (See bug
-        # 585538 comment 12.)
-        SOURCES['nsTextFragmentSSE2.cpp'].flags += ['-msse2']
-    if CONFIG['SOLARIS_SUNPRO_CXX']:
-        SOURCES['nsTextFragmentSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
+    SOURCES['nsTextFragmentSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 EXPORTS.mozilla.dom += [
     'Attr.h',
     'Comment.h',
     'DocumentFragment.h',
     'DocumentType.h',
     'DOMImplementation.h',
     'DOMParser.h',
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -85,24 +85,19 @@ if CONFIG['INTEL_ARCHITECTURE']:
         SOURCES += [
             'BlurSSE2.cpp',
             'FilterProcessingSSE2.cpp',
             'ImageScalingSSE2.cpp',
         ]
         DEFINES['USE_SSE2'] = True
         # The file uses SSE2 intrinsics, so it needs special compile flags on some
         # compilers.
-        if CONFIG['GNU_CC']:
-            SOURCES['BlurSSE2.cpp'].flags += ['-msse2']
-            SOURCES['FilterProcessingSSE2.cpp'].flags += ['-msse2']
-            SOURCES['ImageScalingSSE2.cpp'].flags += ['-msse2']
-        if CONFIG['SOLARIS_SUNPRO_CXX']:
-            SOURCES['BlurSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
-            SOURCES['FilterProcessingSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
-            SOURCES['ImageScalingSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
+        SOURCES['BlurSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+        SOURCES['FilterProcessingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+        SOURCES['ImageScalingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 UNIFIED_SOURCES += [
     'Blur.cpp',
     'DataSourceSurface.cpp',
     'DataSurfaceHelpers.cpp',
     'DrawEventRecorder.cpp',
     'DrawTargetCairo.cpp',
     'DrawTargetDual.cpp',
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -167,18 +167,17 @@ SOURCES += ['renderer/' + src for src in
     'TextureStorage9.cpp',
     'VertexBuffer.cpp',
     'VertexBuffer11.cpp',
     'VertexBuffer9.cpp',
     'VertexDataManager.cpp',
     'VertexDeclarationCache.cpp',
 ]]
 
-if CONFIG['GNU_CC']:
-    SOURCES['renderer/ImageSSE2.cpp'].flags += ['-msse2']
+SOURCES['renderer/ImageSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 # On Windows, we don't automatically get "lib" prepended, but we need it.
 LIBRARY_NAME = 'libGLESv2'
 
 FORCE_SHARED_LIB = True
 
 LOCAL_INCLUDES += [
     '..',
--- a/gfx/cairo/libpixman/src/moz.build
+++ b/gfx/cairo/libpixman/src/moz.build
@@ -105,34 +105,31 @@ elif 'arm' in CONFIG['OS_TEST']:
         if CONFIG['HAVE_ARM_SIMD']:
             use_arm_simd_gcc = True
         if CONFIG['HAVE_ARM_NEON']:
             use_arm_neon_gcc = True
 
 if use_mmx:
     DEFINES['USE_MMX'] = True
     SOURCES += ['pixman-mmx.c']
+    SOURCES['pixman-mmx.c'].flags += CONFIG['MMX_FLAGS']
     if CONFIG['GNU_CC']:
         SOURCES['pixman-mmx.c'].flags += [
-            '-mmmx',
             '-Winline',
             '--param inline-unit-growth=10000',
             '--param large-function-growth=10000',
         ]
 
 if use_sse2:
     DEFINES['USE_SSE'] = True
     DEFINES['USE_SSE2'] = True
     SOURCES += ['pixman-sse2.c']
+    SOURCES['pixman-sse2.c'].flags += CONFIG['SSE_FLAGS'] + CONFIG['SSE2_FLAGS']
     if CONFIG['GNU_CC']:
-        SOURCES['pixman-sse2.c'].flags += [
-            '-msse',
-            '-msse2',
-            '-Winline',
-        ]
+        SOURCES['pixman-sse2.c'].flags += ['-Winline']
 
 if use_vmx:
     DEFINES['USE_VMX'] = True
     SOURCES += ['pixman-vmx.c']
     SOURCES['pixman-vmx.c'].flags += ['-maltivec']
 
 if use_arm_simd_gcc:
     DEFINES['USE_ARM_SIMD'] = True
--- a/gfx/qcms/moz.build
+++ b/gfx/qcms/moz.build
@@ -35,31 +35,29 @@ if '86' in CONFIG['OS_TEST']:
     else:
         use_sse1 = True
 elif 'ppc' in CONFIG['CPU_ARCH']:
     if CONFIG['GNU_CC']:
         use_altivec = True
 
 if use_sse1:
     SOURCES += ['transform-sse1.c']
-    if CONFIG['GNU_CC']:
-        SOURCES['transform-sse1.c'].flags += ['-msse']
-    elif CONFIG['SOLARIS_SUNPRO_CC']:
+    SOURCES['transform-sse1.c'].flags += CONFIG['SSE_FLAGS']
+    if CONFIG['SOLARIS_SUNPRO_CC']:
         if '64' in CONFIG['OS_TEST']:
             # Sun Studio doesn't work correctly for x86 intristics
             # with -m64 and without optimization.
             SOURCES['transform-sse1.c'].flags += ['-xO4']
         else:
             SOURCES['transform-sse1.c'].flags += ['-xarch=sse']
 
 if use_sse2:
     SOURCES += ['transform-sse2.c']
-    if CONFIG['GNU_CC']:
-        SOURCES['transform-sse2.c'].flags += ['-msse2']
-    elif CONFIG['SOLARIS_SUNPRO_CC']:
+    SOURCES['transform-sse2.c'].flags += CONFIG['SSE2_FLAGS']
+    if CONFIG['SOLARIS_SUNPRO_CC']:
         if '64' in CONFIG['OS_TEST']:
             # Sun Studio doesn't work correctly for x86 intristics
             # with -m64 and without optimization.
             SOURCES['transform-sse2.c'].flags += ['-xO4']
         else:
             SOURCES['transform-sse2.c'].flags += ['-xarch=sse2']
 
 if use_altivec:
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -75,24 +75,24 @@ if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'and
    CONFIG['MOZ_WIDGET_GTK']:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['SKIA_DLL'] = 1
     DEFINES['GR_DLL'] = 1
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
-    SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-msse2']
+    SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
-    SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-msse2']
+    SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
     DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
     DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
 
 DEFINES['SKIA_IMPLEMENTATION'] = 1
 DEFINES['GR_IMPLEMENTATION'] = 1
 """
 
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -876,22 +876,22 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('and
 if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or    (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or    (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or    CONFIG['MOZ_WIDGET_QT'] or    CONFIG['MOZ_WIDGET_GTK']:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['SKIA_DLL'] = 1
     DEFINES['GR_DLL'] = 1
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
-    SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-msse2']
+    SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
-    SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-msse2']
-    SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-msse2']
+    SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
+    SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
     DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
     DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
 
 DEFINES['SKIA_IMPLEMENTATION'] = 1
 DEFINES['GR_IMPLEMENTATION'] = 1
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -197,20 +197,17 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
             'gfxDWriteTextAnalysis.cpp',
         ]
 
 # Are we targeting x86 or x64?  If so, build gfxAlphaRecoverySSE2.cpp.
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += ['gfxAlphaRecoverySSE2.cpp']
     # The file uses SSE2 intrinsics, so it needs special compile flags on some
     # compilers.
-    if CONFIG['GNU_CC']:
-        SOURCES['gfxAlphaRecoverySSE2.cpp'].flags += ['-msse2']
-    if CONFIG['SOLARIS_SUNPRO_CXX']:
-        SOURCES['gfxAlphaRecoverySSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
+    SOURCES['gfxAlphaRecoverySSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 SOURCES += [
     # Includes mac system header conflicting with point/size,
     # and includes glxXlibSurface.h which drags in Xrender.h
     'gfxASurface.cpp',
     # on X11, gfxDrawable.cpp includes X headers for an old workaround which
     # we could consider removing soon (affects Ubuntus older than 10.04 LTS)
     # which currently prevent it from joining UNIFIED_SOURCES.
--- a/gfx/ycbcr/moz.build
+++ b/gfx/ycbcr/moz.build
@@ -19,33 +19,27 @@ UNIFIED_SOURCES += [
     'yuv_row_c.cpp',
     'yuv_row_table.cpp',
 ]
 
 if CONFIG['INTEL_ARCHITECTURE']:
     # These files use MMX and SSE2 intrinsics, so they need special compile flags
     # on some compilers.
     SOURCES += ['yuv_convert_sse2.cpp']
-    if CONFIG['GNU_CC']:
-        SOURCES['yuv_convert_sse2.cpp'].flags += ['-msse2']
-    if CONFIG['SOLARIS_SUNPRO_CXX']:
-        SOURCES['yuv_convert_sse2.cpp'].flags += ['-xarch=sse2', '-xO4']
+    SOURCES['yuv_convert_sse2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
     # MSVC doesn't support MMX when targeting AMD64.
     if CONFIG['_MSC_VER']:
         if CONFIG['OS_TEST'] != 'x86_64':
             SOURCES += [
                 'yuv_convert_mmx.cpp',
             ]
     else:
         SOURCES += ['yuv_convert_mmx.cpp']
-        if CONFIG['GNU_CC']:
-            SOURCES['yuv_convert_mmx.cpp'].flags += ['-mmmx']
-        if CONFIG['SOLARIS_SUNPRO_CXX']:
-            SOURCES['yuv_convert_mmx.cpp'].flags += ['-xarch=mmx', '-xO4']
+        SOURCES['yuv_convert_mmx.cpp'].flags += CONFIG['MMX_FLAGS']
 
 if CONFIG['_MSC_VER']:
     if CONFIG['OS_TEST'] == 'x86_64':
         if CONFIG['_MSC_VER'] == '1400':
             # VC8 doesn't support some SSE2 built-in functions
             SOURCES += [
                 'yuv_row_win.cpp',
             ]
--- a/intl/uconv/src/moz.build
+++ b/intl/uconv/src/moz.build
@@ -197,22 +197,17 @@ UNIFIED_SOURCES += [
     '../util/nsUnicodeEncodeHelper.cpp',
     '../util/ugen.c',
     '../util/umap.c',
     '../util/uscan.c',
 ]
 
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += ['nsUTF8ToUnicodeSSE2.cpp']
-    if CONFIG['GNU_CC']:
-        # nsUTF8ToUnicodeSSE2.cpp uses SSE2 intrinsics, so we need to pass -msse2 if
-        # we're using gcc. (See bug 585538 comment 12.)
-        SOURCES['nsUTF8ToUnicodeSSE2.cpp'].flags += ['-msse2']
-    if CONFIG['SOLARIS_SUNPRO_CXX']:
-        SOURCES['nsUTF8ToUnicodeSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
+    SOURCES['nsUTF8ToUnicodeSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '../ucvcn',
     '../ucvibm',
     '../ucvja',
     '../ucvko',
--- a/media/libsoundtouch/src/moz.build
+++ b/media/libsoundtouch/src/moz.build
@@ -19,26 +19,20 @@ UNIFIED_SOURCES += [
     'RateTransposer.cpp',
     'SoundTouch.cpp',
     'TDStretch.cpp',
 ]
 
 if CONFIG['INTEL_ARCHITECTURE']:
     if CONFIG['MOZ_SAMPLE_TYPE_FLOAT32']:
         SOURCES += ['sse_optimized.cpp']
-        if CONFIG['GNU_CC']:
-            SOURCES['sse_optimized.cpp'].flags += ['-msse2']
-        if CONFIG['SOLARIS_SUNPRO_CXX']:
-            SOURCES['sse_optimized.cpp'].flags += ['-xarch=sse2', '-xO4']
+        SOURCES['sse_optimized.cpp'].flags += CONFIG['SSE2_FLAGS']
     else:
         SOURCES += ['mmx_optimized.cpp']
-        if CONFIG['GNU_CC']:
-            SOURCES['mmx_optimized.cpp'].flags += ['-mmmx']
-        if CONFIG['SOLARIS_SUNPRO_CXX']:
-            SOURCES['mmx_optimized.cpp'].flags += ['-xarch=mmx', '-xO4']
+        SOURCES['mmx_optimized.cpp'].flags += CONFIG['MMX_FLAGS']
 
 MSVC_ENABLE_PGO = True
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     NO_VISIBILITY_FLAGS = True
 
 FINAL_LIBRARY = 'gkmedias'
 
 # Use abort() instead of exception in SoundTouch.
--- a/media/libspeex_resampler/src/moz.build
+++ b/media/libspeex_resampler/src/moz.build
@@ -34,14 +34,13 @@ if CONFIG['OS_TARGET'] == 'Android':
     DEFINES['FIXED_POINT'] = True
 else:
     DEFINES['FLOATING_POINT'] = True
 
 # Only use SSE code when using floating point samples, and on x86
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['OS_TARGET'] != 'Android':
     DEFINES['_USE_SSE'] = True
     DEFINES['_USE_SSE2'] = True
-    if CONFIG['GNU_CC']:
-        SOURCES['resample.c'].flags += ['-msse2']
+    SOURCES['resample.c'].flags += CONFIG['SSE2_FLAGS']
 
 # Suppress warnings in third-party code.
 if CONFIG['GNU_CC']:
     CFLAGS += ['-Wno-sign-compare']
--- a/media/libvpx/moz.build
+++ b/media/libvpx/moz.build
@@ -87,17 +87,17 @@ if CONFIG['OS_TARGET'] == 'Android':
         SOURCES += [
             '%s/sources/android/cpufeatures/cpu-features.c' % CONFIG['ANDROID_NDK'],
         ]
 
 if not CONFIG['_MSC_VER']:
     for f in SOURCES:
         if f.endswith('.c'):
             if 'sse2' in f:
-                SOURCES[f].flags += ['-msse2']
+                SOURCES[f].flags += CONFIG['SSE2_FLAGS']
             if 'ssse3' in f:
                 SOURCES[f].flags += ['-mssse3']
             if 'avx2' in f:
                 SOURCES[f].flags += ['-mavx2']
 
 # Suppress warnings in third-party code.
 if CONFIG['GNU_CC']:
     CFLAGS += ['-Wno-sign-compare']
--- a/xpcom/string/src/moz.build
+++ b/xpcom/string/src/moz.build
@@ -15,22 +15,17 @@ UNIFIED_SOURCES += [
     'nsSubstring.cpp',
     'nsSubstringTuple.cpp',
 ]
 
 # Are we targeting x86 or x86-64?  If so, compile the SSE2 functions for
 # nsUTF8Utils.cpp.
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += ['nsUTF8UtilsSSE2.cpp']
-    if CONFIG['GNU_CC']:
-        # gcc requires -msse2 on nsUTF8UtilsSSE2.cpp since it uses SSE2 intrinsics.
-        # (See bug 585538 comment 12.)
-        SOURCES['nsUTF8UtilsSSE2.cpp'].flags += ['-msse2']
-    if CONFIG['SOLARIS_SUNPRO_CXX']:
-        SOURCES['nsUTF8UtilsSSE2.cpp'].flags += ['-xarch=sse2', '-xO4']
+    SOURCES['nsUTF8UtilsSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
 LOCAL_INCLUDES += [
     '/mfbt/double-conversion',
 ]
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xpcom_core'