Bug 945042 - Move NO_PROFILE_GUIDED_OPTIMIZE to moz.build. r=gps,r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 09 Dec 2013 13:39:26 +0900
changeset 160450 c7b7b00e867f80783f493ecbd128ee8e17c9c565
parent 160449 8b71967fcfd564c1584a2514577a7602b5393c38
child 160451 d6f19da0dfb30c6b74e7d1765de2c119ceaa0ff8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersgps, njn
bugs945042
milestone29.0a1
Bug 945042 - Move NO_PROFILE_GUIDED_OPTIMIZE to moz.build. r=gps,r=njn
browser/metro/shell/commandexecutehandler/Makefile.in
browser/metro/shell/commandexecutehandler/moz.build
browser/metro/shell/linktool/Makefile.in
browser/metro/shell/linktool/moz.build
browser/metro/shell/testing/Makefile.in
browser/metro/shell/testing/moz.build
build/unix/elfhack/Makefile.in
build/unix/elfhack/inject/Makefile.in
build/unix/elfhack/inject/moz.build
build/unix/elfhack/moz.build
build/unix/stdc++compat/Makefile.in
build/unix/stdc++compat/moz.build
build/win32/Makefile.in
build/win32/moz.build
config/rules.mk
db/sqlite3/src/Makefile.in
db/sqlite3/src/moz.build
gfx/layers/Makefile.in
gfx/layers/moz.build
js/src/Makefile.in
js/src/config/rules.mk
js/src/jit/RangeAnalysis.h
js/src/moz.build
js/src/shell/Makefile.in
js/src/shell/moz.build
media/libvpx/Makefile.in
media/libvpx/moz.build
memory/mozjemalloc/Makefile.in
memory/mozjemalloc/moz.build
netwerk/sctp/datachannel/Makefile.in
netwerk/sctp/datachannel/moz.build
netwerk/sctp/src/Makefile.in
netwerk/sctp/src/moz.build
xpcom/base/Makefile.in
xpcom/base/moz.build
xpcom/reflect/xptcall/src/md/unix/Makefile.in
xpcom/reflect/xptcall/src/md/unix/moz.build
xpcom/reflect/xptcall/src/md/win32/Makefile.in
xpcom/reflect/xptcall/src/md/win32/moz.build
--- a/browser/metro/shell/commandexecutehandler/Makefile.in
+++ b/browser/metro/shell/commandexecutehandler/Makefile.in
@@ -1,14 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 include $(topsrcdir)/config/config.mk
 
 DIST_PROGRAM = CommandExecuteHandler$(BIN_SUFFIX)
 
 # Don't link against mozglue.dll
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
--- a/browser/metro/shell/commandexecutehandler/moz.build
+++ b/browser/metro/shell/commandexecutehandler/moz.build
@@ -11,8 +11,10 @@ SOURCES += [
     'CommandExecuteHandler.cpp',
 ]
 
 # We want this exe in dist/bin
 DIST_SUBDIR = ''
 
 for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM'):
     DEFINES[var] = True
+
+NO_PGO = True
--- a/browser/metro/shell/linktool/Makefile.in
+++ b/browser/metro/shell/linktool/Makefile.in
@@ -1,14 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 include $(topsrcdir)/config/config.mk
 
 OS_LIBS = \
 	kernel32.lib \
 	user32.lib \
 	ole32.lib \
 	shlwapi.lib \
 	shell32.lib \
--- a/browser/metro/shell/linktool/moz.build
+++ b/browser/metro/shell/linktool/moz.build
@@ -9,8 +9,10 @@ PROGRAM = 'linktool'
 SOURCES += [
     'linktool.cpp',
 ]
 
 DIST_SUBDIR = 'metro/install'
 
 for var in ('UNICODE', '_UNICODE'):
     DEFINES[var] = True
+
+NO_PGO = True
--- a/browser/metro/shell/testing/Makefile.in
+++ b/browser/metro/shell/testing/Makefile.in
@@ -4,18 +4,16 @@
 
 # static win runtime linking
 USE_STATIC_LIBS = 1
 
 # don't use moz glue libs
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 include $(topsrcdir)/config/config.mk
 
 OS_LIBS = \
 	kernel32.lib \
 	user32.lib \
 	ole32.lib \
 	shlwapi.lib \
 	propsys.lib \
--- a/browser/metro/shell/testing/moz.build
+++ b/browser/metro/shell/testing/moz.build
@@ -10,8 +10,10 @@ SOURCES += [
     'metrotestharness.cpp',
 ]
 
 # We want this exe in dist/bin
 DIST_SUBDIR = ''
 
 for var in ('UNICODE', '_UNICODE'):
     DEFINES[var] = True
+
+NO_PGO = True
--- a/build/unix/elfhack/Makefile.in
+++ b/build/unix/elfhack/Makefile.in
@@ -1,17 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 INTERNAL_TOOLS = 1
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 VPATH += $(topsrcdir)/build
 
 OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions
 
 WRAP_LDFLAGS=
 
 include $(topsrcdir)/config/rules.mk
 
--- a/build/unix/elfhack/inject/Makefile.in
+++ b/build/unix/elfhack/inject/Makefile.in
@@ -1,15 +1,14 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 INTERNAL_TOOLS = 1
-NO_PROFILE_GUIDED_OPTIMIZE = 1
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(CSRCS:.c=.$(OBJ_SUFFIX))
 
 $(CSRCS): %.c: ../inject.c
 	cp $< $@
 
--- a/build/unix/elfhack/inject/moz.build
+++ b/build/unix/elfhack/inject/moz.build
@@ -13,8 +13,10 @@ elif CONFIG['TARGET_CPU'].startswith('ar
 else:
     cpu = CONFIG['TARGET_CPU']
 
 GENERATED_SOURCES += [
     "%s.c" % cpu,
 ]
 
 DEFINES['ELFHACK_BUILD'] = True
+
+NO_PGO = True
--- a/build/unix/elfhack/moz.build
+++ b/build/unix/elfhack/moz.build
@@ -20,8 +20,10 @@ if not CONFIG['CROSS_COMPILE']:
 HOST_SOURCES += [
     'elf.cpp',
     'elfhack.cpp',
 ]
 
 HOST_PROGRAM = 'elfhack'
 
 DEFINES['ELFHACK_BUILD'] = True
+
+NO_PGO = True
--- a/build/unix/stdc++compat/Makefile.in
+++ b/build/unix/stdc++compat/Makefile.in
@@ -1,12 +1,11 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 STL_FLAGS =
 NO_EXPAND_LIBS = 1
-NO_PROFILE_GUIDED_OPTIMIZE = 1
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += -DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_TARGET_VERSION)
 HOST_CXXFLAGS += -DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_HOST_VERSION)
--- a/build/unix/stdc++compat/moz.build
+++ b/build/unix/stdc++compat/moz.build
@@ -10,8 +10,10 @@ if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'
 
 if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
     HOST_LIBRARY_NAME = 'host_stdc++compat'
     HOST_SOURCES += [
         'stdc++compat.cpp',
     ]
 
 FORCE_STATIC_LIB = True
+
+NO_PGO = True
--- a/build/win32/Makefile.in
+++ b/build/win32/Makefile.in
@@ -1,14 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 ifdef ENABLE_TESTS
 
 USE_STATIC_LIBS = 1
 
 endif # ENABLE_TESTS
 
 MOZ_GLUE_LDFLAGS =
 
--- a/build/win32/moz.build
+++ b/build/win32/moz.build
@@ -9,8 +9,10 @@ if CONFIG['_MSC_VER'] and CONFIG['OS_TES
 
 TEST_DIRS += ['crashinjectdll']
 
 if CONFIG['ENABLE_TESTS']:
     PROGRAM = 'crashinject'
     SOURCES += [
         'crashinject.cpp',
     ]
+
+NO_PGO = True
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -637,17 +637,17 @@ endif
 ifdef IS_TOOL_DIR
 # One would think "tools:: libs" would work, but it turns out that combined with
 # bug 907365, this makes make forget to run some rules sometimes.
 tools::
 	@$(MAKE) libs
 endif
 
 ##############################################
-ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
 ifdef MOZ_PROFILE_USE
 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
 # When building with PGO, we have to make sure to re-link
 # in the MOZ_PROFILE_USE phase if we linked in the
 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
 # file in the link rule in the GENERATE phase to indicate
 # that we need a relink.
 ifdef SHARED_LIBRARY
--- a/db/sqlite3/src/Makefile.in
+++ b/db/sqlite3/src/Makefile.in
@@ -41,21 +41,16 @@ MODULE_OPTIMIZE_FLAGS = -O2
 endif
 
 # Force /O2 optimisation on Windows because using the default /O1 causes
 # crashes with MSVC2005 and PGO. See bug 719584.
 ifeq ($(OS_ARCH),WINNT)
 MODULE_OPTIMIZE_FLAGS = -O2
 endif
 
-# disable PGO for Sun Studio
-ifdef SOLARIS_SUNPRO_CC
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 # next line allows use of MOZ_OBJDIR in .mozconfig with older gcc on BeOS, maybe others
 LOCAL_INCLUDES += -I$(srcdir)
 
 ifeq ($(OS_ARCH),OS2)
 ADD_TO_DEF_FILE = $(PYTHON) -m mozbuild.action.preprocessor $(DEFINES) \
        $(srcdir)/sqlite.def | sed -e '1,/^EXPORTS$$/ d' -e 's,sqlite3,_\0,' \
--- a/db/sqlite3/src/moz.build
+++ b/db/sqlite3/src/moz.build
@@ -57,8 +57,12 @@ if CONFIG['OS_TARGET'] == 'Android':
     # default to user readable only to fit Android security model
     DEFINES['SQLITE_DEFAULT_FILE_PERMISSIONS'] = '0600'
 
 # Force using malloc_usable_size when building with jemalloc because _msize
 # causes assertions on Win64. See bug 719579.
 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MEMORY']:
     DEFINES['HAVE_MALLOC_USABLE_SIZE'] = True
     DEFINES['SQLITE_WITHOUT_MSIZE'] = True
+
+# disable PGO for Sun Studio
+if CONFIG['SOLARIS_SUNPRO_CC']:
+    NO_PGO = True
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -20,18 +20,8 @@ include $(topsrcdir)/config/rules.mk
 CXXFLAGS += \
         -I$(ANDROID_SOURCE)/frameworks/base/include/media/stagefright \
         -I$(ANDROID_SOURCE)/frameworks/base/include/media/stagefright/openmax \
         -I$(ANDROID_SOURCE)/frameworks/av/include/media/stagefright \
         -I$(ANDROID_SOURCE)/frameworks/native/include/media/openmax \
         $(NULL)
 
 CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-
-ifdef _MSC_VER
-ifeq ($(CPU_ARCH),x86_64)
-# Workaround compiler bug (Bug 795594)
-NO_PROFILE_GUIDED_OPTIMIZE := \
-  LayerTreeInvalidation.cpp \
-  Layers.cpp \
-  $(NULL)
-endif
-endif
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -249,38 +249,46 @@ UNIFIED_SOURCES += [
     'ipc/LayerTransactionChild.cpp',
     'ipc/LayerTransactionParent.cpp',
     'ipc/ShadowLayerChild.cpp',
     'ipc/ShadowLayerParent.cpp',
     'ipc/ShadowLayers.cpp',
     'ipc/SharedPlanarYCbCrImage.cpp',
     'ipc/SharedRGBImage.cpp',
     'ipc/TaskThrottler.cpp',
-    'Layers.cpp',
     'LayerScope.cpp',
     'LayersLogging.cpp',
     'LayerSorter.cpp',
-    'LayerTreeInvalidation.cpp',
     'opengl/CompositingRenderTargetOGL.cpp',
     'opengl/CompositorOGL.cpp',
     'opengl/OGLShaderProgram.cpp',
     'opengl/TextureClientOGL.cpp',
     'opengl/TextureHostOGL.cpp',
     'opengl/TexturePoolOGL.cpp',
     'ReadbackProcessor.cpp',
     'RenderTrace.cpp',
     'RotatedBuffer.cpp',
     'YCbCrImageDataSerializer.cpp',
 ]
 
 SOURCES += [
     'basic/BasicImageLayer.cpp',
     'ImageContainer.cpp',
+    'Layers.cpp',
+    'LayerTreeInvalidation.cpp',
 ]
 
+# Workaround compiler bug (Bug 795594)
+if CONFIG['_MSC_VER'] and CONFIG['CPU_ARCH'] == 'x86_64':
+    for src in [
+        'Layers.cpp',
+        'LayerTreeInvalidation.cpp',
+    ]:
+        SOURCES[src].no_pgo = True
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     SOURCES += [
         'basic/MacIOSurfaceTextureHostBasic.cpp',
         'opengl/MacIOSurfaceTextureClientOGL.cpp',
         'opengl/MacIOSurfaceTextureHostOGL.cpp',
     ]
 
 IPDL_SOURCES = [
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -375,32 +375,16 @@ EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
 else
 SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS)
 endif
 
 # Prevent floating point errors caused by VC++ optimizations
 ifdef _MSC_VER
 # XXX We should add this to CXXFLAGS, too?
 CFLAGS += -fp:precise
-
-ifeq ($(CPU_ARCH),x86)
-# Workaround compiler bug on PGO (Bug 721284)
-NO_PROFILE_GUIDED_OPTIMIZE := \
-  MonoIC.cpp \
-  Compiler.cpp \
-  $(NULL)
-# Ditto (Bug 772303)
-NO_PROFILE_GUIDED_OPTIMIZE += RegExp.cpp
-endif
-# Ditto (Bug 810661)
-ifeq ($(CPU_ARCH),x86_64)
-NO_PROFILE_GUIDED_OPTIMIZE := \
-  CTypes.cpp \
-  $(NULL)
-endif
 endif # _MSC_VER
 
 ifeq ($(OS_ARCH),FreeBSD)
 EXTRA_LIBS	+= -pthread
 endif
 ifeq ($(OS_ARCH),Linux)
 EXTRA_LIBS	+= -ldl
 endif
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -637,17 +637,17 @@ endif
 ifdef IS_TOOL_DIR
 # One would think "tools:: libs" would work, but it turns out that combined with
 # bug 907365, this makes make forget to run some rules sometimes.
 tools::
 	@$(MAKE) libs
 endif
 
 ##############################################
-ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
 ifdef MOZ_PROFILE_USE
 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
 # When building with PGO, we have to make sure to re-link
 # in the MOZ_PROFILE_USE phase if we linked in the
 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
 # file in the link rule in the GENERATE phase to indicate
 # that we need a relink.
 ifdef SHARED_LIBRARY
--- a/js/src/jit/RangeAnalysis.h
+++ b/js/src/jit/RangeAnalysis.h
@@ -8,16 +8,20 @@
 #define jit_RangeAnalysis_h
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 
 #include "jit/IonAnalysis.h"
 #include "jit/MIR.h"
 
+// windows.h defines those, which messes with the definitions below.
+#undef min
+#undef max
+
 namespace js {
 namespace jit {
 
 class MBasicBlock;
 class MIRGraph;
 
 // An upper bound computed on the number of backedges a loop will take.
 // This count only includes backedges taken while running Ion code: for OSR
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -93,17 +93,16 @@ EXPORTS.js += [
 UNIFIED_SOURCES += [
     'assembler/jit/ExecutableAllocator.cpp',
     'builtin/Eval.cpp',
     'builtin/Intl.cpp',
     'builtin/MapObject.cpp',
     'builtin/Object.cpp',
     'builtin/ParallelArray.cpp',
     'builtin/Profilers.cpp',
-    'builtin/RegExp.cpp',
     'builtin/TestingFunctions.cpp',
     'builtin/TypedObject.cpp',
     'builtin/TypeRepresentation.cpp',
     'devtools/sharkctl.cpp',
     'ds/LifoAlloc.cpp',
     'frontend/BytecodeCompiler.cpp',
     'frontend/BytecodeEmitter.cpp',
     'frontend/FoldConstants.cpp',
@@ -192,23 +191,26 @@ UNIFIED_SOURCES += [
     'yarr/YarrCanonicalizeUCS2.cpp',
     'yarr/YarrInterpreter.cpp',
     'yarr/YarrPattern.cpp',
     'yarr/YarrSyntaxChecker.cpp',
 ]
 
 # jsarray.cpp and jsatom.cpp cannot be built in unified mode because
 # xpcshell is broken during packaging when compiled with gcc-4.8.2
+# builtin/RegExp.cpp cannot be built in unified mode because it is built
+# without PGO
 # frontend/Parser.cpp cannot be built in unified mode because of explicit
 # template instantiations.
 # jsmath.cpp cannot be built in unified mode because it needs to pull rand_s
 # from <stdlib.h> on Windows through a preprocessor define.
 # jsutil.cpp cannot be built in unified mode because it is needed for
 # check-vanilla-allocations.
 SOURCES += [
+    'builtin/RegExp.cpp',
     'frontend/Parser.cpp',
     'jsarray.cpp',
     'jsatom.cpp',
     'jsmath.cpp',
     'jsutil.cpp',
 ]
 
 if CONFIG['JS_POSIX_NSPR']:
@@ -418,8 +420,14 @@ if CONFIG['JS_THREADSAFE']:
 
 if CONFIG['JS_HAS_CTYPES']:
     DEFINES['JS_HAS_CTYPES'] = True
     for var in ('DLL_PREFIX', 'DLL_SUFFIX'):
         DEFINES[var] = '"%s"' % CONFIG[var]
 
 if CONFIG['MOZ_LINKER']:
     DEFINES['MOZ_LINKER'] = True
+
+if CONFIG['_MSC_VER']:
+    if CONFIG['CPU_ARCH'] == 'x86':
+        SOURCES['builtin/RegExp.cpp'].no_pgo = True # Bug 772303
+    elif CONFIG['CPU_ARCH'] == 'x86_64':
+        SOURCES['ctypes/CTypes.cpp'].no_pgo = True # Bug 810661
--- a/js/src/shell/Makefile.in
+++ b/js/src/shell/Makefile.in
@@ -1,21 +1,14 @@
 # -*- Mode: makefile -*-
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifdef _MSC_VER
-# unnecessary PGO for js shell.  But gcc cannot turn off pgo because it is
-# necessary to link PGO lib on gcc when a object/static lib are compiled
-# for PGO.
-NO_PROFILE_GUIDED_OPTIMIZE := 1
-endif
-
 LIBS      = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(MOZ_ZLIB_LIBS)
 ifdef MOZ_NATIVE_FFI
 EXTRA_LIBS += $(MOZ_FFI_LIBS)
 endif
 ifdef MOZ_SHARED_ICU
 EXTRA_LIBS += $(MOZ_ICU_LIBS)
 endif
 
--- a/js/src/shell/moz.build
+++ b/js/src/shell/moz.build
@@ -11,8 +11,14 @@ UNIFIED_SOURCES += [
     'jsheaptools.cpp',
     'jsoptparse.cpp',
 ]
 
 # Building against js_static requires that we declare mfbt sybols "exported"
 # on its behalf.
 for var in ('EXPORT_JS_API', 'IMPL_MFBT'):
     DEFINES[var] = True
+
+if CONFIG['_MSC_VER']:
+    # unnecessary PGO for js shell.  But gcc cannot turn off pgo because it is
+    # necessary to link PGO lib on gcc when a object/static lib are compiled
+    # for PGO.
+    NO_PGO = True
--- a/media/libvpx/Makefile.in
+++ b/media/libvpx/Makefile.in
@@ -103,21 +103,16 @@ ifndef _MSC_VER
 %_avx2.$(OBJ_SUFFIX): CFLAGS += -mavx2
 endif
 
 quantize_sse4.$(OBJ_SUFFIX): vp8_asm_enc_offsets.asm
 quantize_ssse3.$(OBJ_SUFFIX): vp8_asm_enc_offsets.asm
 
 ifdef VPX_NEED_OBJ_INT_EXTRACT
 
-# only for MSVC
-ifdef _MSC_VER
-NO_PROFILE_GUIDED_OPTIMIZE := vpx_scale_asm_offsets.c vp8_asm_enc_offsets.c
-endif
-
 vpx_scale_asm_offsets.asm: vpx_scale_asm_offsets.$(OBJ_SUFFIX) $(HOST_PROGRAM)
 	./$(HOST_PROGRAM) $(VPX_OIE_FORMAT) $< \
 	    $(if $(VPX_AS_CONVERSION),| $(VPX_AS_CONVERSION)) > $@
 
 # Filter out this object, because we don't want to link against it.
 # It was generated solely so it could be parsed by obj_int_extract.
 OBJS := $(filter-out vpx_scale_asm_offsets.$(OBJ_SUFFIX),$(OBJS))
 
--- a/media/libvpx/moz.build
+++ b/media/libvpx/moz.build
@@ -20,20 +20,24 @@ FILES_PER_UNIFIED_FILE = 8
 
 SOURCES += files['SOURCES']
 UNIFIED_SOURCES += files['UNIFIED_SOURCES']
 
 if CONFIG['MOZ_VPX_ERROR_CONCEALMENT']:
     SOURCES += files['ERROR_CONCEALMENT']
 
 if CONFIG['VPX_X86_ASM'] and CONFIG['OS_TARGET'] == 'WINNT':
-    SOURCES += [
+    offset_sources = [
         'vp8/encoder/vp8_asm_enc_offsets.c',
         'vpx_scale/vpx_scale_asm_offsets.c',
     ]
+    SOURCES += offset_sources
+    if CONFIG['_MSC_VER']:
+        for s in offset_sources:
+            SOURCES[s].no_pgo = True
 
 if CONFIG['VPX_X86_ASM']:
     SOURCES += files['X86_ASM']
 
     if '64' in CONFIG['OS_TEST']:
         SOURCES += files['X86-64_ASM']
 
     # AVX2 only supported on
--- a/memory/mozjemalloc/Makefile.in
+++ b/memory/mozjemalloc/Makefile.in
@@ -4,17 +4,11 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifndef MOZ_JEMALLOC3
 ifeq ($(OS_ARCH),SunOS)
 ifndef GNU_CC
 MODULE_OPTIMIZE_FLAGS = -xO5
 endif
 endif
-
-ifeq (Linux,$(OS_TARGET))
-#XXX: PGO on Linux causes problems here
-# See bug 419470
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-endif
 endif
 
 LOCAL_INCLUDES += -I$(topsrcdir)/memory/build
--- a/memory/mozjemalloc/moz.build
+++ b/memory/mozjemalloc/moz.build
@@ -21,8 +21,13 @@ if CONFIG['MOZ_UPDATE_CHANNEL'] not in (
     DEFINES['MOZ_JEMALLOC_HARD_ASSERTS'] = True
 
 DEFINES['abort'] = 'moz_abort'
 
 if CONFIG['MOZ_REPLACE_MALLOC']:
     DEFINES['MOZ_REPLACE_MALLOC'] = True
 
 DEFINES['MOZ_JEMALLOC_IMPL'] = True
+
+#XXX: PGO on Linux causes problems here
+# See bug 419470
+if CONFIG['OS_TARGET'] == 'Linux':
+    NO_PGO = True
deleted file mode 100644
--- a/netwerk/sctp/datachannel/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-NO_PROFILE_GUIDED_OPTIMIZE = 1 # Don't PGO
--- a/netwerk/sctp/datachannel/moz.build
+++ b/netwerk/sctp/datachannel/moz.build
@@ -34,8 +34,10 @@ DEFINES['SCTP_DEBUG'] = 1
 
 if CONFIG['OS_TARGET'] != 'Android':
     DEFINES['INET6'] = 1
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFINES['__Userspace_os_Windows'] = 1
 else:
     DEFINES['__Userspace_os_%s' % CONFIG['OS_TARGET']] = 1
+
+NO_PGO = True # Don't PGO
--- a/netwerk/sctp/src/Makefile.in
+++ b/netwerk/sctp/src/Makefile.in
@@ -1,15 +1,13 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1 # Don't PGO
-
 ifeq ($(OS_TARGET),Darwin)
 DEFINES += \
   -U__APPLE__ \
   $(NULL)
 else
 ifeq ($(OS_TARGET),FreeBSD)
 DEFINES += \
   -U__FreeBSD__ \
--- a/netwerk/sctp/src/moz.build
+++ b/netwerk/sctp/src/moz.build
@@ -75,8 +75,10 @@ else:
     DEFINES['__Userspace_os_%s' % CONFIG['OS_TARGET']] = 1
 
 if CONFIG['OS_TARGET'] == 'Darwin':
     DEFINES['__APPLE_USE_RFC_2292'] = 1
 
 if CONFIG['OS_TARGET'] in ('Linux', 'Android'):
     # to make sure that in6_pktinfo gets defined on all distros
     DEFINES['_GNU_SOURCE'] = True
+
+NO_PGO = True # Don't PGO
--- a/xpcom/base/Makefile.in
+++ b/xpcom/base/Makefile.in
@@ -1,17 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOZILLA_INTERNAL_API =1
 
-NO_PROFILE_GUIDED_OPTIMIZE = nsDebugImpl.cpp
-
 INSTALL_TARGETS += errorlist
 errorlist_FILES := \
   ErrorListCDefines.h \
   ErrorListCxxDefines.h \
   $(NULL)
 errorlist_DEST = $(DIST)/include
 errorlist_TARGET := export
 
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -86,16 +86,17 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'WindowsVersion.h',
     ]
 
 # nsDebugImpl isn't unified because we disable PGO so that NS_ABORT_OOM isn't
 # optimized away oddly.
 SOURCES += [
     'nsDebugImpl.cpp',
 ]
+SOURCES['nsDebugImpl.cpp'].no_pgo = True
 
 UNIFIED_SOURCES += [
     'AvailableMemoryTracker.cpp',
     'ClearOnShutdown.cpp',
     'CycleCollectedJSRuntime.cpp',
     'Debug.cpp',
     'nsConsoleMessage.cpp',
     'nsConsoleService.cpp',
@@ -124,15 +125,13 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
     SOURCES += [
         'nsCrashOnException.cpp',
     ]
 
 UNIFIED_SOURCES += [
     'nsErrorAssertsC.c',
 ]
 
-
-
 MSVC_ENABLE_PGO = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xpcom_core'
--- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in
@@ -1,28 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-
 MOZILLA_INTERNAL_API = 1
 
-#
-# The default is this buildable, but non-functioning code.
-#
-ifeq ($(OS_ARCH),SunOS)
-ifneq (86,$(findstring 86,$(OS_TEST)))
-# disable PGO for this directory with Sun Studio on SPARC because
-# compiling with xprofile=collect will insert code into nsXPTCStubBase::Stub##n
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-endif
-endif
-
 ######################################################################
 # ARM
 ######################################################################
 #
 # Linux/ARM
 #
 ifeq ($(OS_ARCH),Linux)
 ifneq (,$(filter arm% sa110,$(OS_TEST)))
--- a/xpcom/reflect/xptcall/src/md/unix/moz.build
+++ b/xpcom/reflect/xptcall/src/md/unix/moz.build
@@ -303,8 +303,10 @@ if CONFIG['OS_ARCH'] == 'Linux':
         ]
     elif CONFIG['OS_TEST'] == 's390x':
         SOURCES += [
             'xptcinvoke_linux_s390x.cpp',
             'xptcstubs_linux_s390x.cpp',
         ]
 
 FINAL_LIBRARY = 'xpcom_core'
+
+NO_PGO = True
--- a/xpcom/reflect/xptcall/src/md/win32/Makefile.in
+++ b/xpcom/reflect/xptcall/src/md/win32/Makefile.in
@@ -2,19 +2,11 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOZILLA_INTERNAL_API = 1
 
 LOCAL_INCLUDES += -I$(srcdir)/../../../../xptinfo/src
 
-
-ifneq ($(TARGET_CPU),x86_64)
-ifndef GNU_CXX
-# FIXME: bug 413019
-NO_PROFILE_GUIDED_OPTIMIZE = 1
-endif #!GNU_CXX
-endif #!x86_64
-
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	+= -I$(srcdir)/../..
--- a/xpcom/reflect/xptcall/src/md/win32/moz.build
+++ b/xpcom/reflect/xptcall/src/md/win32/moz.build
@@ -30,8 +30,13 @@ else:
         ]
     else:
         SOURCES += [
             'xptcinvoke.cpp',
             'xptcstubs.cpp',
         ]
 
 FINAL_LIBRARY = 'xpcom_core'
+
+if CONFIG['TARGET_CPU'] != 'x86_64':
+    if not CONFIG['GNU_CXX']:
+        # FIXME: bug 413019
+        NO_PGO = True