r1066 - trunk

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Sat Nov 11 15:18:05 PST 2006


Author: tushar
Date: 2006-11-11 16:18:05 -0700 (Sat, 11 Nov 2006)
New Revision: 1066

Modified:
   trunk/intel-c-compiler.txt
Log:
Updated: intel-c-compiler

Modified: trunk/intel-c-compiler.txt
===================================================================
--- trunk/intel-c-compiler.txt	2006-11-11 23:15:45 UTC (rev 1065)
+++ trunk/intel-c-compiler.txt	2006-11-11 23:18:05 UTC (rev 1066)
@@ -1,462 +1,988 @@
 AUTHOR:	Robert Connolly <robert at linuxfromscratch dot org> (ashes)
 	Daniel Baumann <daniel.baumann at panthera-systems.net>
 
-DATE: 2006-05-22
+DATE: 2006-11-06
 
 LICENSE: GNU General Public License
 
-SYNOPSIS: How to build LFS with the Intel C/C++ compiler and code profiling.
+SYNOPSIS: Installing and using the Intel C/C++ compiler with LFS.
 
-PRIMARY URI:
+PRIMARY URL:
 http://www.linuxfromscratch.org/hints/downloads/files/intel-c-compiler.txt
 
 DESCRIPTION:
-How to install the Intel C/C++ Compiler for your LFS-system.
+The Intel C/C++ compiler collection (ICC) is a full featured compiler and
+debugger suite, which is close to compatible with the GNU C/C++ compiler
+collection (GCC). ICC is made only for Intel chips and takes advantage of
+Intel technology, such as Hyper-Threading, more than GCC does. Software
+compiled with ICC usually performs better than if it were compiled with GCC.
+The performance difference can range between 2% and 40% depending on the
+software and compiler flags. Most of the LFS base system will compile with ICC.
 
-PREREQUISITES:
-An Intel CPU (Intel-clones/AMD may or may not work).
-Glibc (icc is linked to /lib/ld-linux.so.2).
+The Intel compiler is not opensource. A non-commercial Linux user license is
+available for application developers. This license does not expire but only
+entitles you to upgrades for one year (you may be able to renew the license).
 
-HINT:
-The Intel C/C++ compiler collection (ICC) is a full featured compiler and
-debugger suite, which is close to compatable with the GNU C/C++ compiler
-collection (GCC). ICC is made only for Intel chips, and takes advantage of
-Intel technology, such as Hyper-Threading, moreso than GCC does. Software
-compiled with ICC is expected to perform better than if it were compiled with
-GCC. Because GCC is much more tested than ICC, ICC may produce less stable
-programs than GCC would with some packages. Not all packages will build with
-ICC, such as X11; maybe they will in the future.
+A commercial license allows you to distribute packages you built with ICC,
+and costs up to $400. Discounts are available for students.
 
-The homepage for the Intel compiler is here:
-http://www.intel.com/software/products/compilers/clin/
+If you are using ICC for personal use, to help develop ICC, the non-commercial
+application developer license is right for you.
 
-You should also see:
-http://gentoo-wiki.com/HOWTO_ICC_and_Portage
+There is a PDF document describing ICC-9.0 here:
+http://cache-www.intel.com/cd/00/00/22/23/222301_222301.pdf
 
-This compiler is not opensource.
+PREREQUISITES:
+- An Intel CPU (Intel-clones may not work).
 
-This hint will give instructions to build supported software with ICC, so that
-as much as possible is using it. ICC will only be installed in chapter 6 since
-we will still need GCC for some packages. You can choose to install ICC without
-using it to build the LFS system, or build just some packages, it's upto you.
-The main reason for using ICC is for performance, so intructions are also
-provided to enable profiling; this means compiling packages twice, but they
-should run a bit faster. The difference between runtimes of a program compiled
-with GCC, compared to ICC with profiling, varies between 2% and 40%.
+- The Intel website says a PentiumII with 256MB of RAM is required to use
+  ICC-9.1.
 
-For even more performance, also see the prelink.txt hint, the optimization.txt
-hint (for GCC), the reiser4-on-2.6.txt hint, and (for GCC):
+- Glibc (icc is linked to /lib/ld-linux.so.2).
 
-http://www.rocklinux.net/people/clifford/ccbench/
-http://blaze.topside.org/~ashes/gcc4/ccbench-20051119.tar.bz2 (for gcc4)
+- 4GB of free space, above the LFS requirement, to be able to build DB, Bash,
+  and Perl with code profiling (they will be normal size when installed).
 
-Intel's compiler is only free of charge for non-commercial use. If that is what
-you want then go here:
+- This hint is for i86, but could be adapted for other Intel platforms.
 
-http://www.intel.com/software/products/compilers/clin/noncom.htm
+HINT:
+The homepage for the Intel compiler (application developer license) is here:
+http://www.intel.com/cd/software/products/asmo-na/eng/compilers/clin/219856.htm
 
-And follow the instructions so that you will be emailed a license file. The
-email will also give you a download location for the compressed tarball.
+The ICC-9.1 compiler is compatible with gcc-4.1 and supports the newest Intel
+CPU's.
 
-After that you should have two files (the numbers may be different):
+To obtain the Intel compiler, and user license, go to the homepage and
+register. You should receive an email with a URL for the ICC tarball, and a
+user license attachment.
 
-l_cc_p_9.0.021.tar.gz
+After that you should have two files (the versions may be different):
+
+l_cc_c_9.1.042.tar.gz (279MB)
 and
-noncommercial_cpp_l_N4R8-B2RV9P4B.lic
+NCOM_L_CMP_CPP_NZDM-FT472MJ3.lic
 
-# INSTALLATION (Tested on LFS-SVN-20051127):
+*****************
+Table of contents
+*****************
+	- Installing ICC
+		Installing ICC files
+		Configuring ICC files
+		Configuring system files
+	- Optimizations
+	- Building LFS packages
 
-# At the end of chaper 5 we will need to install Cpio, and rpm2cpio.
+# ***************************************
+# - INSTALLING ICC - Installing ICC files
+# ***************************************
 
-# Get: ftp://ftp.gnu.org/pub/gnu/cpio/cpio-2.6.tar.gz
-# And: http://www.linuxfromscratch.org/patches/downloads/cpio/\
-#	cpio-2.6-security_fixes-1.patch
+# The rpm packages for ICC are designed to install ICC to /opt. This is
+# convienient because ICC headers can overwrite libc headers, but is
+# inconvienient because software built with ICC will be linked to /opt. I don't
+# like /opt because I think it's redundent. So this hint installs ICC to /usr,
+# and configures ICC to use private header directories so that ICC will not
+# overwrite headers from other packages. Installing ICC to /usr is also
+# compatible with any use, whether you want to use ICC for specific software,
+# or use ICC to build most of LFS.
 
-# And install Cpio to /tools:
+# ICC does not currently build Glibc, so ICC must be installed after Glibc,
+# Binutils, and GCC, are installed in the chapter 6 chroot.
 
-sed -i -e "s/invalid_arg/argmatch_invalid/" src/mt.c &&
-patch -Np1 -i ../cpio-2.6-security_fixes-1.patch &&
-./configure CPIO_MT_PROG=mt --prefix=/tools \
-	--libexecdir=/tmp --with-rmt=/tools/libexec/rmt &&
-echo "#define HAVE_SETLOCALE 1" >> config.h &&
-echo "#define HAVE_LSTAT 1" >> config.h &&
-make &&
-make install
+# As a general rule, always apply GCC4 patches for packages if available.
 
-# If you want to install Cpio to an existing system, follow the instructions in:
+# We need Cpio to unpack the ICC rpm packages. Cpio can be compiled in the
+# chapter 6 chroot after Binutils. Follow the BLFS instructions:
 # http://www.linuxfromscratch.org/blfs/view/svn/general/cpio.html
+# You can rebuild Cpio with ICC later if you want.
 
-# Then get: http://www.rpm.org/tools/scripts/rpm2cpio.sh
+# We also need the rpm2cpio script:
+# http://www.rpm.org/tools/scripts/rpm2cpio.sh
 
-# And install rpm2cpio to /tools with:
+# Install rpm2cpio to /usr:
 
-install rpm2cpio.sh /tools/bin/rpm2cpio
+install -v rpm2cpio.sh /usr/bin/rpm2cpio
 
-# Or change it for /usr.
+# Set your ICC package version in the shell environment (you may need to
+# modify the values for your version). This is done so that the rest of the
+# commands in this hint can be copied and pasted:
 
-# Build chapter 6's Glibc, Binutils, and GCC normally. Install ICC after GCC is
-# installed in chapter 6 (before Coreutils).
+export ICC_V_MAJOR=9
+export ICC_V_MINOR=1
+export ICC_V_PATCH=042
+export ICC_VERSION="${ICC_V_MAJOR}.${ICC_V_MINOR}.${ICC_V_PATCH}"
 
-# ICC has a few headers that replace libc headers, so ICC should not be
-# installed to /usr. Installing to /opt (or /usr/local) is suggested. Some
-# shared libraries are moved to /lib, so that nothing is linked to /opt/lib,
-# since any program linked to /opt/lib should live in /opt/bin too.
+# Unpack the Intel CC tarball and change to the data/ directory:
 
-# Unpack the Intel CC tarball. Then install the ICC compiler:
+tar zxvf l_cc_c_${ICC_VERSION}.tar.gz &&
+cd l_cc_c_${ICC_VERSION}/data/
 
-rpm2cpio intel-icc9-9.0-???.i386.rpm | cpio -id &&
-rm -f opt/intel/cc/9.0/bin/uninstall.sh &&
-chown -R 0:0 opt/ &&
-mv opt/intel/cc/9.0/bin/* /opt/bin &&
-mv opt/intel/cc/9.0/doc /opt/doc/icc &&
-mv opt/intel/cc/9.0/include/* /opt/include &&
-mv opt/intel/cc/9.0/lib/* /opt/lib &&
-mv opt/intel/cc/9.0/licenses /opt/doc/icc &&
-mv opt/intel/cc/9.0/man/man1/* /opt/man/man1 &&
+# Extract the rpm file for the C/C++ compiler:
+
+rpm2cpio intel-icc?????-${ICC_VERSION}*.i386.rpm | \
+	cpio --make-directories --extract --verbose &&
+rm -vf opt/intel/cc/${ICC_VERSION}/bin/uninstall.sh &&
+chown -vR 0:0 opt/
+
+# Copy the files to /usr:
+
+install -vd /usr/share/doc/icc-${ICC_VERSION} &&
+mv -v opt/intel/cc/${ICC_VERSION}/doc /usr/share/doc/icc-${ICC_VERSION} &&
+mv -v opt/intel/cc/${ICC_VERSION}/licenses /usr/share/doc/icc-${ICC_VERSION} &&
+mv -v opt/intel/cc/${ICC_VERSION}/man/man1/* /usr/share/man/man1 &&
+install -vd /usr/include/icc/ &&
+mv -v opt/intel/cc/${ICC_VERSION}/include/* /usr/include/icc
+
+# The iccvars.*sh files are shell startup/profile files, and belong in /etc:
+
+mv -v opt/intel/cc/${ICC_VERSION}/bin/iccvars.*sh /etc &&
+mv -v opt/intel/cc/${ICC_VERSION}/bin/* /usr/bin
+
+# Runtime libraries should be installed to /lib:
+
+mv -v opt/intel/cc/${ICC_VERSION}/lib/libirc.so /lib &&
+mv -v opt/intel/cc/${ICC_VERSION}/lib/libsvml.so /lib &&
+mv -v opt/intel/cc/${ICC_VERSION}/lib/libimf.so /lib
+
+# The rest of the libraries can go in /usr/lib:
+
+mv -v opt/intel/cc/${ICC_VERSION}/lib/locale /usr/lib/locale &&
+mv -v opt/intel/cc/${ICC_VERSION}/lib/* /usr/lib &&
 rm -rf opt/
 
+# Extract the rpm and tar files for the ICC headers:
+
+rpm2cpio intel-isubh*-${ICC_VERSION}*.i386.rpm \
+	| cpio --make-directories --extract --verbose &&
+tar -zvxf opt/intel/cc/${ICC_VERSION}/substitute_headers/libio.tar.gz -C \
+	opt/intel/cc/${ICC_VERSION}/substitute_headers/ &&
+chown -vR 0:0 opt/ &&
+find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type d \
+	-exec chmod -v 755 {} \; &&
+find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type f \
+	-exec chmod -v 644 {} \;
+
 # Install the ICC headers:
 
-rpm2cpio intel-isubh9-9.0-???.i386.rpm | cpio -id &&
-tar -zxf opt/intel/cc/9.0/substitute_headers/libio.tar.gz -C \
-	opt/intel/cc/9.0/substitute_headers/ &&
-chown -R 0:0 opt/ &&
-find opt/intel/cc/9.0/substitute_headers/libio -type d \
-	-exec chmod 755 {} \; &&
-find opt/intel/cc/9.0/substitute_headers/libio -type f \
-	-exec chmod 644 {} \; &&
-mv opt/intel/cc/9.0/substitute_headers/libio/* /opt/include &&
+mv -v opt/intel/cc/${ICC_VERSION}/substitute_headers/libio/* \
+	/usr/include/icc &&
 rm -rf opt/
 
-# Install the debugger:
+# Extract the rpm for the debugger:
 
-rpm2cpio intel-iidb9-9.0-???.i386.rpm | cpio -id &&
-rm -f opt/intel/idb/9.0//uninstall.sh &&
-chown -R 0:0 opt/ &&
-mv opt/intel/idb/9.0//bin/* /opt/bin &&
-mv opt/intel/idb/9.0//doc /opt/doc/idb &&
-mv opt/intel/idb/9.0//man/man1/* /opt/man/man1 &&
+rpm2cpio intel-iidb*-${ICC_VERSION}*.i386.rpm | \
+	cpio --make-directories --extract --verbose &&
+rm -vf opt/intel/idb/${ICC_VERSION}/bin/uninstall.sh
+chown -vR 0:0 opt/
+
+# Install the ICC debugger, idbvars.sh belongs in /etc:
+
+mv -v opt/intel/idb/${ICC_VERSION}/bin/idbvars.*sh /etc &&
+mv -v opt/intel/idb/${ICC_VERSION}/bin/* /usr/bin &&
+mv -v opt/intel/idb/${ICC_VERSION}/doc /usr/share/doc/idb-${ICC_VERSION} &&
+mv -v opt/intel/idb/${ICC_VERSION}/man/man1/* /usr/share/man/man1 &&
 rm -rf opt/
 
-# Install the license file:
+# ****************************************
+# - INSTALLING ICC - Configuring ICC files
+# ****************************************
 
-install -m644 *_cpp_l_*.lic /opt/doc/icc/licenses
+# The compiler suite is installed. Now we set it up. First install the
+# license file:
 
-# Rebuild the linker cache file:
+install -v -m444 *.lic /usr/share/doc/icc-${ICC_VERSION}/licenses/
 
-ldconfig
+# Configure the compiler:
 
-# Configure the compiler (you may need to correct your version number of the
-# first one):
+sed -e \
+"s/<installpackageid>/l_cc_c_${ICC_V_MAJOR}\.${ICC_V_MINOR}\.${ICC_V_PATCH}/" \
+	-i /usr/share/doc/icc-${ICC_VERSION}/doc/csupport
 
-sed -e 's/<installpackageid>/l_cc_p_9\.0\.021/' \
-	-i /opt/doc/icc/csupport
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' -i /usr/bin/icc
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' -i /opt/bin/icc
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' -i /usr/bin/icpc
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' \
-	-e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/iccvars.csh
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' \
+	-e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/iccvars.csh
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' \
-	-e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/iccvars.sh
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/lib/\/usr\/lib/g' \
+	-e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/iccvars.sh
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' -i /opt/bin/icpc
+source /etc/iccvars.sh
 
-source /opt/bin/iccvars.sh
+# If you get "bash: manpath: command not found", don't worry about it.
 
-# If you get "bash: man: command not found", don't worry about it right now.
+# Configure the Intel debugger:
 
-# Configure the debugger (make sure the version of the first one is correct):
+sed -e \
+"s/<installpackageid>/l_cc_c_${ICC_V_MAJOR}\.${ICC_V_MINOR}\.${ICC_V_PATCH}/" \
+	-i /usr/share/doc/idb-${ICC_VERSION}/idbsupport
 
-sed -e 's/<INSTALLTIMECOMBOPACKAGEID>/l_cc_p_9\.0\.026/' \
-	-i /opt/doc/idb/idbsupport
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/idbvars.csh
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/idbvars.csh
+sed -e \
+"s/<INSTALLDIR>\/licenses/\/usr\/share\/doc\/icc-${ICC_VERSION}\/licenses/g" \
+	-e 's/<INSTALLDIR>\/bin/\/usr\/bin/g' \
+	-e 's/<INSTALLDIR>\/man/\/usr\/share\/man/g' -i /etc/idbvars.sh
 
-sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \
-	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
-	-e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/idbvars.sh
+source /etc/idbvars.sh
 
-source /opt/bin/idbvars.sh
+# - INSTALLING ICC - Configuring system files:
 
-# For reasons unknown to me, ICC links to libgcc_s.so. On an LFS system
-# libgcc_s.so is in /usr/lib. Incase you have /usr on a seperate partition we
-# need to move libgcc_s.so to /lib:
+# ICC links programs to libgcc_s.so. On an LFS system libgcc_s.so is in
+# /usr/lib. On some systems libgcc_s.so is in /lib. If you plan to install
+# software built with ICC to /bin or /sbin, you should move libgcc_s.so to
+# /lib if it is not already there (this is recommended):
 
-cp /usr/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 &&
-ln -s libgcc_s.so.1 /lib/libgcc_s.so &&
-rm -f /usr/lib/libgcc_s.so*
+mv -v /usr/lib/libgcc_s.so.1 /lib/ &&
+rm -v /usr/lib/libgcc_s.so &&
+ln -vs libgcc_s.so.1 /lib/libgcc_s.so
 
-# If you plan to use ICC to compile most of the LFS system, the runtime
-# library should be moved to /lib:
+# We also need to tell ICC where to find the headers we installed to
+# /usr/include/icc:
 
-mv /opt/lib/libimf.so /lib &&
-ln -s ../../lib/libimf.so /opt/lib/libimf.so
+echo "-I/usr/include/icc" >> /usr/bin/icc.cfg
+echo "-I/usr/include/icc" >> /usr/bin/icpc.cfg
+echo "-I/usr/include/icc/c++" >> /usr/bin/icpc.cfg
 
-# Now we can use the Intel compiler. You should read:
+# Now we can use the Intel compiler.
+
+# Test ICC to see that it is working:
+
+echo "int main () {return 0;}" > /tmp/main.c &&
+icc -o /tmp/main /tmp/main.c &&
+/tmp/main &&
+rm /tmp/main{,.c}
+
+# If there are no errors then it worked.
+
+# You can unset these now:
+
+unset ICC_VERSION ICC_V_MAJOR ICC_V_MINOR ICC_V_PATCH
+
+# Now we can configure the system to use ICC.
+
+# Configure a GNU autoconf site file for ICC. This makes this hint shorter,
+# and our lives easier. GNU ./configure scripts will search for
+# "${prefix}/share/config.site" and use it to source environment variables.
+# Alternately you can put, and name, the "config.site" anywhere and set
+# the CONFIG_SITE environment variable to point to it:
+
+cat > /usr/share/config.site-icc << "EOF"
+CC="icc"
+CXX="icpc"
+LD="xild"
+AR="xiar"
+LANG="en"
+LANGUAGE="en"
+LC_ALL="C"
+EOF
+
+# If you want to build most of your LFS system with ICC you should export
+# this site configuration:
+
+export CONFIG_SITE="/usr/share/config.site-icc"
+
+# If you only want to use ICC for specific packages then you can use this:
+
+env CONFIG_SITE="/usr/share/config.site-icc" ./configure...
+
+# ***************
+# - Optimizations
+# ***************
+
+# Now you can read the ICC man pages for more information about its features
+# and usage.
+
+# You should also look at:
 # http://gentoo-wiki.com/HOWTO_ICC_and_Portage#CFLAGS
 
-# And figure out your CFLAGS, if you are using CFLAGS. You can't use
-# -fomit-frame-pointer or -pipe, and a few others. For the sake of this hint,
-# and copy pasting, lets set special ICC CFLAGS now. On my Prescott I use this:
+# and:
+# http://sc.tamu.edu/help/intel/9.0/main_cls/mergedProjects/optaps_cls/whnjs.htm
 
-export ICC_CFLAGS="-ip -xP -O3"
-export ICC_CXXFLAGS="$ICC_CFLAGS"
+# I scribbled some notes while reading the ICC man page, and posted them here:
+# http://www.linuxfromscratch.org/~robert/new/icc-cflag-notes.txt
 
-# Interprocedural optimizations (IPO) is a fantastic feature which optimizes
-# executables at link time. This allows the compiler to make better judgements.
-# A similiar option was added to GCC-4.1, -fwhole-program --combine. Using this
-# option is a bit touchy though. The -ipo flag can only be used on executables,
-# and not static libraries. Almost every package has static libraries which are
-# linked into the programs during the build. The HLFS book happens to use the
-# -fpie option which has the same requirements. To use the ICC -ipo option, check
-# the HLFS book for the sed commands which add -fpie to Makefile.in's. Replace the
-# "-pie -fpie" with "-ipo". The sed command for each package is different.
-# Unfortunetly these commands are not available for most of the BLFS packages.
+# We can add our optimizations to the ICC config file. This is what I use for
+# my Prescott:
 
-# Run this to break GCC compatability (some packages need this):
+# The -xP optimization is just like GCC's -march=prescott:
 
-echo "-no-gcc" >> /opt/bin/icc.cfg
+echo "-xP" >> /usr/bin/icc.cfg
+echo "-xP" >> /usr/bin/icpc.cfg
 
-# Libraries compiled with ICC should get -gcc added to CFLAGS, so that
-# programs compiled with GCC can use the libraries compiled with ICC.
+# Note that -axP is just like '-march=i586 -mtune=prescott'.
 
-# INSTALLING PACKAGES (Chapter 6):
+# The -fomit-frame-pointer optimization removes frame pointers from object
+# code, and makes it perform better. Note that this option makes programs
+# harder to debug:
 
-# Use the GCC4 patches from LFS.
+echo "-fomit-frame-pointer" >> /usr/bin/icc.cfg
+echo "-fomit-frame-pointer" >> /usr/bin/icpc.cfg
 
-# For every package built with ICC make sure to run the testsuite because this
-# is still expirmental. If one or more tests fail, retry with GCC. If the
-# results are better with GCC, then use GCC.
+# The -mno-ieee-fp optimization disables floating-point precision. This breaks
+# ANSI conformance but increases performance. This can break some software,
+# if it does then add -mp to CFLAGS. Note that this option makes programs
+# harder to debug:
 
-# Don't worry about:
-# "icc: warning: PGOPTI instrumentation disables IP optimizations"
-# This warning is given when using -ip (-fomit-frame-pointer) while generating
-# code profiles. -ip will work with the second build.
+echo "-mno-ieee-fp" >> /usr/bin/icc.cfg
+echo "-mno-ieee-fp" >> /usr/bin/icpc.cfg
 
-# To keep this hint shorter, I won't give complete instructions for every
-# package, but I'll give notes where needed.
+# The -no-prec-div optimization disables floating-point division computations.
+# Note that the man page entry for this option is not completely correct,
+# check google for this option. Note that this option makes programs harder
+# to debug:
 
-# To use ICC profiling we need to add "-prof_gen" and "-prof_dir=$(pwd)" to
-# CFLAGS/CXXFLAGS for the first build. Then run 'make check' in order to run the
-# programs and generate profiling data. If you are able to run the programs better
-# than how 'make check' does, then I suggest you do that. Then 'make clean', and
-# make again with "-prof_use". You can run 'make check' again if you like, and
-# finally 'make install'.
+echo "-no-prec-div" >> /usr/bin/icc.cfg
+echo "-no-prec-div" >> /usr/bin/icpc.cfg
 
-# In general, use this:
+# The -rcd enabled fast float-to-int conversions. This option breaks ANSI
+# conformance:
 
-env CFLAGS="$ICC_CFLAGS -prof_gen -prof_dir=$(pwd)" \
-	CXXFLAGS="$ICC_CXXFLAGS -prof_gen -prof_dir=$(pwd)" LC_ALL="C" \
-        LANG="en" LANGUAGE="en" CC="icc" CXX="icpc" ./configure...
+echo "-rcd" >> /usr/bin/icc.cfg
+echo "-rcd" >> /usr/bin/icpc.cfg
 
-# Then 'make && make check && make clean', and final build with:
+# This option tells ICC which GCC version to be compatable with:
 
-env CFLAGS="$ICC_CFLAGS -prof_use -prof_dir=$(pwd)" \
-	CXXFLAGS="$ICC_CXXFLAGS -prof_use -prof_dir=$(pwd)" LC_ALL="C" \
-	LANG="en" LANGUAGE="en" CC="icc" CXX="icpc" ./configure...
+echo "-gcc-version=410" >> /usr/bin/icc.cfg
+echo "-gcc-version=410" >> /usr/bin/icpc.cfg
 
-# Then 'make && make install'.
+# Use -no-gcc to break GCC compatability. This will perform better, and some
+# packages will need this. Libraries compiled with ICC should get -gcc
+# added to CFLAGS, so that programs compiled with GCC can use the libraries
+# compiled with ICC. I will provide commands to add -gcc to LFS packages,
+# but you need to keep this in mind with BLFS packages:
 
-# DB can not be compiled with ICC.
+echo "-no-gcc" >> /usr/bin/icc.cfg
+echo "-no-gcc" >> /usr/bin/icpc.cfg
 
-# Coreutils can compile with ICC profiling.
+# Software-based Speculative Pre-computation (-ssp) performs thread based
+# prefetching and takes advantage of hyper-threading. This option increases
+# performance signicicantly. See google for more information. This option
+# should not go together with -prof_gen, but -prof_use is okay. It might
+# depend on profrun. This is 5 stage profiling:
 
-# Zlib can compile with ICC, but X11 will not be able to link to it, so I do not
-# suggest it.
+-prof-gen
+./a.out
+-prof-gen-sampling -prof-use
+profrun -dcache ./a.out
+-prof-use -ssp
 
-# Mktemp can compile with ICC profiling.
+# The newer Pentium4 cpus perform Hardware-based Speculative Pre-computation,
+# so I have never tried to use the -ssp option.
 
-# Iana-Etc has no C/C++ code.
+# The -ansi-alias optimization will add additional optimizations but must
+# only be used if the package adheres to the ISO C Standard. The -strict-ansi
+# option should be used with -ansi-alias, to make sure the source comforms
+# to ansi.
 
-# Findutils can be compiled with ICC profiling.
+# Interprocedural optimizations (-ipo) is a fantastic feature which optimizes
+# code at link time, including expanding inline functions across multiple
+# files. This is equivilent to combining all the source code into a single
+# file. This allows the compiler to make better judgements. This option can
+# be very particular and error prone (at compile time).
 
-# Gawk can compile with ICC profiling.
+# The -ipo option can take an integer argument to specify the limit of output
+# files it can generate. By default the limit is 1. -ipo0 will allow the
+# compiler to decide how many object files to create depending on their size.
 
-# Ncurses can compile with ICC profiling. We add the -gcc flag because Ncurses
-# is a library. Ncurses also has C++ code, so CXX flags are also added.
+# The -Ob2 optimization adds -ip, a subset of -ipo but for single file
+# compilation, and inlines functions at the compiler's descretion. This
+# option can be used with all code.
 
-# Readline can compile with ICC profiling, and because it is a library -gcc
-# needs to be added to CFLAGS.
+# -Ob2, -ip, and -ipo can not be used during profile generation (see below)
+# and will cause a compiler warning if we try. If you decide not to profile
+# your packages then you can add -ipo0 or -Ob2 to the icc.cfg and icpc.cfg
+# files. Using -ipo0 on the command line will supersede -ip and -Ob2 in
+# icc.cfg. If you do not plan to use profiling then you can add -ipo0 to the
+# icc.cfg and icpc.cfg files.
 
-# Vim can compile with ICC profiling.
+# The -fast option enables "-O3 -ipo -static -no-prec-div -xP". Make sure
+# your cpu works with the -xP (pentium4 sse3) optimization before using -fast.
+# Because this optimization statically links programs I do not suggest building
+# most packages with it. Statically linked programs do not share virtual
+# memory, and will eventually consume all memory when most of the system is
+# statically linked. I do suggest using -fast with programs which are freed
+# from memory quickly and are not run often, like Bzip2.
 
-# M4 can compile with ICC profiling.
+# The -ipo option does not work with private static libraries, which most
+# packages have. So -ipo has to be surgically added.
 
-# Bison can compile with ICC profiling.
+# In ICC the -g option will disable the default -O2 optimization, unless
+# -O1/-O2/-O3 are used on the command line. Setting CFLAGS in the environment
+# will remove the -g option from most packages.
 
-# Less can compile with ICC profiling.
+# Packages configured with Libtool add the --with-pic configure switch. This
+# switch will build both shared and static libraries with -fPIC. We can take
+# advantage of this by adding -gcc beside -fPIC so that -gcc will only be
+# added to libraries, and not the programs. There is a disadvantage too.
+# Static libraries compiled with -fPIC will perform slightly slower, however
+# in LFS we link almost everything dynamically, so this should not become an
+# issue. In this hint I will provide instructions to add -gcc beside -fPIC
+# to make shared libraries GCC compatable, but not the static libraries. If
+# the static libraries cause issues for you, you should rebuild the package
+# with --with-pic. This way if you compile programs statically with ICC they
+# will perform as well as possible.
 
-# Groff can compile with ICC profiling.
+# Profile-guided optimizations works by first compiling a program, or library,
+# with profile generation (-prof_gen). When that program is executed it will
+# generate data files with details about how the program works at runtime,
+# such as which functions are called the most and how they relate to other
+# functions. Then the program is recompiled to use the profiling data with
+# -prof_use. This means compiling the package twice, but also means the
+# installed package will perform as well as possible. You do not have to do
+# this, but I do. If you choose not to profile your packages you can skip
+# much of the rest of this hint and simply use the config.site file as-is.
 
-# Sed can compile with ICC profiling.
+# Rather than resetting our CFLAGS twice for every profiled package, it's
+# easier to use a script. Some packages use 'libtool' to build packages,
+# and using 'make CC="icc -prof_gen"' for these packages will not work. When
+# profiling packages I suggest reconfiguring them. Also, some packages do not
+# use CFLAGS/CXXFLAGS for all components because the package developer may
+# not want particular parts of the programs optimized. So it is best to modify
+# the CC/CXX environment variables, instead of CFLAGS/CXXFLAGS, when using
+# -prof_gen and -prof_use.
 
-# Flex can compile with ICC profiling.
+# The following commands will add the profiling options to a few scripts,
+# including additional optimizations when profile data is being used:
 
-# Gettext can compile with ICC profiling, but because it's a library add -gcc.
+cat > /usr/bin/prof_gen-env << "EOF"
+unset CONFIG_SITE
+export LANG="en"
+export LANGUAGE="en"
+export LC_ALL="C"
+export LD="xild"
+export AR="xiar"
+export CFLAGS="-O2"
+export CXXFLAGS="-O2"
+export CC="icc -prof_gen -prof_dir=$(pwd)"
+export CXX="icpc -prof_gen -prof_dir=$(pwd)"
+"$@"
+EOF
+chmod -v +x /usr/bin/prof_gen-env
 
-# Inetutils can compile with ICC profiling.
+cat > /usr/bin/prof_use-env << "EOF"
+unset CONFIG_SITE
+export LANG="en"
+export LANGUAGE="en"
+export LC_ALL="C"
+export LD="xild"
+export AR="xiar"
+export CFLAGS="-O2 -ipo0"
+export CXXFLAGS="-O2 -ipo0"
+export CC="icc -prof_use -prof_dir=$(pwd)"
+export CXX="icpc -prof_use -prof_dir=$(pwd)"
+nice -n 19 "$@"
+EOF
+chmod -v +x /usr/bin/prof_use-env
 
-# For Iproute2 do (Iproute2 needs -gcc):
+cat > /usr/bin/prof_use-fast-env << "EOF"
+unset CONFIG_SITE
+export LANG="en"
+export LANGUAGE="en"
+export LC_ALL="C"
+export LD="xild"
+export AR="xiar"
+export CFLAGS="-O3 -fast -ipo0"
+export CXXFLAGS="-O3 -fast -ipo0"
+export CC="icc -prof_use -prof_dir=$(pwd)"
+export CXX="icpc -prof_use -prof_dir=$(pwd)"
+nice -n 19 "$@"
+EOF
+chmod -v +x /usr/bin/prof_use-fast-env
 
-sed -e 's/gcc/icc/g' -i Makefile &&
-sed -e "s|^CCOPTS .*$|& $ICC_CFLAGS -gcc -prof_gen -prof_dir=/tmp|" \
-	-i Makefile
+# For some reason most GNU ./configure scripts do not pass environment set
+# AR to Makefile. We need to use Intel's AR, not GNU's. So we need to create
+# a 'make' wrapper script which will always override the AR variable. I added
+# LD for good measure:
 
-# Then 'make' and 'make clean', and:
+cat > /usr/bin/icc-make << "EOF"
+nice make AR="xiar" LD="xild" "$@"
+EOF
+chmod -v +x /usr/bin/icc-make
 
-sed -e 's/prof_gen/prof_use/g' -i Makefile
+# Use 'icc-make' instead of 'make' whenever you are compiling with ICC.
 
-# And 'make' and 'make install'.
+# ***********************
+# - Building LFS packages
+# ***********************
 
-# Warning! Building Perl with profiling has frozen my desktop, beware.
-# Perl can compile with ICC profiling. After 'make distclean' you will have to
-# run ./configure again, substituting -prof_gen with -prof_use.
+# To build packages without profiling then './configure && icc-make'. The
+# /usr/share/config.site-icc file will be used. You may want to add
+# "-O2 -ipo0" to CFLAGS and CXXFLAGS in /usr/share/config.site-icc:
 
-# Texinfo can compile with ICC profiling.
+echo 'CFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc
+echo 'CXXFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc
 
-# Autoconf and Automake are scripts, and do not need to be compiled with ICC.
+# Some packages, such as Perl and Bash, generate large amounts of profiling
+# data. You can expect these packages to use 4GB of storage, and more, during
+# the build. Packages which generate especially large amounts of profiling
+# data also take a lot of system resources to process this data.
 
-# Bash compiles with ICC but will crash at runtime. Do not compile Bash with
-# ICC.
+# Some packages do not have testsuites, so we can not easily generate profiling
+# data for them. With small packages we can manually run common commands to
+# generating the profiling data.
 
-# File can compile with ICC profiling.
+# Beware I have frozen my system while computing profiling data (with Perl).
+# Since then I began using 'nice -n 19' when using -prof_use, and have not
+# frozen my system since. You can renice your whole login... first find your
+# process ID for your LFS chroot with 'ps a | grep /tools/bin/bash', and then
+# 'renice 10 -p ???'.
 
-# Libtool can compile with ICC profiling.
+# The truely best way to generate profiling data is to install the programs.
+# This way the program will be profiled against your specific system and uses.
+# If you wish to do this, I'll let you modify the following instructions. You
+# will need to store the profiling data in a dedicated directory, like
+# /home/icc/prof_data/coreutils, reboot the system and run it normally for a
+# few days, then rebuild with make-icc-prof_use (-prof_use). I have never
+# tried this.
 
-# For Bzip2 do this after applying the patches (add -gcc to the library):
+# In general, to profile packages, we would do something like this:
 
-sed -e 's|gcc|icc|g' -i Makefile* &&
-sed -e "s|^CFLAGS.*$|& $ICC_CFLAGS -prof_gen -prof_dir=/tmp|g" -i Makefile &&
-sed -e "s|^CFLAGS.*$|& $ICC_CFLAGS -prof_gen -prof_dir=/tmp -gcc|g" \
-	-i Makefile-libbz2_so
+prof_gen-env ./configure &&
+icc-make &&
+icc-make check &&
+icc-make distclean &&
+prof_use-env ./configure &&
+icc-make &&
+icc-make install
 
-# After 'make clean':
+# Packages (in the "Linux From Scratch - Version SVN-20061029" order):
 
-make &&
-make -f Makefile-libbz2_so clean &&
-sed -e 's/prof_gen/prof_use/g' -i Makefile* &&
-make -f Makefile-libbz2_so &&
-make clean
+# You should unset environment CFLAGS/CXXFLAGS, if you set them, so that
+# ICC will use the optimizations in the icc config files.
 
-# Then run 'make' and 'make install'.
+# You should also run the testsuies whether you are using profiling or not.
 
-# Diffutils can compile with ICC profiling.
+# - Berkeley DB (and TCL)
+# DB compiles with ICC, but the testsuite does not work without a full
+# installation of TCL. Berkeley DB's testsuite takes about 150 SBU (many hours)
+# to complete. If you are not prepared to do that then simply install Berkeley
+# DB without profiling, like the LFS book does. These tests will also use
+# about 4GB of space.
 
-# - For Kbd, after running ./configure, make like this:
+# If you want to profile Berkeley DB then install TCL from the BLFS book.
+# Berkeley DB and TCL contain libraries, so you may want to add the -gcc
+# option. I built my system using ICC as much as possible, so I did not build
+# these libraries with -gcc because I have no compatability to worry about.
+# TCL can also be profiled with ICC. If you want GCC compatability with TCL's
+# libraries then run this command:
 
-make CC="icc" CFLAGS="$ICC_CFLAGS -prof_gen -prof_dir=$(pwd)" &&
-make clean &&
-make CC="icc" CFLAGS="$ICC_CFLAGS -prof_use -prof_dir=$(pwd)"
+sed -e 's/-.*PIC/& -gcc /' -i unix/configure
 
-# E2fsprogs can compile with ICC profiling. We have to re-run ./configure
-# like with Perl, substituting -prof_gen with -prof_use on the second pass.
+# To profile TCL (make sure the ./configure --options are the same as in the
+# BLFS book):
 
-# Grep can compile with ICC profiling.
+cd unix &&
+prof_gen-env ./configure --prefix=/usr --enable-threads &&
+icc-make &&
+icc-make test
 
-# Grub does not compile with ICC.
+# TCL will fail several tests because networking does not work, and will also
+# complain about the profiling data files being left behind, that's fine. Then
+# rebuild TCL to use the profile data and -ipo:
 
-# Gzip can compile with ICC profiling.
+icc-make distclean &&
+prof_use-env ./configure --prefix=/usr --enable-threads &&
+icc-make
 
-# Hotplug has no C code.
+# You can 'make test' again if you're paranoid. Then install TCL.
 
-# Man doesn't do profiling, but can compile with ICC:
+# We need GCC compatability with Berkeley DB libraries for Man-DB:
 
-make CC="icc" CFLAGS="$ICC_CFLAGS"
+sed -e 's/-.*PIC/& -gcc /' -i dist/configure
 
-# Make can compile with ICC profiling.
+# Build Berkeley DB just like TCL, with the prof_gen-env and prof_use-env
+# scripts. Also add TCL and tests to the configure command:
 
-# - For Module-init-tools you will need to use a patch to disable the static
-# linking of insmod:
-# http://www.linuxfromscratch.org/patches/downloads/module-init-tools/\
-#	module-init-tools-3.2.1-nostatic-1.patch
+cd build_unix &&
+prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \
+	--enable-tcl --with-tcl=/usr/lib --enable-test &&
+icc-make
 
-# Module-init-tools can compile with ICC profiling.
+# Then to run the testsuite open the tclsh shell:
 
-# Patch can compile with ICC profiling.
+tclsh
 
-# Procps does not compile with ICC.
+# At the % promt run the tests (this will take hours):
 
-# Psmisc can compile with ICC profiling.
+source ../test/test.tcl
+run_parallel 5 run_std
+exit
 
-# Shadow can compile with ICC profiling.
+# Then clean Berkeley DB and rebuild:
 
-# Sysklogd doesn't do profiling, but can compile with ICC:
+icc-make realclean &&
+prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \
+	--enable-tcl --with-tcl=/usr/lib &&
+icc-make
 
-make CC="icc" CFLAGS="-DSYSV $ICC_CFLAGS"
+# Then install Berkeley DB.
 
-# Sysvinit doesn't do profiling, but can compile with ICC:
+# - E2fsprogs
+# E2fsprogs does not build properly with ICC. Build E2fsprogs with GCC:
 
-make -C src CC="icc" CFLAGS="$ICC_CFLAGS -D_GNU_SOURCE"
+env -u CONFIG_SITE ../configure...
+make
 
-# Tar can compile with ICC profiling.
+# - Coreutils
+# Build Coreutils with profiling:
 
-# Udev does not compile with ICC.
+prof_gen-env ./configure --prefix=/usr &&
+icc-make
 
-# Util-linux needs GCC for mkfs.minix.
+# Then run the testsuite, distclean, and rebuild with the profiling
+# information:
 
-# There is a project to compile the Linux kernel with ICC:
+prof_use-env ./configure --prefix=/usr &&
+icc-make
 
-# http://www.pyrillion.org/linuxkernelpatch.html
+# Then install Coreutils.
 
-# But I couldn't get it to work, and the advantages are minimal (about 2%).
+# - Iana-Etc has nothing to compile.
 
-# After LFS is installed do this:
+# - M4
+# M4 is typical. Build and install it just like Coreutils.
 
-echo "source /opt/bin/idbvars.sh" >> /etc/profile
-echo "source /opt/bin/iccvars.sh" >> /etc/profile
-echo 'export ICC_CFLAGS="-ip -xP -O3"' >> /etc/profile
-echo 'export ICC_CXXFLAGS="$ICC_CFLAGS"' >> /etc/profile
+# - Bison:
+# Bison is a typical build, like M4.
+
+# - Ncurses
+# Ncurses builds with ICC, but I had serious issues with Bash. So for now
+# I suggest building Ncurses with GCC:
+
+env -u CONFIG_SITE ./configure...
+
+# - Procps does not compile with ICC. It will compile with GCC by default.
+# If you really want a pure ICC system, you can use the Procps utilities from
+# Busybox.
+
+# - Sed
+# I compile Sed with -fast. If you don't want to, and/or you are not using
+# the -xP optimization, then build Sed like Coreutils. To build Sed with
+# -fast:
+
+prof_gen-env ./configure...
+icc-make
+icc-make check
+icc-make distclean
+prof_use-fast-env ./configure...
+icc-make
+
+# Then install Sed.
+
+# - Libtool
+# 'libtool' itself is a script, but the package includes a library. To add
+# GCC compatability (this is optional):
+
+sed -e 's/^CFLAGS =/& -gcc/' -i libltdl/Makefile.in
+
+# Then profile Libtool like Coreutils, but use 'make clean' instead of
+# 'distclean'.
+
+# - Perl
+# Since I started using AR="xiar" I have not been able to get Perl to build
+# with ICC. Even without AR="xiar" Perl will fail a couple tests. For these
+# reasons I suggest building Perl with GCC. Just build Perl normally, it will
+# ignore the config.site file.
+
+# - Readline
+# Readline is a library and you may want to add -gcc (I don't):
+
+sed -e 's/^CFLAGS =/& -gcc/' -i {,shlib/}Makefile.in
+
+# Readline does not have a testsuite, so it can not easily be profiled. Build
+# it normally and it will use the config.site file to use ICC. Remember to
+# use 'icc-make'.
+
+# - Zlib can compile with ICC, but X11 will not be able to link to it even if
+# -gcc is used, so I do not suggest it. To build Zlib with GCC:
+
+env -u CONFIG_SITE ./configure...
+
+# - Autoconf and Automake are perl scripts.
+
+# - Bash
+# Bash-3.1 can compile with ICC, and bash-3.2 does not. I do not suggest
+# using Bash-3.2 because I had bad expirence with it (it's screwy).
+# Bash-3.1 can be built with profiling, but not with -ipo. Remember to use
+# the bash-3.1 upstream patch. The Bash sources directory will grow to almost
+# 3GB with profiling data. Build Bash like this:
+
+prof_gen-env ./configure...
+icc-make
+icc-make tests
+icc-make distclean
+nice -n 19 env -u CONFIG_SITE LANG="en" LANGUAGE="en" LC_ALL="C" \
+	LD="xild" AR="xiar" CC="icc -prof_use -prof_dir=$(pwd)" \
+	./configure...
+icc-make
+
+# Then install Bash.
+
+# - Bzip2
+# I'm building bzip2.so,a with -ipo, and bzip2 and bzip2recover with -fast.
+# If you are not using -xP then change -fast to -ipo0.
+
+icc-make CC=icc CFLAGS="-prof_gen -prof_dir=$(pwd) \
+	-D_FILE_OFFSET_BITS=64 -O2" \
+	AR=xiar LD=xild -f Makefile-libbz2_so &&
+icc-make clean &&
+icc-make CC=icc CFLAGS="-prof_gen -prof_dir=$(pwd) \
+	-D_FILE_OFFSET_BITS=64 -O2" \
+		AR=xiar LD=xild
+
+# The bzip2 testsuite tests the bzip2 which has libbz2.a linked to it, so
+# the libbz2.so shared libraries doesn't get tested and doesn't generate
+# profiling data. We can do this ourselves:
+
+dd if=/dev/urandom of=urandom.file bs=1M count=17
+env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared urandom.file
+env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d urandom.file.bz2
+cat CHANGES LICENSE bzip2 | \
+	env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -4 -c > non-random.bz2
+env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d non-random.bz2
+env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared --help
+
+# Then rebuild Bzip2 with the profiling data:
+
+icc-make clean &&
+icc-make -f Makefile-libbz2_so clean &&
+icc-make CC=icc CFLAGS="-prof_use -prof_dir=$(pwd) -O -gcc -ipo0 -O2 \
+	-D_FILE_OFFSET_BITS=64" AR=xiar LD=xild -f Makefile-libbz2_so &&
+icc-make clean &&
+icc-make CC=icc CFLAGS="-prof_use -prof_dir=$(pwd) -D_FILE_OFFSET_BITS=64 \
+	-ipo0 -fast" AR=xiar LD=xild
+
+# Then when installing bzip2, do not install the 'bzip2-shared' version,
+# install the statically linked (with -fast) 'bzip2' file instead.
+
+# - Diffutils does not have a testsuite. You can build it with ICC the way the
+# LFS book builds Diffutils. Remember to use 'icc-make'.
+
+# - File
+# File builds with ICC, and does not have a testsuite, just like Diffutils.
+
+# - Findutils
+# Findutils can be compiled with ICC profiling, just like Coreutils or M4.
+# I compile Findutils with -fast because 'find' and 'locate' usually do
+# intense operations and don't stay in memory after. To build Findutils with
+# -fast:
+
+prof_gen-env ./configure...
+icc-make
+icc-make check
+icc-make distclean
+prof_use-fast-env ./configure...
+icc-make
+ 
+# Then install Findutils.
+
+# - Flex
+# Build and install Flex typically, like Coreutils and M4.
+
+# - Grub does not compile with ICC:
+
+env -u CONFIG_SITE ./configure...
+
+# - Gawk
+# Build and install Gawk typically, like Flex. I used -fast with Gawk, via
+# prof_use-fast-env.
+
+sed -e 's/CFLAGS =/& -fast/' -i {,awklib/}Makefile &&
+make-icc-prof_use
+
+# Then install Gawk.
+
+# - Gettext
+# Gettext contains libraries, so you may want to add -gcc (I don't):
+
+find gettext-runtime/ -name Makefile.in \
+	-exec sed -e 's/^CFLAGS =/& -gcc/' -i {} \;
+
+# I couldn't get Gettext to build with -ipo, but it builds with profiling.
+# After 'make distclean':
+
+nice -n 19 env -u CONFIG_SITE LANG="en" LANGUAGE="en" LC_ALL="C" \
+	LD="xild" AR="xiar" CC="icc -prof_use -prof_dir=$(pwd)" ./configure..
+
+# - Grep
+# Build and install Grep typically. I used -fast for Grep too.
+
+# - Groff
+# Groff does not build with -ipo, and does not have a testsuite. Build Groff
+# like this:
+
+env -u CONFIG_SITE CC="icc" CXX="icpc" LD="xild" AR="xiar" \
+	LANG="en" LANGUAGE="en" LC_ALL="C" ...
+
+# Remember to use 'icc-make'.
+
+# - Gzip
+# Gzip doesn't have a testsuite, but we can mimick one:
+
+dd if=/dev/urandom of=urandom.file bs=2M count=10
+./gzip -9 urandom.file
+./gzip -d urandom.file.gz
+cat AUTHORS README README-alpha ChangeLog | ./gzip -4 -c > non-random.gz
+./gzip -d non-random.gz
+
+# I build Gzip with -fast too.
+
+# - Inetutils
+# Inetutils does not have a testsuite but will compile with ICC.
+
+# - Iproute2
+# Iproute2 needs the -gcc option, and does not have a testsuite:
+
+icc-make SBINDIR=/sbin CC="icc -gcc" &&
+icc-make SBINDIR=/sbin CC="icc -gcc" install
+
+# - Kdb
+# Kbd does not have a testsuite:
+
+icc-make CC="icc"
+
+# - Less
+# Less does not have a testsuite. Configure and build it normally.
+
+# - Make
+# Build and install Make typically.
+
+# - Man-DB
+# Man-DB does not have a testsuite. Configure and build it normally.
+
+# - Mktemp
+# Mktemp does not have a testsuite, but we can simulate one:
+
+./mktemp --help
+./mktemp -V
+./mktemp -p . && ./mktemp -p . XXXXXXXX
+./mktemp -p . -d && ./mktemp -p . -d XXXXXXXX
+
+# You can build Mktemp with -fast if you like.
+
+# - Module-init-tools
+# I suggest you use this patch to dynamically link insmod:
+# http://www.linuxfromscratch.org/patches/downloads/module-init-tools/
+#	module-init-tools-3.2.2-nostatic-1.patch
+
+# Run the Module-init-tools tests like this:
+
+prof_gen-env ./configure &&
+prof_gen-env icc-make check &&
+icc-make distclean
+
+# Then rebuild with 'prof_use-env'.
+
+# - Patch
+# Patch does not have a testsuite. Build and install it normally.
+
+# - Psmisc
+# Psmisc does not have a testsuite. Build and install it normally.
+
+# - Shadow
+# Shadow does not have a testsuite. Build and install it normally.
+
+# - Sysklogd
+# Sysklogd does not have a testsuite. Build Sysklogd with ICC like this:
+
+icc-make CC="icc -ipo0"
+
+# - Sysvinit
+# Sysvinit does not have a testsuite. Build Sysvinit with ICC like this:
+
+icc-make -C src CC="icc -ipo0"
+
+# - Tar
+# Tar can be built typically, like Coreutils.
+
+# - Texinfo
+# Texinfo can be built typically, like Coreutils.
+
+# - Udev does not compile with ICC.
+
+# - Util-linux does not compile with ICC.
+
+# - Vim
+# Vim can be built typically. Vim's testsuite will almost certainly screw up
+# your terminal. Pipe the output to a log, or /dev/null:
+
+make test 2>&1>/dev/null
+
+# Opening and reading the log can also screw up your terminal.
+
+# After LFS is installed add the environment files to /etc/profile:
+
+echo "source /etc/idbvars.sh" >> /etc/profile
+echo "source /etc/iccvars.sh" >> /etc/profile
+echo 'export CONFIG_SITE="/usr/share/config.site-icc"' >> /etc/profile
 source /etc/profile
 
+# There is a project to compile the Linux kernel with ICC:
+
+# http://www.pyrillion.org/linuxkernelpatch.html
+
+# But I couldn't get it to work.
+
 # Your system should now be running like lightning :-)
 
 # Beyond LFS packages which compile with ICC:
 
-# OpenSSL
+# - OpenSSL
+# I couldn't get OpenSSL to compile with 'xiar'.
 
-# For OpenSSL can compile with ICC profiling. After ./config, and before make:
+# - OpenSSH
+# OpenSSH can compile with profiling, but has a couple issues. First the
+# 'optreset' Glibc function doesn't resolve, but we can use the 'optreset'
+# included with OpenSSH:
 
-sed -e 's|gcc|icc|g' \
-	-e 's/-fomit-frame-pointer//g' \
-	-e 's/-mcpu=pentium//g' \
-	-e 's/-O3//g' \
-	-e "s|^CFLAG.*$|& $ICC_CFLAGS -gcc -prof_gen -prof_dir=/tmp|" \
-	-i Makefile
+prof_gen-env env ac_cv_have_getopt_optreset=no ./configure...
 
-# 'make...' ane 'make clean', then:
+# The other issue is with 'ld' not resolving symbols from the Glibc
+# library, but we can 'icc' instead:
 
-sed -e 's/prof_gen/prof_use/' -i Makefile
+make LD=icc AR=xiar
 
-# And run 'make' again, and install OpenSSL.
+# - LibPNG
+# LibPNG can compile with ICC, but X11 won't be able to use it:
 
-# OpenSSH can compile with ICC profiling.
+env -u CONFIG_SITE ./configure...
 
-# LibPNG can compile with ICC, but X11 won't be able to link to it. If you
-# still want to compile LibPNG with ICC (for console Lynx):
+# - Freetype doesn't compile with profiling, but can compile with ICC.
 
-make prefix=/usr ZLIBINC= ZLIBLIB= CC=icc CFLAGS="$ICC_CFLAGS -gcc" \
-    ZLIBLIB= -f scripts/makefile.linux
+# - Expat doesn't compile with profiling, but can compile with ICC.
 
-# Freetype doesn't compile with profiling, but can compile with ICC.
+# - Fontconfig can compile with ICC profiling.
 
-# Expat doesn't compile with profiling, but can compile with ICC. Add -gcc
-# to CFLAGS.
+# - Wget
+# Wget will compile with ICC but has weird buggy behaviour, so I suggest
+# building Wget with GCC:
 
-# Fontconfig can compile with ICC profiling.
+env -u CONFIG_SITE ./configure...
 
-# X11 does not compile with ICC (yet).
+# - Pkg-config
+# Pkg-config will build with profiling, like Coreutils.
 
+# - Xorg
+# Don't build Xorg with ICC, its not well supported. Use:
+
+env -u CONFIG_SITE ../build.sh...
+
 # Jpeg-6b can compile with ICC profiling. Add -gcc to CFLAGS and because this
 # is a library.
 
@@ -465,15 +991,11 @@
 
 # LibMNG can compile with ICC.
 
-make CC=icc CFLAGS="$ICC_CFLAGS -gcc"
+icc-make CC=icc CFLAGS="$ICC_CFLAGS -gcc"
 
-# QT supports ICC. Before ./configure:
+# QT supports ICC.
+# Add "-platform linux-icc -thread" to the ./configure command.
 
-sed -e "s|^QMAKE_CFLAGS_RELEASE.*$|& $ICC_CFLAGS|" \
-	-i mkspecs/linux-icc/qmake.conf
-
-# Then add "-platform linux-icc -thread" to the ./configure command.
-
 # Pkgconfig can compile with ICC profiling.
 
 # Glib2 can compile with ICC profiling. Add -gcc to CFLAGS/CXXFLAGS.
@@ -522,7 +1044,7 @@
 
 # LibIDL can compile with ICC profiling.
 
-# Others:
+# Others that compile with ICC:
 
 # Glib
 # Gtk
@@ -576,17 +1098,14 @@
 # Libaal
 # Reiser4progs
 # Cdrtools
+# Add "CC=/opt/bin/icc" to the make command.
 
-# For Cdrtools do:
-
-sed -e "s/-O/$ICC_CFLAGS/" -i RULES/i586-linux-cc.rul
-
-# And add "CC=/opt/bin/icc" to the make command.
-
 # Irssi
 
 # And more...
 
+# ICC has its own Prelink program... check the man pages.
+
 ACKNOWLEDGMENTS:
 	* Thanks to Daniel Baumann for the original hint.
 	* Thanks to Gentoo for their wiki page:
@@ -611,3 +1130,22 @@
 	* Run 'make check' after building with prof_gen, to generate profiling data.
 [2006-05-22]
 	* Added notes for the -ipo option.
+	* Added warning about Perl's large amount of generated profiling data.
+	* Bash may compile with ICC now.
+	* Fixed up the bzip2 instructions a bit.
+	* Added note about Diffutils and File's lack of testsuite.
+[2006-06-24]
+	* Bump to icc-9.1.
+	* Use some shell variables for icc version to make it easier for users
+	  who are using a different icc version.
+	* Add sed commands for -ipo.
+	* Make a config.site for ICC.
+	* Added make scripts for code profiling, to make things easier.
+	* Add ICC_CFLAGS to the ICC config file, to make things easier.
+	* Spell checked.
+[2006-11-06]
+	* Bump to ICC-9.1.042.
+	* Added more uses for the -fast option, and other options.
+	* Bumped to LFS-SVN-20061021
+	* Static libraries can be built with -ipo, but only works if AR=xiar
+	* Added icc-make so xiar (AR) is used.




More information about the hints mailing list