My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MozillaBuiltICC  
Build Mozilla Product using Intel C/C++ Compiler.
Updated Feb 9, 2012 by xunxun1...@gmail.com

If you get some ideas from my project, please quote with pcxfirefox, and this is my greatest reward. Many thanks.


How to build Mozilla Product using Intel C/C++ Compiler

This wiki page tells you some steps and tips to build Mozilla Product using Intel C/C++ Compiler.


Step 0 Prepare Build Environment

The compiler and SDKs which I use are below.

Mozilla-build Official link
Visual C/C++ 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)
Intel C/C++ Compiler 30 days Evaluation 12


Step 1 Patch start-msvc.bat

The patch is similar to it below:
--- start-msvc10.bat	Wed Jan  4 01:31:23 2012
+++ start-msvc10.bat	Wed Jan  4 01:32:29 2012
@@ -83,6 +83,17 @@
     )
 )
 
+call "D:\Program Files (x86)\Intel\Composer XE 2011 SP1\bin\ipsxe-comp-vars.bat" ia32 vs2010
+set CC=icl
+set CXX=icl
+set CC_VERSION=12.1.2.278
+set CXX_VERSION=12.1.2.278
+set LD=xilink
+set AR=xilib -NOLOGO -OUT:"$@"
+
 cd "%USERPROFILE%"
 
 "%MOZILLABUILD%\msys\bin\bash" --login -i
Of cource, you can create new file called start-icc.bat analogously.
X64 build bat is similar.

Step 2 Patch Mozilla source Makefile

diff -ruNa mozilla/config/autoconf.mk.in mozilla-icc/config/autoconf.mk.in
--- mozilla/config/autoconf.mk.in	2012-01-12 01:14:36 +0800
+++ mozilla-icc/config/autoconf.mk.in	2012-01-18 13:03:07 +0800
@@ -331,8 +331,8 @@
 MOZ_EGL_XRENDER_COMPOSITE	= @MOZ_EGL_XRENDER_COMPOSITE@
 
 WIN_TOP_SRC	= @WIN_TOP_SRC@
-AR		= @AR@
-AR_FLAGS	= @AR_FLAGS@
+AR		= xilib
+AR_FLAGS	= -NOLOGO -OUT:"$@"
 AR_EXTRACT	= @AR_EXTRACT@
 AR_LIST		= @AR_LIST@
 AR_DELETE	= @AR_DELETE@
@@ -391,8 +391,8 @@
 HOST_LDFLAGS	= @HOST_LDFLAGS@
 HOST_OPTIMIZE_FLAGS = @HOST_OPTIMIZE_FLAGS@
 HOST_NSPR_MDCPUCFG = @HOST_NSPR_MDCPUCFG@
-HOST_AR		= @HOST_AR@
-HOST_AR_FLAGS	= @HOST_AR_FLAGS@
+HOST_AR		= xilib
+HOST_AR_FLAGS	= -NOLOGO -OUT:"$@"
 HOST_LD		= @HOST_LD@
 HOST_RANLIB	= @HOST_RANLIB@
 HOST_BIN_SUFFIX	= @HOST_BIN_SUFFIX@
diff -ruNa mozilla/configure mozilla-icc/configure
--- mozilla/configure	2012-01-12 01:33:04 +0800
+++ mozilla-icc/configure	2012-01-18 12:42:59 +0800
@@ -4,6 +4,10 @@
   msyshost=1
 fi
 
+export CC=icl
+export CXX=icl
+export AR='xilib -NOLOGO -OUT:"$@"'
+export LD=xilink
 
 # Read the user's .mozconfig script.  We can't do this in
 # configure.in: autoconf puts the argument parsing code above anything
@@ -3413,8 +3417,8 @@
 #define _CRT_NONSTDC_NO_WARNINGS 1
 EOF
 
-        elif test "$_CC_MAJOR_VERSION" = "17"; then
-            _CC_SUITE=11
+        elif test "$_CC_MAJOR_VERSION" = "12"; then
+            _CC_SUITE=10
             cat >> confdefs.h <<\EOF
 #define _CRT_SECURE_NO_WARNINGS 1
 EOF
diff -ruNa mozilla/js/src/config/autoconf.mk.in mozilla-icc/js/src/config/autoconf.mk.in
--- mozilla/js/src/config/autoconf.mk.in	2012-01-12 01:14:44 +0800
+++ mozilla-icc/js/src/config/autoconf.mk.in	2012-01-18 13:07:47 +0800
@@ -157,8 +157,8 @@
 PROFILE_USE_LDFLAGS = @PROFILE_USE_LDFLAGS@
 
 WIN_TOP_SRC	= @WIN_TOP_SRC@
-AR		= @AR@
-AR_FLAGS	= @AR_FLAGS@
+AR		= xilib
+AR_FLAGS	= -NOLOGO -OUT:"$@"
 AR_EXTRACT	= @AR_EXTRACT@
 AR_LIST		= @AR_LIST@
 AR_DELETE	= @AR_DELETE@
@@ -210,8 +210,8 @@
 HOST_LDFLAGS	= @HOST_LDFLAGS@
 HOST_OPTIMIZE_FLAGS = @HOST_OPTIMIZE_FLAGS@
 HOST_NSPR_MDCPUCFG = @HOST_NSPR_MDCPUCFG@
-HOST_AR		= @HOST_AR@
-HOST_AR_FLAGS	= @HOST_AR_FLAGS@
+HOST_AR		= xilib
+HOST_AR_FLAGS	= -NOLOGO -OUT:"$@"
 HOST_LD		= @HOST_LD@
 HOST_RANLIB	= @HOST_RANLIB@
 HOST_BIN_SUFFIX	= @HOST_BIN_SUFFIX@
diff -ruNa mozilla/js/src/configure mozilla-icc/js/src/configure
--- mozilla/js/src/configure	2012-01-12 01:33:04 +0800
+++ mozilla-icc/js/src/configure	2012-01-18 12:44:24 +0800
@@ -4,6 +4,11 @@
   msyshost=1
 fi
 
+export CC=icl
+export CXX=icl
+export AR='xilib -NOLOGO -OUT:"$@"'
+export LD=xilink
+
 # Guess values for system-dependent variables and create Makefiles.
 # Generated automatically using autoconf version 2.13 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
@@ -3117,8 +3122,8 @@
 #define _CRT_NONSTDC_NO_WARNINGS 1
 EOF
 
-        elif test "$_CC_MAJOR_VERSION" = "17"; then
-            _CC_SUITE=11
+        elif test "$_CC_MAJOR_VERSION" = "12"; then
+            _CC_SUITE=10
             cat >> confdefs.h <<\EOF
 #define _CRT_SECURE_NO_WARNINGS 1
 EOF
diff -ruNa mozilla/js/src/ctypes/libffi/configure mozilla-icc/js/src/ctypes/libffi/configure
--- mozilla/js/src/ctypes/libffi/configure	2012-01-12 01:14:44 +0800
+++ mozilla-icc/js/src/ctypes/libffi/configure	2012-01-18 12:45:06 +0800
@@ -17,6 +17,12 @@
 ## -------------------- ##
 
 # Be more Bourne compatible
+
+export CC=icl
+export CXX=icl
+export AR='xilib -NOLOGO -OUT:"$@"'
+export LD=xilink
+
 DUALCASE=1; export DUALCASE # for MKS sh
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
diff -ruNa mozilla/js/src/ctypes/libffi/msvcc.sh mozilla-icc/js/src/ctypes/libffi/msvcc.sh
--- mozilla/js/src/ctypes/libffi/msvcc.sh	2012-01-12 01:14:44 +0800
+++ mozilla-icc/js/src/ctypes/libffi/msvcc.sh	2012-01-18 12:40:29 +0800
@@ -44,7 +44,7 @@
 
 args="-nologo -W3"
 md=-MD
-cl="cl"
+cl="icl"
 ml="ml"
 safeseh="-safeseh"
 output=
@@ -62,7 +62,7 @@
       shift 1
     ;;
     -m64)
-      cl="cl"   # "$MSVC/x86_amd64/cl"
+      cl="icl"   # "$MSVC/x86_amd64/cl"
       ml="ml64" # "$MSVC/x86_amd64/ml64"
       safeseh=
       shift 1
diff -ruNa mozilla/nsprpub/config/autoconf.mk.in mozilla-icc/nsprpub/config/autoconf.mk.in
--- mozilla/nsprpub/config/autoconf.mk.in	2012-01-12 01:14:58 +0800
+++ mozilla-icc/nsprpub/config/autoconf.mk.in	2012-01-18 13:17:28 +0800
@@ -56,14 +56,14 @@
 
 AS		= @AS@
 ASFLAGS		= @ASFLAGS@
-CC		= @CC@
-CCC		= @CXX@
+CC		= icl
+CCC		= icl
 NS_USE_GCC	= @GNU_CC@
 GCC_USE_GNU_LD	= @GCC_USE_GNU_LD@
 MSC_VER		= @MSC_VER@
-AR		= @AR@
+AR		= xilib -NOLOGO -OUT:"$@"
 AR_FLAGS	= @AR_FLAGS@
-LD		= @LD@
+LD		= xilink
 RANLIB		= @RANLIB@
 PERL		= @PERL@
 RC		= @RC@
diff -ruNa mozilla/nsprpub/configure mozilla-icc/nsprpub/configure
--- mozilla/nsprpub/configure	2012-01-12 01:14:58 +0800
+++ mozilla-icc/nsprpub/configure	2012-01-18 12:45:39 +0800
@@ -7,6 +7,11 @@
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 
+export CC=icl
+export CXX=icl
+export AR='xilib -NOLOGO -OUT:"$@"'
+export LD=xilink
+
 # Defaults:
 ac_help=
 ac_default_prefix=/usr/local

Step 3 Prepare .mozconfig

see VC build.
Change the section
ac_add_options --enable-optimize="-O2 -fp:precise"

Step 4 Build

Suppose you put mozilla source tree on d:\mozilla.

Open mozilla build msys environment.

cd /d/mozilla
make -f client.mk build

Step 5 Make installer

cd /d/obju
make installer

Then the installer will be in /d/obju/dist/install/sea


About Optimization Methods

The methods below can be applied in combination.

Method 1 : Build BetterPGO

1 build pgo-gen

Change .mozconfig section

ac_add_options --enable-optimize="-O2 -fp:precise -Qprof-gen -Qprof-dird:/iccpgo"
make -f client.mk build

2 generate PGO information

You can enter into d:/dist/bin, and run firefox.exe or thunderbird.exe, then run some BetterPGO tests and close it.

3 final build

Change .mozconfig section

ac_add_options --enable-optimize="-O2 -fp:precise -Qprof-use -Qprof-dird:/iccpgo"
make -f client.mk build

Method 2 : Some Intel C/C++ Compiler options

-fp:precise

Not a necessary option. But if you don't add it, js tests and sqlite will cause wrong results. So at least we should add it to js/sqlite/nsprub/security's makefile.

NOTE

It seems that other modules except js/sqlite/nsprub/security must add -fp:precise, if not, that will cause some Web shows not normal. I do not know the specific module name. So I suggest to add -fp:precise to all modules except memory/angle/image/libjpeg.

-arch:SSE2 or -arch:SSE3

Generally, all new cpu supports SSE2, but most supports SSE3 (especially Intel CPU), too.

NOTE

It's very strange that -arch:SSE3 editions can't run on some AMD CPUS which support SSE3. I suggest to use the baseline -arch:SSE2.

-Qipo

Great option, but will cause build time very very long.

-w -W0

Disable warnings. Will speed build process.

-QaxSSE2,SSE3,SSSE3,SSE4.1,SSE4.2,AVX,CORE-AVX2,CORE-AVX-I

It's useless for AMD CPU, but may improve the performance on Intel CPU. See link.

-O3

If you feel -O3 is not so safe, I suggest you use -O2 -Qftz

About bugs and patches

1 ICC PGO bug

ICC PGO has also many bugs, and will cause some linker errors when linking, so you should use no-PGO to rebuild the code in error. Then continue building.

2 Strange bugs

Sometimes, it will crash on XUL.dll (when call back mozjs or in the xpcom, depending on defferent edition). I don't know why, so you can copy xul.dll vc built to cover that icc built.
Others? Should debug it.

Others

ICC X64 build cost more time than X86 build (About 4 times).
ICC X64 build cost more memory than X86 build, you must not disable OS's Virtual Memory and must not set Virtual Memory too few.

Sign in to add a comment
Powered by Google Project Hosting