Chinaunix首页 | 论坛 | 博客
  • 博客访问: 115528
  • 博文数量: 32
  • 博客积分: 2067
  • 博客等级: 大尉
  • 技术积分: 383
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-08 07:47
文章分类

全部博文(32)

文章存档

2011年(1)

2010年(14)

2009年(17)

我的朋友

分类: LINUX

2010-05-05 12:45:09

icc是intel推出的一款c/c++编译器,也是最成功的商业编译器之一,同时也是和gcc最贴近的编译器,据说icc和gcc的开发者有很多合作
在intel ia平台上icc有着无与伦比的速度优势
icc和gcc可谓一时瑜亮,在数学运算上icc生成的二进制文件明显快了很多,而gcc在移植性上更胜一筹

但根据我自己的粗略测试,用来编译firefox的话icc-11.1和gcc-4.5 PGO优化启动和运行速度相差不大,在sunspider和peackeeper测试icc稍高,但都只相差1%,基本可以视之为误差.
估计是firefox的数学运算量比较小,而且gcc近年来有了很大提高了


参考我前面的一篇blog:
http://blog.chinaunix.net/u3/96229/showart.php?id=2179108
arch论坛的讨论:
intel的官方网站:

icc非商业版下载(免费):

安装比较简单,但需要libstdc++5,aptitude install libstdc++5
我把它装到$HOME下了:
运行(我的是32位):
source ~/intel/Compiler/11.1/072/tbb/bin/tbbvars.sh ia32
source ~/intel/Compiler/11.1/072/bin/iccvars.sh ia32
或者把这两句加入~/.bashrc

打个patch:
cat > ff-icc.patch << EOF
diff -Nur ./js/ctypes/libffi/src/x86/ffi64.c ./js/ctypes/libffi/src/x86/ffi64.c
--- ./js/ctypes/libffi/src/x86/ffi64.c  2010-03-16 10:55:18.000000000 +0100
+++ ./js/ctypes/libffi/src/x86/ffi64.c  2010-03-30 16:15:43.000000000 +0200
@@ -36,6 +36,8 @@
 #define MAX_GPR_REGS 6
 #define MAX_SSE_REGS 8

+typedef struct { int64_t m[2]; } __int128_t;
+
 struct register_args
 {
   /* Registers for argument passing.  */
@@ -415,10 +417,12 @@
                  break;
                case X86_64_SSE_CLASS:
                case X86_64_SSEDF_CLASS:
-                 reg_args->sse[ssecount++] = *(UINT64 *) a;
+                 reg_args->sse[ssecount++].m[0] = *(UINT64 *) a;
+                 reg_args->sse[ssecount++].m[1] = 0;
                  break;
                case X86_64_SSESF_CLASS:
-                 reg_args->sse[ssecount++] = *(UINT32 *) a;
+                 reg_args->sse[ssecount++].m[0] = *(UINT32 *) a;
+                 reg_args->sse[ssecount++].m[1] = 0;
                  break;
                default:
                  abort();
diff -Nur ./xpcom/ds/nsMathUtils.h ./xpcom/ds/nsMathUtils.h
--- ./xpcom/ds/nsMathUtils.h    2010-03-16 10:57:23.000000000 +0100
+++ ./xpcom/ds/nsMathUtils.h    2010-03-30 16:17:38.000000000 +0200
@@ -155,7 +155,7 @@
  */
 inline NS_HIDDEN_(double) NS_hypot(double x, double y)
 {
-#if __GNUC__ >= 4
+#if (__GNUC__ >= 4) && !__INTEL_COMPILER
     return __builtin_hypot(x, y);
 #elif defined _WIN32
     return _hypot(x, y);
diff -Nur ./modules/libpr0n/encoders/png/nsPNGEncoder.cpp ./modules/libpr0n/encoders/png/nsPNGEncoder.cpp
--- ./modules/libpr0n/encoders/png/nsPNGEncoder.cpp     2010-03-16 10:56:46.000000000 +0100
+++ ./modules/libpr0n/encoders/png/nsPNGEncoder.cpp     2010-03-30 18:35:43.000000000 +0200
@@ -134,8 +134,9 @@
   }

   // initialize
+  // changed png_voidp_NULL -> 0, due to
   mPNG = png_create_write_struct(PNG_LIBPNG_VER_STRING,
-                                 png_voidp_NULL,
+                                 0,
                                  ErrorCallback,
                                  ErrorCallback);
   if (! mPNG)
EOF

cd到firefox-3.7a4的源码目录
vim .mozconfig
写入:

ac_add_options --enable-application=browser
mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --prefix=/home/stesen/tools/ff-icc
ac_add_options --with-system-nss --with-system-jpeg --with-pthreads --with-system-zlib
ac_add_options --with-system-bz2 --with-system-hunspell
ac_add_options --with-system-sqlite --with-system-nspr
ac_add_options --disable-installer --disable-updater
ac_add_options --enable-official-branding
ac_add_options --enable-startup-notification
ac_add_options --disable-gnomeui --disable-gnomevfs
ac_add_options --disable-necko-wifi
ac_add_options --disable-xprint
ac_add_options --disable-xinerama
ac_add_options --disable-pedantic --enable-jemalloc --enable-xterm-updates
ac_add_options --enable-optimize --disable-debug --disable-tests
ac_add_options --enable-strip --enable-install-strip
ac_add_options --disable-tests
ac_add_options --enable-cpp-rtti
ac_add_options --disable-crashreporter --disable-parental-controls 
ac_add_options --disable-printing
ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --enable-places --enable-svg --enable-pango --enable-canvas
ac_add_options --enable-smil --disable-java-xpcom
ac_add_options --enable-canvas3d
ac_add_options --disable-safe-browsing
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-opt
$(MOZ_OBJDIR)/_profile/pgo/profileserver.py
export BUILD_OFFICIAL=1
export MOZILLA_OFFICIAL=1
mk_add_options BUILD_OFFICIAL=1
mk_add_options MOZILLA_OFFICIAL=1

然后:
patch -Np1 -i ../ff-icc.patch
make -f client.mk configure
CC=icc CXX=icpc CFLAGS="-fast" CXXFLAGS="-fast" AR=xiar make -f client.mk build
CC=icc CXX=icpc CFLAGS="-fast" CXXFLAGS="-fast" AR=xiar make -f client.mk install

fast即“-xT -O3 -ipo -no-prec-div -static".-xT表明使用最新的Core 2微架构处理器提供的指令.
阅读(874) | 评论(0) | 转发(0) |
0

上一篇:gcc-4.5.0 build脚本

下一篇:urxvt-256-build脚本

给主人留下些什么吧!~~