bug 361343 - make profiledbuild work on windows. r=bsmedberg
This commit is contained in:
Родитель
df7030351b
Коммит
15bfe95de7
10
Makefile.in
10
Makefile.in
|
@ -209,3 +209,13 @@ BUILDID = $(shell $(PYTHON) $(srcdir)/config/printconfigsetting.py $(DIST)/bin/a
|
|||
else
|
||||
BUILDID = $(shell $(PYTHON) $(srcdir)/config/printconfigsetting.py $(DIST)/bin/platform.ini Build BuildID)
|
||||
endif
|
||||
|
||||
#XXX: this is a hack, since we don't want to clobber for MSVC
|
||||
# PGO support, but we can't do this test in client.mk
|
||||
ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
|
||||
maybe_clobber_profiledbuild: clobber_all
|
||||
else
|
||||
maybe_clobber_profiledbuild:
|
||||
endif
|
||||
|
||||
.PHONY: maybe_clobber_profiledbuild
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/python
|
||||
# Usage: pgomerge.py <binary basename> <dist/bin>
|
||||
# Gathers .pgc files from dist/bin and merges them into
|
||||
# $PWD/$basename.pgd using pgomgr, then deletes them.
|
||||
# No errors if any of these files don't exist.
|
||||
|
||||
import sys, os, os.path, subprocess
|
||||
if not sys.platform == "win32":
|
||||
raise Exception("This script was only meant for Windows.")
|
||||
|
||||
def MergePGOFiles(basename, pgddir, pgcdir):
|
||||
"""Merge pgc files produced from an instrumented binary
|
||||
into the pgd file for the second pass of profile-guided optimization
|
||||
with MSVC. |basename| is the name of the DLL or EXE without the
|
||||
extension. |pgddir| is the path that contains <basename>.pgd
|
||||
(should be the objdir it was built in). |pgcdir| is the path
|
||||
containing basename!N.pgc files, which is probably dist/bin.
|
||||
Calls pgomgr to merge each pgc file into the pgd, then deletes
|
||||
the pgc files."""
|
||||
if not os.path.isdir(pgddir) or not os.path.isdir(pgcdir):
|
||||
return
|
||||
pgdfile = os.path.abspath(os.path.join(pgddir, basename + ".pgd"))
|
||||
if not os.path.isfile(pgdfile):
|
||||
return
|
||||
for file in os.listdir(pgcdir):
|
||||
if file.startswith(basename) and file.endswith(".pgc"):
|
||||
try:
|
||||
pgcfile = os.path.normpath(os.path.join(pgcdir, file))
|
||||
subprocess.call(['pgomgr', '-merge',
|
||||
pgcfile,
|
||||
pgdfile])
|
||||
os.remove(pgcfile)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >>sys.stderr, "Usage: pgomerge.py <binary basename> <dist/bin>"
|
||||
sys.exit(1)
|
||||
MergePGOFiles(sys.argv[1], os.getcwd(), sys.argv[2])
|
|
@ -1097,9 +1097,8 @@ build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
|||
profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) MOZ_PROFILE_GENERATE=1
|
||||
OBJDIR=${OBJDIR} $(PROFILE_GEN_SCRIPT)
|
||||
$(MOZ_MAKE) clobber_all
|
||||
$(MOZ_MAKE) maybe_clobber_profiledbuild
|
||||
$(MOZ_MAKE) MOZ_PROFILE_USE=1
|
||||
find $(OBJDIR) -name "*.da" -exec rm {} \;
|
||||
|
||||
####################################
|
||||
# Other targets
|
||||
|
|
|
@ -356,23 +356,37 @@ endif
|
|||
endif
|
||||
|
||||
# Enable profile-based feedback
|
||||
ifndef NO_PROFILE_GUIDED_OPTIMIZE
|
||||
ifdef MOZ_PROFILE_GENERATE
|
||||
# No sense in profiling tools
|
||||
ifndef INTERNAL_TOOLS
|
||||
OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
|
||||
OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
|
||||
endif # INTERNAL_TOOLS
|
||||
OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
AR_FLAGS += -LTCG
|
||||
endif
|
||||
else
|
||||
# We don't want to link internal tools with profiling,
|
||||
# but gcc needs to because xpidl will wind up linking with
|
||||
# libs that have been built with PROFILE_GEN_CFLAGS.
|
||||
ifdef GNU_CC
|
||||
OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
|
||||
endif
|
||||
endif # INTERNAL_TOOLS
|
||||
endif # MOZ_PROFILE_GENERATE
|
||||
|
||||
# We always use the profile-use flags, even in cases where we didn't use the
|
||||
# profile-generate flags. It's harmless, and it saves us from having to
|
||||
# answer the question "Would these objects have been built using
|
||||
# the profile-generate flags?" which is not trivial.
|
||||
ifdef MOZ_PROFILE_USE
|
||||
ifndef INTERNAL_TOOLS
|
||||
OS_CFLAGS += $(PROFILE_USE_CFLAGS)
|
||||
OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
|
||||
OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
|
||||
ifeq (WINNT,$(OS_ARCH))
|
||||
AR_FLAGS += -LTCG
|
||||
endif
|
||||
endif # INTERNAL_TOOLS
|
||||
endif # MOZ_PROFILE_USE
|
||||
endif # NO_PROFILE_GUIDED_OPTIMIZE
|
||||
|
||||
|
||||
# Does the makefile specifies the internal XPCOM API linkage?
|
||||
|
|
|
@ -784,6 +784,37 @@ endif # !NO_DIST_INSTALL
|
|||
|
||||
##############################################
|
||||
|
||||
ifndef NO_PROFILE_GUIDED_OPTIMIZE
|
||||
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
|
||||
ifeq ($(OS_ARCH)_$(GNU_CC)$(INTERNAL_TOOLS), WINNT_)
|
||||
# Force re-linking when building with PGO, since
|
||||
# the MSVC linker does all the work. We force re-link
|
||||
# in both stages so you can do depend builds with PGO.
|
||||
ifdef SHARED_LIBRARY
|
||||
$(SHARED_LIBRARY): FORCE
|
||||
BINARY_BASENAME = $(SHARED_LIBRARY:$(DLL_SUFFIX)=)
|
||||
endif
|
||||
ifdef PROGRAM
|
||||
$(PROGRAM): FORCE
|
||||
BINARY_BASENAME = $(PROGRAM:$(BIN_SUFFIX)=)
|
||||
endif
|
||||
|
||||
ifdef MOZ_PROFILE_USE
|
||||
# In the second pass, we need to merge the pgc files into the pgd file.
|
||||
# The compiler would do this for us automatically if they were in the right
|
||||
# place, but they're in dist/bin.
|
||||
ifdef BINARY_BASENAME
|
||||
export::
|
||||
$(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
|
||||
$(BINARY_BASENAME) $(DIST)/bin
|
||||
endif
|
||||
endif # MOZ_PROFILE_USE
|
||||
endif # WINNT_
|
||||
endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
|
||||
endif # NO_PROFILE_GUIDED_OPTIMIZE
|
||||
|
||||
##############################################
|
||||
|
||||
checkout:
|
||||
$(MAKE) -C $(topsrcdir) -f client.mk checkout
|
||||
|
||||
|
|
|
@ -1920,6 +1920,12 @@ case "$target" in
|
|||
MOZ_XPCOM_OBSOLETE_LIBS='$(LIBXUL_DIST)/lib/xpcom_compat.lib'
|
||||
if test $_MSC_VER -ge 1400; then
|
||||
LDFLAGS="$LDFLAGS -NXCOMPAT -SAFESEH"
|
||||
# For profile-guided optimization
|
||||
PROFILE_GEN_CFLAGS="-GL"
|
||||
PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
|
||||
PROFILE_USE_CFLAGS="-GL"
|
||||
#XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul
|
||||
PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
|
||||
fi
|
||||
fi
|
||||
MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,jpeg$(MOZ_BITS)$(VERSION_NUMBER),$(DEPTH)/jpeg)'
|
||||
|
@ -6514,6 +6520,9 @@ if test "$_IGNORE_LONG_LONG_WARNINGS"; then
|
|||
CFLAGS="$_SAVE_CFLAGS"
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl Profile guided optimization
|
||||
dnl ========================================================
|
||||
dnl Test for profiling options
|
||||
dnl Under gcc 3.3, use -fprofile-arcs/-fbranch-probabilities
|
||||
dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
|
||||
|
|
Загрузка…
Ссылка в новой задаче