lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / intel-c-compiler.txt
blobf2c91e815495c6a46dc6d1d304549028cdd91aa9
1 AUTHOR: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
2         Daniel Baumann <daniel.baumann at panthera-systems.net>
4 DATE: 2006-11-06
6 LICENSE: GNU General Public License
8 SYNOPSIS: Installing and using the Intel C/C++ compiler with LFS.
10 PRIMARY URL:
11 http://www.linuxfromscratch.org/hints/downloads/files/intel-c-compiler.txt
13 DESCRIPTION:
14 The Intel C/C++ compiler collection (ICC) is a full featured compiler and
15 debugger suite, which is close to compatible with the GNU C/C++ compiler
16 collection (GCC). ICC is made only for Intel chips and takes advantage of
17 Intel technology, such as Hyper-Threading, more than GCC does. Software
18 compiled with ICC usually performs better than if it were compiled with GCC.
19 The performance difference can range between 2% and 40% depending on the
20 software and compiler flags. Most of the LFS base system will compile with ICC.
22 The Intel compiler is not opensource. A non-commercial Linux user license is
23 available for application developers. This license does not expire but only
24 entitles you to upgrades for one year (you may be able to renew the license).
26 A commercial license allows you to distribute packages you built with ICC,
27 and costs up to $400. Discounts are available for students.
29 If you are using ICC for personal use, to help develop ICC, the non-commercial
30 application developer license is right for you.
32 There is a PDF document describing ICC-9.0 here:
33 http://cache-www.intel.com/cd/00/00/22/23/222301_222301.pdf
35 PREREQUISITES:
36 - An Intel CPU (Intel-clones may not work).
38 - The Intel website says a PentiumII with 256MB of RAM is required to use
39   ICC-9.1.
41 - Glibc (icc is linked to /lib/ld-linux.so.2).
43 - 4GB of free space, above the LFS requirement, to be able to build DB, Bash,
44   and Perl with code profiling (they will be normal size when installed).
46 - This hint is for i86, but could be adapted for other Intel platforms.
48 HINT:
49 The homepage for the Intel compiler (application developer license) is here:
50 http://www.intel.com/cd/software/products/asmo-na/eng/compilers/clin/219856.htm
52 The ICC-9.1 compiler is compatible with gcc-4.1 and supports the newest Intel
53 CPU's.
55 To obtain the Intel compiler, and user license, go to the homepage and
56 register. You should receive an email with a URL for the ICC tarball, and a
57 user license attachment.
59 After that you should have two files (the versions may be different):
61 l_cc_c_9.1.042.tar.gz (279MB)
62 and
63 NCOM_L_CMP_CPP_NZDM-FT472MJ3.lic
65 *****************
66 Table of contents
67 *****************
68         - Installing ICC
69                 Installing ICC files
70                 Configuring ICC files
71                 Configuring system files
72         - Optimizations
73         - Building LFS packages
75 # ***************************************
76 # - INSTALLING ICC - Installing ICC files
77 # ***************************************
79 # The rpm packages for ICC are designed to install ICC to /opt. This is
80 # convienient because ICC headers can overwrite libc headers, but is
81 # inconvienient because software built with ICC will be linked to /opt. I don't
82 # like /opt because I think it's redundent. So this hint installs ICC to /usr,
83 # and configures ICC to use private header directories so that ICC will not
84 # overwrite headers from other packages. Installing ICC to /usr is also
85 # compatible with any use, whether you want to use ICC for specific software,
86 # or use ICC to build most of LFS.
88 # ICC does not currently build Glibc, so ICC must be installed after Glibc,
89 # Binutils, and GCC, are installed in the chapter 6 chroot.
91 # As a general rule, always apply GCC4 patches for packages if available.
93 # We need Cpio to unpack the ICC rpm packages. Cpio can be compiled in the
94 # chapter 6 chroot after Binutils. Follow the BLFS instructions:
95 # http://www.linuxfromscratch.org/blfs/view/svn/general/cpio.html
96 # You can rebuild Cpio with ICC later if you want.
98 # We also need the rpm2cpio script:
99 # http://www.rpm.org/tools/scripts/rpm2cpio.sh
101 # Install rpm2cpio to /usr:
103 install -v rpm2cpio.sh /usr/bin/rpm2cpio
105 # Set your ICC package version in the shell environment (you may need to
106 # modify the values for your version). This is done so that the rest of the
107 # commands in this hint can be copied and pasted:
109 export ICC_V_MAJOR=9
110 export ICC_V_MINOR=1
111 export ICC_V_PATCH=042
112 export ICC_VERSION="${ICC_V_MAJOR}.${ICC_V_MINOR}.${ICC_V_PATCH}"
114 # Unpack the Intel CC tarball and change to the data/ directory:
116 tar zxvf l_cc_c_${ICC_VERSION}.tar.gz &&
117 cd l_cc_c_${ICC_VERSION}/data/
119 # Extract the rpm file for the C/C++ compiler:
121 rpm2cpio intel-icc?????-${ICC_VERSION}*.i386.rpm | \
122         cpio --make-directories --extract --verbose &&
123 rm -vf opt/intel/cc/${ICC_VERSION}/bin/uninstall.sh &&
124 chown -vR 0:0 opt/
126 # Copy the files to /usr:
128 install -vd /usr/share/doc/icc-${ICC_VERSION} &&
129 mv -v opt/intel/cc/${ICC_VERSION}/doc /usr/share/doc/icc-${ICC_VERSION} &&
130 mv -v opt/intel/cc/${ICC_VERSION}/licenses /usr/share/doc/icc-${ICC_VERSION} &&
131 mv -v opt/intel/cc/${ICC_VERSION}/man/man1/* /usr/share/man/man1 &&
132 install -vd /usr/include/icc/ &&
133 mv -v opt/intel/cc/${ICC_VERSION}/include/* /usr/include/icc
135 # The iccvars.*sh files are shell startup/profile files, and belong in /etc:
137 mv -v opt/intel/cc/${ICC_VERSION}/bin/iccvars.*sh /etc &&
138 mv -v opt/intel/cc/${ICC_VERSION}/bin/* /usr/bin
140 # Runtime libraries should be installed to /lib:
142 mv -v opt/intel/cc/${ICC_VERSION}/lib/libirc.so /lib &&
143 mv -v opt/intel/cc/${ICC_VERSION}/lib/libsvml.so /lib &&
144 mv -v opt/intel/cc/${ICC_VERSION}/lib/libimf.so /lib
146 # The rest of the libraries can go in /usr/lib:
148 mv -v opt/intel/cc/${ICC_VERSION}/lib/locale /usr/lib/locale &&
149 mv -v opt/intel/cc/${ICC_VERSION}/lib/* /usr/lib &&
150 rm -rf opt/
152 # Extract the rpm and tar files for the ICC headers:
154 rpm2cpio intel-isubh*-${ICC_VERSION}*.i386.rpm \
155         | cpio --make-directories --extract --verbose &&
156 tar -zvxf opt/intel/cc/${ICC_VERSION}/substitute_headers/libio.tar.gz -C \
157         opt/intel/cc/${ICC_VERSION}/substitute_headers/ &&
158 chown -vR 0:0 opt/ &&
159 find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type d \
160         -exec chmod -v 755 {} \; &&
161 find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type f \
162         -exec chmod -v 644 {} \;
164 # Install the ICC headers:
166 mv -v opt/intel/cc/${ICC_VERSION}/substitute_headers/libio/* \
167         /usr/include/icc &&
168 rm -rf opt/
170 # Extract the rpm for the debugger:
172 rpm2cpio intel-iidb*-${ICC_VERSION}*.i386.rpm | \
173         cpio --make-directories --extract --verbose &&
174 rm -vf opt/intel/idb/${ICC_VERSION}/bin/uninstall.sh
175 chown -vR 0:0 opt/
177 # Install the ICC debugger, idbvars.sh belongs in /etc:
179 mv -v opt/intel/idb/${ICC_VERSION}/bin/idbvars.*sh /etc &&
180 mv -v opt/intel/idb/${ICC_VERSION}/bin/* /usr/bin &&
181 mv -v opt/intel/idb/${ICC_VERSION}/doc /usr/share/doc/idb-${ICC_VERSION} &&
182 mv -v opt/intel/idb/${ICC_VERSION}/man/man1/* /usr/share/man/man1 &&
183 rm -rf opt/
185 # ****************************************
186 # - INSTALLING ICC - Configuring ICC files
187 # ****************************************
189 # The compiler suite is installed. Now we set it up. First install the
190 # license file:
192 install -v -m444 *.lic /usr/share/doc/icc-${ICC_VERSION}/licenses/
194 # Configure the compiler:
196 sed -e \
197 "s/<installpackageid>/l_cc_c_${ICC_V_MAJOR}\.${ICC_V_MINOR}\.${ICC_V_PATCH}/" \
198         -i /usr/share/doc/icc-${ICC_VERSION}/doc/csupport
200 sed -e \
201 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
202         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
203         -e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' -i /usr/bin/icc
205 sed -e \
206 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
207         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
208         -e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' -i /usr/bin/icpc
210 sed -e \
211 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
212         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
213         -e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' \
214         -e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/iccvars.csh
216 sed -e \
217 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
218         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
219         -e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' \
220         -e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/iccvars.sh
222 source /etc/iccvars.sh
224 # If you get "bash: manpath: command not found", don't worry about it.
226 # Configure the Intel debugger:
228 sed -e \
229 "s/<installpackageid>/l_cc_c_${ICC_V_MAJOR}\.${ICC_V_MINOR}\.${ICC_V_PATCH}/" \
230         -i /usr/share/doc/idb-${ICC_VERSION}/idbsupport
232 sed -e \
233 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
234         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
235         -e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/idbvars.csh
237 sed -e \
238 "s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
239         -e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
240         -e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/idbvars.sh
242 source /etc/idbvars.sh
244 # - INSTALLING ICC - Configuring system files:
246 # ICC links programs to libgcc_s.so. On an LFS system libgcc_s.so is in
247 # /usr/lib. On some systems libgcc_s.so is in /lib. If you plan to install
248 # software built with ICC to /bin or /sbin, you should move libgcc_s.so to
249 # /lib if it is not already there (this is recommended):
251 mv -v /usr/lib/libgcc_s.so.1 /lib/ &&
252 rm -v /usr/lib/libgcc_s.so &&
253 ln -vs libgcc_s.so.1 /lib/libgcc_s.so
255 # We also need to tell ICC where to find the headers we installed to
256 # /usr/include/icc:
258 echo "-I/usr/include/icc" >> /usr/bin/icc.cfg
259 echo "-I/usr/include/icc" >> /usr/bin/icpc.cfg
260 echo "-I/usr/include/icc/c++" >> /usr/bin/icpc.cfg
262 # Now we can use the Intel compiler.
264 # Test ICC to see that it is working:
266 echo "int main () {return 0;}" > /tmp/main.c &&
267 icc -o /tmp/main /tmp/main.c &&
268 /tmp/main &&
269 rm /tmp/main{,.c}
271 # If there are no errors then it worked.
273 # You can unset these now:
275 unset ICC_VERSION ICC_V_MAJOR ICC_V_MINOR ICC_V_PATCH
277 # Now we can configure the system to use ICC.
279 # Configure a GNU autoconf site file for ICC. This makes this hint shorter,
280 # and our lives easier. GNU ./configure scripts will search for
281 # "${prefix}/share/config.site" and use it to source environment variables.
282 # Alternately you can put, and name, the "config.site" anywhere and set
283 # the CONFIG_SITE environment variable to point to it:
285 cat > /usr/share/config.site-icc << "EOF"
286 CC="icc"
287 CXX="icpc"
288 LD="xild"
289 AR="xiar"
290 LANG="en"
291 LANGUAGE="en"
292 LC_ALL="C"
295 # If you want to build most of your LFS system with ICC you should export
296 # this site configuration:
298 export CONFIG_SITE="/usr/share/config.site-icc"
300 # If you only want to use ICC for specific packages then you can use this:
302 env CONFIG_SITE="/usr/share/config.site-icc" ./configure...
304 # ***************
305 # - Optimizations
306 # ***************
308 # Now you can read the ICC man pages for more information about its features
309 # and usage.
311 # You should also look at:
312 # http://gentoo-wiki.com/HOWTO_ICC_and_Portage#CFLAGS
314 # and:
315 # http://sc.tamu.edu/help/intel/9.0/main_cls/mergedProjects/optaps_cls/whnjs.htm
317 # I scribbled some notes while reading the ICC man page, and posted them here:
318 # http://www.linuxfromscratch.org/~robert/new/icc-cflag-notes.txt
320 # We can add our optimizations to the ICC config file. This is what I use for
321 # my Prescott:
323 # The -xP optimization is just like GCC's -march=prescott:
325 echo "-xP" >> /usr/bin/icc.cfg
326 echo "-xP" >> /usr/bin/icpc.cfg
328 # Note that -axP is just like '-march=i586 -mtune=prescott'.
330 # The -fomit-frame-pointer optimization removes frame pointers from object
331 # code, and makes it perform better. Note that this option makes programs
332 # harder to debug:
334 echo "-fomit-frame-pointer" >> /usr/bin/icc.cfg
335 echo "-fomit-frame-pointer" >> /usr/bin/icpc.cfg
337 # The -mno-ieee-fp optimization disables floating-point precision. This breaks
338 # ANSI conformance but increases performance. This can break some software,
339 # if it does then add -mp to CFLAGS. Note that this option makes programs
340 # harder to debug:
342 echo "-mno-ieee-fp" >> /usr/bin/icc.cfg
343 echo "-mno-ieee-fp" >> /usr/bin/icpc.cfg
345 # The -no-prec-div optimization disables floating-point division computations.
346 # Note that the man page entry for this option is not completely correct,
347 # check google for this option. Note that this option makes programs harder
348 # to debug:
350 echo "-no-prec-div" >> /usr/bin/icc.cfg
351 echo "-no-prec-div" >> /usr/bin/icpc.cfg
353 # The -rcd enabled fast float-to-int conversions. This option breaks ANSI
354 # conformance:
356 echo "-rcd" >> /usr/bin/icc.cfg
357 echo "-rcd" >> /usr/bin/icpc.cfg
359 # This option tells ICC which GCC version to be compatable with:
361 echo "-gcc-version=410" >> /usr/bin/icc.cfg
362 echo "-gcc-version=410" >> /usr/bin/icpc.cfg
364 # Use -no-gcc to break GCC compatability. This will perform better, and some
365 # packages will need this. Libraries compiled with ICC should get -gcc
366 # added to CFLAGS, so that programs compiled with GCC can use the libraries
367 # compiled with ICC. I will provide commands to add -gcc to LFS packages,
368 # but you need to keep this in mind with BLFS packages:
370 echo "-no-gcc" >> /usr/bin/icc.cfg
371 echo "-no-gcc" >> /usr/bin/icpc.cfg
373 # Software-based Speculative Pre-computation (-ssp) performs thread based
374 # prefetching and takes advantage of hyper-threading. This option increases
375 # performance signicicantly. See google for more information. This option
376 # should not go together with -prof_gen, but -prof_use is okay. It might
377 # depend on profrun. This is 5 stage profiling:
379 -prof-gen
380 ./a.out
381 -prof-gen-sampling -prof-use
382 profrun -dcache ./a.out
383 -prof-use -ssp
385 # The newer Pentium4 cpus perform Hardware-based Speculative Pre-computation,
386 # so I have never tried to use the -ssp option.
388 # The -ansi-alias optimization will add additional optimizations but must
389 # only be used if the package adheres to the ISO C Standard. The -strict-ansi
390 # option should be used with -ansi-alias, to make sure the source comforms
391 # to ansi.
393 # Interprocedural optimizations (-ipo) is a fantastic feature which optimizes
394 # code at link time, including expanding inline functions across multiple
395 # files. This is equivilent to combining all the source code into a single
396 # file. This allows the compiler to make better judgements. This option can
397 # be very particular and error prone (at compile time).
399 # The -ipo option can take an integer argument to specify the limit of output
400 # files it can generate. By default the limit is 1. -ipo0 will allow the
401 # compiler to decide how many object files to create depending on their size.
403 # The -Ob2 optimization adds -ip, a subset of -ipo but for single file
404 # compilation, and inlines functions at the compiler's descretion. This
405 # option can be used with all code.
407 # -Ob2, -ip, and -ipo can not be used during profile generation (see below)
408 # and will cause a compiler warning if we try. If you decide not to profile
409 # your packages then you can add -ipo0 or -Ob2 to the icc.cfg and icpc.cfg
410 # files. Using -ipo0 on the command line will supersede -ip and -Ob2 in
411 # icc.cfg. If you do not plan to use profiling then you can add -ipo0 to the
412 # icc.cfg and icpc.cfg files.
414 # The -fast option enables "-O3 -ipo -static -no-prec-div -xP". Make sure
415 # your cpu works with the -xP (pentium4 sse3) optimization before using -fast.
416 # Because this optimization statically links programs I do not suggest building
417 # most packages with it. Statically linked programs do not share virtual
418 # memory, and will eventually consume all memory when most of the system is
419 # statically linked. I do suggest using -fast with programs which are freed
420 # from memory quickly and are not run often, like Bzip2.
422 # The -ipo option does not work with private static libraries, which most
423 # packages have. So -ipo has to be surgically added.
425 # In ICC the -g option will disable the default -O2 optimization, unless
426 # -O1/-O2/-O3 are used on the command line. Setting CFLAGS in the environment
427 # will remove the -g option from most packages.
429 # Packages configured with Libtool add the --with-pic configure switch. This
430 # switch will build both shared and static libraries with -fPIC. We can take
431 # advantage of this by adding -gcc beside -fPIC so that -gcc will only be
432 # added to libraries, and not the programs. There is a disadvantage too.
433 # Static libraries compiled with -fPIC will perform slightly slower, however
434 # in LFS we link almost everything dynamically, so this should not become an
435 # issue. In this hint I will provide instructions to add -gcc beside -fPIC
436 # to make shared libraries GCC compatable, but not the static libraries. If
437 # the static libraries cause issues for you, you should rebuild the package
438 # with --with-pic. This way if you compile programs statically with ICC they
439 # will perform as well as possible.
441 # Profile-guided optimizations works by first compiling a program, or library,
442 # with profile generation (-prof_gen). When that program is executed it will
443 # generate data files with details about how the program works at runtime,
444 # such as which functions are called the most and how they relate to other
445 # functions. Then the program is recompiled to use the profiling data with
446 # -prof_use. This means compiling the package twice, but also means the
447 # installed package will perform as well as possible. You do not have to do
448 # this, but I do. If you choose not to profile your packages you can skip
449 # much of the rest of this hint and simply use the config.site file as-is.
451 # Rather than resetting our CFLAGS twice for every profiled package, it's
452 # easier to use a script. Some packages use 'libtool' to build packages,
453 # and using 'make CC="icc -prof_gen"' for these packages will not work. When
454 # profiling packages I suggest reconfiguring them. Also, some packages do not
455 # use CFLAGS/CXXFLAGS for all components because the package developer may
456 # not want particular parts of the programs optimized. So it is best to modify
457 # the CC/CXX environment variables, instead of CFLAGS/CXXFLAGS, when using
458 # -prof_gen and -prof_use.
460 # The following commands will add the profiling options to a few scripts,
461 # including additional optimizations when profile data is being used:
463 cat > /usr/bin/prof_gen-env << "EOF"
464 unset CONFIG_SITE
465 export LANG="en"
466 export LANGUAGE="en"
467 export LC_ALL="C"
468 export LD="xild"
469 export AR="xiar"
470 export CFLAGS="-O2"
471 export CXXFLAGS="-O2"
472 export CC="icc -prof_gen -prof_dir=$(pwd)"
473 export CXX="icpc -prof_gen -prof_dir=$(pwd)"
474 "$@"
476 chmod -v +x /usr/bin/prof_gen-env
478 cat > /usr/bin/prof_use-env << "EOF"
479 unset CONFIG_SITE
480 export LANG="en"
481 export LANGUAGE="en"
482 export LC_ALL="C"
483 export LD="xild"
484 export AR="xiar"
485 export CFLAGS="-O2 -ipo0"
486 export CXXFLAGS="-O2 -ipo0"
487 export CC="icc -prof_use -prof_dir=$(pwd)"
488 export CXX="icpc -prof_use -prof_dir=$(pwd)"
489 nice -n 19 "$@"
491 chmod -v +x /usr/bin/prof_use-env
493 cat > /usr/bin/prof_use-fast-env << "EOF"
494 unset CONFIG_SITE
495 export LANG="en"
496 export LANGUAGE="en"
497 export LC_ALL="C"
498 export LD="xild"
499 export AR="xiar"
500 export CFLAGS="-O3 -fast -ipo0"
501 export CXXFLAGS="-O3 -fast -ipo0"
502 export CC="icc -prof_use -prof_dir=$(pwd)"
503 export CXX="icpc -prof_use -prof_dir=$(pwd)"
504 nice -n 19 "$@"
506 chmod -v +x /usr/bin/prof_use-fast-env
508 # For some reason most GNU ./configure scripts do not pass environment set
509 # AR to Makefile. We need to use Intel's AR, not GNU's. So we need to create
510 # a 'make' wrapper script which will always override the AR variable. I added
511 # LD for good measure:
513 cat > /usr/bin/icc-make << "EOF"
514 nice make AR="xiar" LD="xild" "$@"
516 chmod -v +x /usr/bin/icc-make
518 # Use 'icc-make' instead of 'make' whenever you are compiling with ICC.
520 # ***********************
521 # - Building LFS packages
522 # ***********************
524 # To build packages without profiling then './configure && icc-make'. The
525 # /usr/share/config.site-icc file will be used. You may want to add
526 # "-O2 -ipo0" to CFLAGS and CXXFLAGS in /usr/share/config.site-icc:
528 echo 'CFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc
529 echo 'CXXFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc
531 # Some packages, such as Perl and Bash, generate large amounts of profiling
532 # data. You can expect these packages to use 4GB of storage, and more, during
533 # the build. Packages which generate especially large amounts of profiling
534 # data also take a lot of system resources to process this data.
536 # Some packages do not have testsuites, so we can not easily generate profiling
537 # data for them. With small packages we can manually run common commands to
538 # generating the profiling data.
540 # Beware I have frozen my system while computing profiling data (with Perl).
541 # Since then I began using 'nice -n 19' when using -prof_use, and have not
542 # frozen my system since. You can renice your whole login... first find your
543 # process ID for your LFS chroot with 'ps a | grep /tools/bin/bash', and then
544 # 'renice 10 -p ???'.
546 # The truely best way to generate profiling data is to install the programs.
547 # This way the program will be profiled against your specific system and uses.
548 # If you wish to do this, I'll let you modify the following instructions. You
549 # will need to store the profiling data in a dedicated directory, like
550 # /home/icc/prof_data/coreutils, reboot the system and run it normally for a
551 # few days, then rebuild with make-icc-prof_use (-prof_use). I have never
552 # tried this.
554 # In general, to profile packages, we would do something like this:
556 prof_gen-env ./configure &&
557 icc-make &&
558 icc-make check &&
559 icc-make distclean &&
560 prof_use-env ./configure &&
561 icc-make &&
562 icc-make install
564 # Packages (in the "Linux From Scratch - Version SVN-20061029" order):
566 # You should unset environment CFLAGS/CXXFLAGS, if you set them, so that
567 # ICC will use the optimizations in the icc config files.
569 # You should also run the testsuies whether you are using profiling or not.
571 # - Berkeley DB (and TCL)
572 # DB compiles with ICC, but the testsuite does not work without a full
573 # installation of TCL. Berkeley DB's testsuite takes about 150 SBU (many hours)
574 # to complete. If you are not prepared to do that then simply install Berkeley
575 # DB without profiling, like the LFS book does. These tests will also use
576 # about 4GB of space.
578 # If you want to profile Berkeley DB then install TCL from the BLFS book.
579 # Berkeley DB and TCL contain libraries, so you may want to add the -gcc
580 # option. I built my system using ICC as much as possible, so I did not build
581 # these libraries with -gcc because I have no compatability to worry about.
582 # TCL can also be profiled with ICC. If you want GCC compatability with TCL's
583 # libraries then run this command:
585 sed -e 's/-.*PIC/& -gcc /' -i unix/configure
587 # To profile TCL (make sure the ./configure --options are the same as in the
588 # BLFS book):
590 cd unix &&
591 prof_gen-env ./configure --prefix=/usr --enable-threads &&
592 icc-make &&
593 icc-make test
595 # TCL will fail several tests because networking does not work, and will also
596 # complain about the profiling data files being left behind, that's fine. Then
597 # rebuild TCL to use the profile data and -ipo:
599 icc-make distclean &&
600 prof_use-env ./configure --prefix=/usr --enable-threads &&
601 icc-make
603 # You can 'make test' again if you're paranoid. Then install TCL.
605 # We need GCC compatability with Berkeley DB libraries for Man-DB:
607 sed -e 's/-.*PIC/& -gcc /' -i dist/configure
609 # Build Berkeley DB just like TCL, with the prof_gen-env and prof_use-env
610 # scripts. Also add TCL and tests to the configure command:
612 cd build_unix &&
613 prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \
614         --enable-tcl --with-tcl=/usr/lib --enable-test &&
615 icc-make
617 # Then to run the testsuite open the tclsh shell:
619 tclsh
621 # At the % promt run the tests (this will take hours):
623 source ../test/test.tcl
624 run_parallel 5 run_std
625 exit
627 # Then clean Berkeley DB and rebuild:
629 icc-make realclean &&
630 prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \
631         --enable-tcl --with-tcl=/usr/lib &&
632 icc-make
634 # Then install Berkeley DB.
636 # - E2fsprogs
637 # E2fsprogs does not build properly with ICC. Build E2fsprogs with GCC:
639 env -u CONFIG_SITE ../configure...
640 make
642 # - Coreutils
643 # Build Coreutils with profiling:
645 prof_gen-env ./configure --prefix=/usr &&
646 icc-make
648 # Then run the testsuite, distclean, and rebuild with the profiling
649 # information:
651 prof_use-env ./configure --prefix=/usr &&
652 icc-make
654 # Then install Coreutils.
656 # - Iana-Etc has nothing to compile.
658 # - M4
659 # M4 is typical. Build and install it just like Coreutils.
661 # - Bison:
662 # Bison is a typical build, like M4.
664 # - Ncurses
665 # Ncurses builds with ICC, but I had serious issues with Bash. So for now
666 # I suggest building Ncurses with GCC:
668 env -u CONFIG_SITE ./configure...
670 # - Procps does not compile with ICC. It will compile with GCC by default.
671 # If you really want a pure ICC system, you can use the Procps utilities from
672 # Busybox.
674 # - Sed
675 # I compile Sed with -fast. If you don't want to, and/or you are not using
676 # the -xP optimization, then build Sed like Coreutils. To build Sed with
677 # -fast:
679 prof_gen-env ./configure...
680 icc-make
681 icc-make check
682 icc-make distclean
683 prof_use-fast-env ./configure...
684 icc-make
686 # Then install Sed.
688 # - Libtool
689 # 'libtool' itself is a script, but the package includes a library. To add
690 # GCC compatability (this is optional):
692 sed -e 's/^CFLAGS =/& -gcc/' -i libltdl/Makefile.in
694 # Then profile Libtool like Coreutils, but use 'make clean' instead of
695 # 'distclean'.
697 # - Perl
698 # Since I started using AR="xiar" I have not been able to get Perl to build
699 # with ICC. Even without AR="xiar" Perl will fail a couple tests. For these
700 # reasons I suggest building Perl with GCC. Just build Perl normally, it will
701 # ignore the config.site file.
703 # - Readline
704 # Readline is a library and you may want to add -gcc (I don't):
706 sed -e 's/^CFLAGS =/& -gcc/' -i {,shlib/}Makefile.in
708 # Readline does not have a testsuite, so it can not easily be profiled. Build
709 # it normally and it will use the config.site file to use ICC. Remember to
710 # use 'icc-make'.
712 # - Zlib can compile with ICC, but X11 will not be able to link to it even if
713 # -gcc is used, so I do not suggest it. To build Zlib with GCC:
715 env -u CONFIG_SITE ./configure...
717 # - Autoconf and Automake are perl scripts.
719 # - Bash
720 # Bash-3.1 can compile with ICC, and bash-3.2 does not. I do not suggest
721 # using Bash-3.2 because I had bad expirence with it (it's screwy).
722 # Bash-3.1 can be built with profiling, but not with -ipo. Remember to use
723 # the bash-3.1 upstream patch. The Bash sources directory will grow to almost
724 # 3GB with profiling data. Build Bash like this:
726 prof_gen-env ./configure...
727 icc-make
728 icc-make tests
729 icc-make distclean
730 nice -n 19 env -u CONFIG_SITE LANG="en" LANGUAGE="en" LC_ALL="C" \
731         LD="xild" AR="xiar" CC="icc -prof_use -prof_dir=$(pwd)" \
732         ./configure...
733 icc-make
735 # Then install Bash.
737 # - Bzip2
738 # I'm building bzip2.so,a with -ipo, and bzip2 and bzip2recover with -fast.
739 # If you are not using -xP then change -fast to -ipo0.
741 icc-make CC=icc CFLAGS="-prof_gen -prof_dir=$(pwd) \
742         -D_FILE_OFFSET_BITS=64 -O2" \
743         AR=xiar LD=xild -f Makefile-libbz2_so &&
744 icc-make clean &&
745 icc-make CC=icc CFLAGS="-prof_gen -prof_dir=$(pwd) \
746         -D_FILE_OFFSET_BITS=64 -O2" \
747                 AR=xiar LD=xild
749 # The bzip2 testsuite tests the bzip2 which has libbz2.a linked to it, so
750 # the libbz2.so shared libraries doesn't get tested and doesn't generate
751 # profiling data. We can do this ourselves:
753 dd if=/dev/urandom of=urandom.file bs=1M count=17
754 env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared urandom.file
755 env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d urandom.file.bz2
756 cat CHANGES LICENSE bzip2 | \
757         env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -4 -c > non-random.bz2
758 env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d non-random.bz2
759 env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared --help
761 # Then rebuild Bzip2 with the profiling data:
763 icc-make clean &&
764 icc-make -f Makefile-libbz2_so clean &&
765 icc-make CC=icc CFLAGS="-prof_use -prof_dir=$(pwd) -O -gcc -ipo0 -O2 \
766         -D_FILE_OFFSET_BITS=64" AR=xiar LD=xild -f Makefile-libbz2_so &&
767 icc-make clean &&
768 icc-make CC=icc CFLAGS="-prof_use -prof_dir=$(pwd) -D_FILE_OFFSET_BITS=64 \
769         -ipo0 -fast" AR=xiar LD=xild
771 # Then when installing bzip2, do not install the 'bzip2-shared' version,
772 # install the statically linked (with -fast) 'bzip2' file instead.
774 # - Diffutils does not have a testsuite. You can build it with ICC the way the
775 # LFS book builds Diffutils. Remember to use 'icc-make'.
777 # - File
778 # File builds with ICC, and does not have a testsuite, just like Diffutils.
780 # - Findutils
781 # Findutils can be compiled with ICC profiling, just like Coreutils or M4.
782 # I compile Findutils with -fast because 'find' and 'locate' usually do
783 # intense operations and don't stay in memory after. To build Findutils with
784 # -fast:
786 prof_gen-env ./configure...
787 icc-make
788 icc-make check
789 icc-make distclean
790 prof_use-fast-env ./configure...
791 icc-make
793 # Then install Findutils.
795 # - Flex
796 # Build and install Flex typically, like Coreutils and M4.
798 # - Grub does not compile with ICC:
800 env -u CONFIG_SITE ./configure...
802 # - Gawk
803 # Build and install Gawk typically, like Flex. I used -fast with Gawk, via
804 # prof_use-fast-env.
806 sed -e 's/CFLAGS =/& -fast/' -i {,awklib/}Makefile &&
807 make-icc-prof_use
809 # Then install Gawk.
811 # - Gettext
812 # Gettext contains libraries, so you may want to add -gcc (I don't):
814 find gettext-runtime/ -name Makefile.in \
815         -exec sed -e 's/^CFLAGS =/& -gcc/' -i {} \;
817 # I couldn't get Gettext to build with -ipo, but it builds with profiling.
818 # After 'make distclean':
820 nice -n 19 env -u CONFIG_SITE LANG="en" LANGUAGE="en" LC_ALL="C" \
821         LD="xild" AR="xiar" CC="icc -prof_use -prof_dir=$(pwd)" ./configure..
823 # - Grep
824 # Build and install Grep typically. I used -fast for Grep too.
826 # - Groff
827 # Groff does not build with -ipo, and does not have a testsuite. Build Groff
828 # like this:
830 env -u CONFIG_SITE CC="icc" CXX="icpc" LD="xild" AR="xiar" \
831         LANG="en" LANGUAGE="en" LC_ALL="C" ...
833 # Remember to use 'icc-make'.
835 # - Gzip
836 # Gzip doesn't have a testsuite, but we can mimick one:
838 dd if=/dev/urandom of=urandom.file bs=2M count=10
839 ./gzip -9 urandom.file
840 ./gzip -d urandom.file.gz
841 cat AUTHORS README README-alpha ChangeLog | ./gzip -4 -c > non-random.gz
842 ./gzip -d non-random.gz
844 # I build Gzip with -fast too.
846 # - Inetutils
847 # Inetutils does not have a testsuite but will compile with ICC.
849 # - Iproute2
850 # Iproute2 needs the -gcc option, and does not have a testsuite:
852 icc-make SBINDIR=/sbin CC="icc -gcc" &&
853 icc-make SBINDIR=/sbin CC="icc -gcc" install
855 # - Kdb
856 # Kbd does not have a testsuite:
858 icc-make CC="icc"
860 # - Less
861 # Less does not have a testsuite. Configure and build it normally.
863 # - Make
864 # Build and install Make typically.
866 # - Man-DB
867 # Man-DB does not have a testsuite. Configure and build it normally.
869 # - Mktemp
870 # Mktemp does not have a testsuite, but we can simulate one:
872 ./mktemp --help
873 ./mktemp -V
874 ./mktemp -p . && ./mktemp -p . XXXXXXXX
875 ./mktemp -p . -d && ./mktemp -p . -d XXXXXXXX
877 # You can build Mktemp with -fast if you like.
879 # - Module-init-tools
880 # I suggest you use this patch to dynamically link insmod:
881 # http://www.linuxfromscratch.org/patches/downloads/module-init-tools/
882 #       module-init-tools-3.2.2-nostatic-1.patch
884 # Run the Module-init-tools tests like this:
886 prof_gen-env ./configure &&
887 prof_gen-env icc-make check &&
888 icc-make distclean
890 # Then rebuild with 'prof_use-env'.
892 # - Patch
893 # Patch does not have a testsuite. Build and install it normally.
895 # - Psmisc
896 # Psmisc does not have a testsuite. Build and install it normally.
898 # - Shadow
899 # Shadow does not have a testsuite. Build and install it normally.
901 # - Sysklogd
902 # Sysklogd does not have a testsuite. Build Sysklogd with ICC like this:
904 icc-make CC="icc -ipo0"
906 # - Sysvinit
907 # Sysvinit does not have a testsuite. Build Sysvinit with ICC like this:
909 icc-make -C src CC="icc -ipo0"
911 # - Tar
912 # Tar can be built typically, like Coreutils.
914 # - Texinfo
915 # Texinfo can be built typically, like Coreutils.
917 # - Udev does not compile with ICC.
919 # - Util-linux does not compile with ICC.
921 # - Vim
922 # Vim can be built typically. Vim's testsuite will almost certainly screw up
923 # your terminal. Pipe the output to a log, or /dev/null:
925 make test 2>&1>/dev/null
927 # Opening and reading the log can also screw up your terminal.
929 # After LFS is installed add the environment files to /etc/profile:
931 echo "source /etc/idbvars.sh" >> /etc/profile
932 echo "source /etc/iccvars.sh" >> /etc/profile
933 echo 'export CONFIG_SITE="/usr/share/config.site-icc"' >> /etc/profile
934 source /etc/profile
936 # There is a project to compile the Linux kernel with ICC:
938 # http://www.pyrillion.org/linuxkernelpatch.html
940 # But I couldn't get it to work.
942 # Your system should now be running like lightning :-)
944 # Beyond LFS packages which compile with ICC:
946 # - OpenSSL
947 # I couldn't get OpenSSL to compile with 'xiar'.
949 # - OpenSSH
950 # OpenSSH can compile with profiling, but has a couple issues. First the
951 # 'optreset' Glibc function doesn't resolve, but we can use the 'optreset'
952 # included with OpenSSH:
954 prof_gen-env env ac_cv_have_getopt_optreset=no ./configure...
956 # The other issue is with 'ld' not resolving symbols from the Glibc
957 # library, but we can 'icc' instead:
959 make LD=icc AR=xiar
961 # - LibPNG
962 # LibPNG can compile with ICC, but X11 won't be able to use it:
964 env -u CONFIG_SITE ./configure...
966 # - Freetype doesn't compile with profiling, but can compile with ICC.
968 # - Expat doesn't compile with profiling, but can compile with ICC.
970 # - Fontconfig can compile with ICC profiling.
972 # - Wget
973 # Wget will compile with ICC but has weird buggy behaviour, so I suggest
974 # building Wget with GCC:
976 env -u CONFIG_SITE ./configure...
978 # - Pkg-config
979 # Pkg-config will build with profiling, like Coreutils.
981 # - Xorg
982 # Don't build Xorg with ICC, its not well supported. Use:
984 env -u CONFIG_SITE ../build.sh...
986 # Jpeg-6b can compile with ICC profiling. Add -gcc to CFLAGS and because this
987 # is a library.
989 # LCMS can compile with ICC profiling. Add -gcc to CFLAGS because of the
990 # library.
992 # LibMNG can compile with ICC.
994 icc-make CC=icc CFLAGS="$ICC_CFLAGS -gcc"
996 # QT supports ICC.
997 # Add "-platform linux-icc -thread" to the ./configure command.
999 # Pkgconfig can compile with ICC profiling.
1001 # Glib2 can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1003 # Libogg can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1005 # Libvorbis does not compile with ICC.
1007 # Alsa-lib doesn't compile with profiling, but does compile with ICC.
1009 # Alsa-utils can compile with ICC profiling.
1011 # Audiofile can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1013 # Libmad can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1015 # Arts supports ICC, but the newest version of ICC does not build the latest
1016 # stable release of Arts. So, for now, it doesn't work. I emailed KDE about it,
1017 # after trying to build an Arts snapshot.
1019 # Libart_lgpl does not compile with ICC.
1021 # Wget can compile with ICC profiling.
1023 # Libxml2 can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1025 # Libxslt can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
1027 # KDE does not compile with ICC.
1029 # Zip compiles with ICC:
1031 sed -e 's|gcc|icc|g' -i unix/Makefile
1033 # And use "generic_icc" as the make target.
1035 # Unzip compiles with ICC. Run this after applying the patches:
1037 sed -e 's|gcc|icc|g' -i unix/Makefile
1039 # Cpio can compile with ICC profiling.
1041 # Tcsh can compile with ICC profiling.
1043 # GnuPG can compile with ICC profiling.
1045 # LibIDL can compile with ICC profiling.
1047 # Others that compile with ICC:
1049 # Glib
1050 # Gtk
1051 # Pango
1052 # Atk
1053 # Gtk2
1054 # Libogg
1055 # Libxml
1056 # Libxst
1057 # Audiofile
1058 # Libmad
1059 # Which
1060 # GnuPG
1061 # Cdparanoia
1062 # Libungif
1063 # Giflib
1064 # Imlib2
1065 # Aalib
1066 # SDL
1067 # Libdvdcs
1068 # Libdvdread
1069 # Xvidcore
1070 # Lzo
1072 # Lame
1073 # If Lame is compiled with ICC it will cause problems with other packages, like
1074 # FFmpeg, which try to link to libmp3lame. This package should be compiled with
1075 # GCC.
1077 # Xine-lib
1078 # Popt
1079 # Libao
1080 # Flac123
1081 # Wget
1082 # Cvs
1083 # Ncftp
1084 # Subversion
1085 # Ntp
1086 # Lynx
1087 # Bind-utils
1088 # Vorbis-tools
1089 # Mpg123
1091 # For Mpg123 do:
1093 sed -e 's at gcc@/opt/bin/icc at g' -i Makefile
1095 # LibIDL
1097 # Vorbisgain
1098 # Libaal
1099 # Reiser4progs
1100 # Cdrtools
1101 # Add "CC=/opt/bin/icc" to the make command.
1103 # Irssi
1105 # And more...
1107 # ICC has its own Prelink program... check the man pages.
1109 ACKNOWLEDGMENTS:
1110         * Thanks to Daniel Baumann for the original hint.
1111         * Thanks to Gentoo for their wiki page:
1112                 http://gentoo-wiki.com/HOWTO_ICC_and_Portage
1114 CHANGELOG:
1115 [2005-06-25]
1116         * Adopted hint.
1117 [2005-06-26]
1118         * Added more supported packages.
1119 [2005-07-04]
1120         * It can reboot now.
1121 [2005-12-08]
1122         * New Intel CC version.
1123         * New Cpio security patch.
1124         * Point Cpio to the correct location of rmt in /tools.
1125         * Use icpc for CXX.
1126         * Several more packages compile now.
1127         * Added instructions to profile code.
1128         * Added -gcc for Iproute2.
1129 [2006-05-19]
1130         * Run 'make check' after building with prof_gen, to generate profiling data.
1131 [2006-05-22]
1132         * Added notes for the -ipo option.
1133         * Added warning about Perl's large amount of generated profiling data.
1134         * Bash may compile with ICC now.
1135         * Fixed up the bzip2 instructions a bit.
1136         * Added note about Diffutils and File's lack of testsuite.
1137 [2006-06-24]
1138         * Bump to icc-9.1.
1139         * Use some shell variables for icc version to make it easier for users
1140           who are using a different icc version.
1141         * Add sed commands for -ipo.
1142         * Make a config.site for ICC.
1143         * Added make scripts for code profiling, to make things easier.
1144         * Add ICC_CFLAGS to the ICC config file, to make things easier.
1145         * Spell checked.
1146 [2006-11-06]
1147         * Bump to ICC-9.1.042.
1148         * Added more uses for the -fast option, and other options.
1149         * Bumped to LFS-SVN-20061021
1150         * Static libraries can be built with -ipo, but only works if AR=xiar
1151         * Added icc-make so xiar (AR) is used.