If you get some ideas from my project, please quote with
pcxfirefox, and this is my greatest reward. Many thanks.
This wiki page tells you some steps and tips to build Mozilla Product using VC2010.
The compiler and SDKs which I use are below.
Mozilla-build
Official link
Compiler
Microsoft Visual Studio 2010 SP1
Windows SDK
Microsoft Windows SDK for Windows 7 and .NET Framework 4
DirectX SDK
Microsoft DirectX SDK (June 2010)
Put .mozconfig on the source code tree's Top-level directory.
. $topsrcdir/browser/config/mozconfig ac_add_options --enable-application=browser mk_add_options MOZ_MAKE_FLAGS=-j1 mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obju-vc # for 64-bit build #ac_add_options --target=x86_64-pc-mingw32 #ac_add_options --host=x86_64-pc-mingw32 export MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf -LARGEADDRESSAWARE" mk_add_options MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf -LARGEADDRESSAWARE" # for 64-bit build #export MOZ_OPTIMIZE_LDFLAGS="-MACHINE:X64 -OPT:REF,ICF" #mk_add_options MOZ_OPTIMIZE_LDFLAGS="-MACHINE:X64 -OPT:REF,ICF" ac_add_options --disable-auto-deps ac_add_options --disable-tests ac_add_options --disable-ipdl-tests ac_add_options --enable-installer #ac_add_options --with-branding=browser/branding/aurora ac_add_options --enable-official-branding ac_add_options --enable-extensions=default ac_add_options --enable-strip ac_add_options --enable-install-strip # for Athlon 64/Pentium 4/ # for X86 ac_add_options --enable-optimize="-O2 -GL -arch:SSE2" # for X64 #ac_add_options --enable-optimize="-O2 -GL -favor:blend" # diasble updater ac_add_options --disable-updater ac_add_options --disable-update-channel ac_add_options --disable-update-packaging # diasble crashreporter ac_add_options --disable-crashreporter # Enable jemalloc ac_add_options --enable-jemalloc # enable shared js ac_add_options --enable-shared-js # for debug ac_add_options --enable-debugger-info-modules=yes ac_add_options --enable-debugger-info-modules ac_add_options --enable-debug-symbols # for auto pgo build mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(MOZ_OBJDIR)/_profile/pgo/profileserver.py' # for manual pgo build # mk_add_options PROFILE_GEN_SCRIPT='cscript E:/Mozilla/PgoMsg.vbs' ac_add_options --disable-activex ac_add_options --disable-activex-scripting ac_add_options --enable-crypto ac_add_options --enable-image-decoders=icon,png,gif,jpeg,bmp #ac_add_options --enable-chrome-format=jar ac_add_options --disable-mochitest ac_add_options --disable-mochitests ac_add_options --disable-accessibility ac_add_options --disable-parental-controls ac_add_options --disable-windows-mobile-components ac_add_options --disable-maintenance-service # windows version ac_add_options --with-windows-version=601 # crt dir WIN32_REDIST_DIR=$VCINSTALLDIR/redist/x86/Microsoft.VC100.CRT # for X64 #WIN32_REDIST_DIR=$VCINSTALLDIR/redist/x64/Microsoft.VC100.CRT
ac_add_options --enable-application=mail mk_add_options MOZ_CO_PROJECT=mail mk_add_options MOZ_MAKE_FLAGS=-j1 mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obju-vc # for 64-bit build #ac_add_options --target=x86_64-pc-mingw32 #ac_add_options --host=x86_64-pc-mingw32 export MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf -LARGEADDRESSAWARE" mk_add_options MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf -LARGEADDRESSAWARE" # for 64-bit build #export MOZ_OPTIMIZE_LDFLAGS="-MACHINE:X64 -OPT:REF,ICF" #mk_add_options MOZ_OPTIMIZE_LDFLAGS="-MACHINE:X64 -OPT:REF,ICF" ac_add_options --disable-auto-deps ac_add_options --disable-tests ac_add_options --disable-ipdl-tests ac_add_options --enable-installer #ac_add_options --with-branding=browser/branding/aurora ac_add_options --enable-official-branding ac_add_options --enable-extensions=default ac_add_options --enable-strip ac_add_options --enable-install-strip # for Athlon 64/Pentium 4/ # for X86 ac_add_options --enable-optimize="-O2 -GL -arch:SSE2" # for X64 #ac_add_options --enable-optimize="-O2 -GL -favor:blend" # diasble updater ac_add_options --disable-updater ac_add_options --disable-update-channel ac_add_options --disable-update-packaging # diasble crashreporter ac_add_options --disable-crashreporter # Enable jemalloc ac_add_options --enable-jemalloc # enable shared js ac_add_options --enable-shared-js # for debug ac_add_options --enable-debugger-info-modules=yes ac_add_options --enable-debugger-info-modules ac_add_options --enable-debug-symbols # for auto pgo build mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(MOZ_OBJDIR)/_profile/pgo/profileserver.py' # for manual pgo build mk_add_options PROFILE_GEN_SCRIPT='cscript E:/Mozilla/PgoMsg.vbs' ac_add_options --disable-activex ac_add_options --disable-activex-scripting ac_add_options --enable-crypto ac_add_options --enable-image-decoders=icon,png,gif,jpeg,bmp #ac_add_options --enable-chrome-format=jar ac_add_options --disable-mochitest ac_add_options --disable-mochitests ac_add_options --disable-accessibility ac_add_options --disable-parental-controls ac_add_options --disable-windows-mobile-components ac_add_options --disable-maintenance-service # windows version ac_add_options --with-windows-version=601 # crt dir WIN32_REDIST_DIR=$VCINSTALLDIR/redist/x86/Microsoft.VC100.CRT # for X64 #WIN32_REDIST_DIR=$VCINSTALLDIR/redist/x64/Microsoft.VC100.CRT
Assume that you put the source code to e:\mozilla\mozilla-release .
Open Mozilla Msys Bash (start-msvc10.bat)
cd /e/mozilla/mozilla-release make -f client.mk build
cd /e/mozilla/obju-vc make installer
The installer will be generated in the folder e:/mozilla/obju-vc/dist/install/sea .
Off course, you can decompress it using 7zip.
The methods involved below can be used at the same time.
make -f client.mk profiledbuild
If you use BetterPGO, I suggest you to use manual PGO test, which can control test time more flexibly.
Full BetterPGO test can be used: http://pcxfirefox.googlecode.com/files/BetterPGO_20120204_OfflineTest.7z
Manual PGO test needs a pause build script, so we can use a python script to do that (cross platform).
# stopmsg.py Cross Platform from Tkinter import * class Application(Frame): def say_hi(self): print "PGO-gen is not finished!" def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "PGO-gen finished" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) self.hi_there = Button(self) self.hi_there["text"] = "PGO-gen is not finished", self.hi_there["command"] = self.say_hi self.hi_there.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() root = Tk() app = Application(master=root) app.mainloop() root.destroy()
Or use vcscript on Windows (from tete009's PgoMsg.vbs)
Dim r Do r = MsgBox("Please push [Yes] button after collecting the profile data manually.", 4 + 48 + 256, "Mozilla PGO") Loop While r <> 6
mk_add_options PROFILE_GEN_SCRIPT='python e:/mozilla/stopmsg.py'
or
mk_add_options PROFILE_GEN_SCRIPT='cscript e:/mozilla/PgoMsg.vbs'
make -f client.mk profiledbuild
When pgo-gen finished, build process will be paused by the script above.
Latest Mozilla edition need a environment variable set MOZ_PGO_INSTRUMENTED=1, and only this can run pgo-gen test.
Then you can enter <obj>/dist/bin
, run firefox.exe or thunderbird.exe, and run some BetterPGO tests, close it. And then you can copy the related files' .pgc to their .pgd folder.
Close the script dialog, then continue building.
How BetterPGO Auto run?
You can see my origin idea.
BetterPGO should improve the performance remarkably (by 5%-35% depending on different tests).
If you 3rd Math optimization lib, you can use it.
Take Intel LibM for an example, you can modify the lines in .mozconfig
export MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf libmmt.lib libircmt.lib" mk_add_options MOZ_OPTIMIZE_LDFLAGS="-opt:ref,icf libmmt.lib libircmt.lib"
Note: you also may choose to link Intel LibM dynamic lib, which can reduce some memory, but may cause some extentions not to work.
At the same time, to make Intel LibM run fastest, you need to enforce including the similar header file.
#include <math.h> #pragma function(atan,exp,log10,sqrt,atan2,log,sin,tan,cos,acos,cosh,pow,tanh,asin,fmod,sinh)
Of course, you also can use -Oi- to link Intel LibM directly, but -Oi- will cause VC's other functions run very slowly (such as memcpy).
-GR- -GS-
The two switch can reduce the image's size, so may improve some cache performance theoretically, but -GS- may downgrade some security.
-fp:fast
Not a safe option. But only use the switch, VC's many math functions have intrisic forms (if you don't use 3rd libM).
If you want to use -fp:fast, you must patch the some Makefile to avoid the miscount:
diff -ruNa mozilla-beta-vc/content/Makefile.in mozilla-beta/content/Makefile.in --- mozilla-beta-vc/content/Makefile.in Thu May 24 02:56:34 2012 +++ mozilla-beta/content/Makefile.in Mon May 28 15:00:25 2012 @@ -67,3 +67,6 @@ endif # WINNT include $(topsrcdir)/config/rules.mk + +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise diff -ruNa mozilla-beta-vc/ipc/app/Makefile.in mozilla-beta/ipc/app/Makefile.in --- mozilla-beta-vc/ipc/app/Makefile.in Thu May 24 02:56:46 2012 +++ mozilla-beta/ipc/app/Makefile.in Mon May 28 15:02:26 2012 @@ -130,3 +130,6 @@ $(NSINSTALL) $(PROGRAM) $(DIST)/bin/$(PROGRAM).app/Contents/MacOS rm -f $(DIST)/bin/$(PROGRAM) endif + +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise diff -ruNa mozilla-beta-vc/js/src/Makefile.in mozilla-beta/js/src/Makefile.in --- mozilla-beta-vc/js/src/Makefile.in Thu May 24 02:56:46 2012 +++ mozilla-beta/js/src/Makefile.in Mon May 28 15:03:00 2012 @@ -919,3 +919,5 @@ # END kludges for the Nitro assembler ############################################### +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise diff -ruNa mozilla-beta-vc/memory/jemalloc/Makefile.in mozilla-beta/memory/jemalloc/Makefile.in --- mozilla-beta-vc/memory/jemalloc/Makefile.in Thu May 24 02:56:58 2012 +++ mozilla-beta/memory/jemalloc/Makefile.in Mon May 28 15:27:45 2012 @@ -67,3 +67,6 @@ endif include $(topsrcdir)/config/rules.mk + +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise diff -ruNa mozilla-beta-vc/nsprpub/pr/src/misc/Makefile.in mozilla-beta/nsprpub/pr/src/misc/Makefile.in --- mozilla-beta-vc/nsprpub/pr/src/misc/Makefile.in Thu May 24 02:57:04 2012 +++ mozilla-beta/nsprpub/pr/src/misc/Makefile.in Mon May 28 15:12:06 2012 @@ -109,4 +109,5 @@ export:: $(TARGETS) - +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise diff -ruNa mozilla-beta-vc/security/nss/lib/sqlite/Makefile mozilla-beta/security/nss/lib/sqlite/Makefile --- mozilla-beta-vc/security/nss/lib/sqlite/Makefile Thu May 24 02:57:06 2012 +++ mozilla-beta/security/nss/lib/sqlite/Makefile Mon May 28 15:19:05 2012 @@ -78,3 +78,5 @@ export:: private_export +CFLAGS += -fp:precise +CXXFLAGS += -fp:precise
For those modules to be used -fp:precise, we can add -Qfast_transcendentals to improve some performance, too.
-arch:AVX
Generate AVX Auto SIMD program.
-GA
Optimize for .exe, don't use for .dll !
You may use the similar patches below:
diff -ruNa mozilla-beta-vc/browser/app/Makefile.in mozilla-beta/browser/app/Makefile.in --- mozilla-beta-vc/browser/app/Makefile.in Thu May 24 02:56:32 2012 +++ mozilla-beta/browser/app/Makefile.in Mon May 28 14:52:51 2012 @@ -232,3 +232,6 @@ endif # cocoa endif # SKIP_COPY_XULRUNNER endif # LIBXUL_SDK + +CFLAGS += -GA +CXXFLAGS += -GA diff -ruNa mozilla-beta-vc/ipc/app/Makefile.in mozilla-beta/ipc/app/Makefile.in --- mozilla-beta-vc/ipc/app/Makefile.in Thu May 24 02:56:46 2012 +++ mozilla-beta/ipc/app/Makefile.in Mon May 28 15:02:26 2012 @@ -130,3 +130,6 @@ $(NSINSTALL) $(PROGRAM) $(DIST)/bin/$(PROGRAM).app/Contents/MacOS rm -f $(DIST)/bin/$(PROGRAM) endif + +CFLAGS += -GA +CXXFLAGS += -GA
When you use manual PGO test, I suggest your test time is less than 50 minutes each time, or VC may not generate PGO information.
Sometimes you may encounter some problems below when linking especially on X64 build:
d:\mozilla\js\src\ctypes\ctypes.cpp(1461): fatal error C1001: An internal error has occurred in the compiler. (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x709037A1:0x00000010]', line 183) To work around this problem, try simplifying or changing the program near the locations listed above. Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
You can see the
notes, to use a X86 to X64 cross linker, but may also encounter the similar problem. To solve it, you can rebuild the source code to be in question (like ctypes.cpp above) using "-GL-", and continue making and linking. This process may be repeated more than once ( because it's very random ).
You can use the similar patch:
diff -r cac0854514e9 js/src/Makefile.in --- a/js/src/Makefile.in Sat Jun 02 10:16:44 2012 +0900 +++ b/js/src/Makefile.in Sat Jun 02 10:29:19 2012 +0900 @@ -914,8 +910,38 @@ endif TestMain$(HOST_BIN_SUFFIX): $(TESTMAIN_OBJS) $(CXX) -o TestMain$(HOST_BIN_SUFFIX) $(TESTMAIN_OBJS) endif # # END kludges for the Nitro assembler ############################################### +ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) +ctypes.$(OBJ_SUFFIX): ctypes.cpp $(GLOBAL_DEPS) + $(REPORT_BUILD) + @$(MAKE_DEPS_AUTO_CXX) + $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) -GL- $(_VPATH_SRCS) +endif
Wiki: Guide
Wiki: GuideExplained
View and moderate all "wiki Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Wiki"
Originally posted by: lky...@gmail.com
VC编译一直很慢呐... 你有没有什么加快编译的技巧么
View and moderate all "wiki Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Wiki"
Originally posted by: xunxun1...@gmail.com
MOZ_MAKE_FLAGS=-jN 使用多核编译,可以使用mach build,当然他底层还是调用的pymake
在Fx28之后Mozilla引入了united build也可以加快编译(默认开启)
禁用一些组件或者禁用debug调试也可以加快构建速度
使用VC2012+可以加快链接速度(多线程链接,VC2010只能单线程链接)
所以理论上编译器使用VC2010的,链接器使用VC2012的可以同时保证性能和构建速度,不过这个要Hacker很多Makefile,构建过程也不是很稳定
Last edit: Anonymous 2017-12-21