Changeset 1066

Show
Ignore:
Timestamp:
11/11/06 16:18:05 (2 years ago)
Author:
tushar
Message:

Updated: intel-c-compiler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/intel-c-compiler.txt

    r1035 r1066  
    22        Daniel Baumann <daniel.baumann at panthera-systems.net> 
    33 
    4 DATE: 2006-05-22 
     4DATE: 2006-11-06 
    55 
    66LICENSE: GNU General Public License 
    77 
    8 SYNOPSIS: How to build LFS with the Intel C/C++ compiler and code profiling
    9  
    10 PRIMARY URI
     8SYNOPSIS: Installing and using the Intel C/C++ compiler with LFS
     9 
     10PRIMARY URL
    1111http://www.linuxfromscratch.org/hints/downloads/files/intel-c-compiler.txt 
    1212 
    1313DESCRIPTION: 
    14 How to install the Intel C/C++ Compiler for your LFS-system. 
     14The Intel C/C++ compiler collection (ICC) is a full featured compiler and 
     15debugger suite, which is close to compatible with the GNU C/C++ compiler 
     16collection (GCC). ICC is made only for Intel chips and takes advantage of 
     17Intel technology, such as Hyper-Threading, more than GCC does. Software 
     18compiled with ICC usually performs better than if it were compiled with GCC. 
     19The performance difference can range between 2% and 40% depending on the 
     20software and compiler flags. Most of the LFS base system will compile with ICC. 
     21 
     22The Intel compiler is not opensource. A non-commercial Linux user license is 
     23available for application developers. This license does not expire but only 
     24entitles you to upgrades for one year (you may be able to renew the license). 
     25 
     26A commercial license allows you to distribute packages you built with ICC, 
     27and costs up to $400. Discounts are available for students. 
     28 
     29If you are using ICC for personal use, to help develop ICC, the non-commercial 
     30application developer license is right for you. 
     31 
     32There is a PDF document describing ICC-9.0 here: 
     33http://cache-www.intel.com/cd/00/00/22/23/222301_222301.pdf 
    1534 
    1635PREREQUISITES: 
    17 An Intel CPU (Intel-clones/AMD may or may not work). 
    18 Glibc (icc is linked to /lib/ld-linux.so.2). 
     36- An Intel CPU (Intel-clones may not work). 
     37 
     38- The Intel website says a PentiumII with 256MB of RAM is required to use 
     39  ICC-9.1. 
     40 
     41- Glibc (icc is linked to /lib/ld-linux.so.2). 
     42 
     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). 
     45 
     46- This hint is for i86, but could be adapted for other Intel platforms. 
    1947 
    2048HINT: 
    21 The Intel C/C++ compiler collection (ICC) is a full featured compiler and 
    22 debugger suite, which is close to compatable with the GNU C/C++ compiler 
    23 collection (GCC). ICC is made only for Intel chips, and takes advantage of 
    24 Intel technology, such as Hyper-Threading, moreso than GCC does. Software 
    25 compiled with ICC is expected to perform better than if it were compiled with 
    26 GCC. Because GCC is much more tested than ICC, ICC may produce less stable 
    27 programs than GCC would with some packages. Not all packages will build with 
    28 ICC, such as X11; maybe they will in the future. 
    29  
    30 The homepage for the Intel compiler is here: 
    31 http://www.intel.com/software/products/compilers/clin/ 
    32  
    33 You should also see: 
    34 http://gentoo-wiki.com/HOWTO_ICC_and_Portage 
    35  
    36 This compiler is not opensource. 
    37  
    38 This hint will give instructions to build supported software with ICC, so that 
    39 as much as possible is using it. ICC will only be installed in chapter 6 since 
    40 we will still need GCC for some packages. You can choose to install ICC without 
    41 using it to build the LFS system, or build just some packages, it's upto you. 
    42 The main reason for using ICC is for performance, so intructions are also 
    43 provided to enable profiling; this means compiling packages twice, but they 
    44 should run a bit faster. The difference between runtimes of a program compiled 
    45 with GCC, compared to ICC with profiling, varies between 2% and 40%. 
    46  
    47 For even more performance, also see the prelink.txt hint, the optimization.txt 
    48 hint (for GCC), the reiser4-on-2.6.txt hint, and (for GCC): 
    49  
    50 http://www.rocklinux.net/people/clifford/ccbench/ 
    51 http://blaze.topside.org/~ashes/gcc4/ccbench-20051119.tar.bz2 (for gcc4) 
    52  
    53 Intel's compiler is only free of charge for non-commercial use. If that is what 
    54 you want then go here: 
    55  
    56 http://www.intel.com/software/products/compilers/clin/noncom.htm 
    57  
    58 And follow the instructions so that you will be emailed a license file. The 
    59 email will also give you a download location for the compressed tarball. 
    60  
    61 After that you should have two files (the numbers may be different): 
    62  
    63 l_cc_p_9.0.021.tar.gz 
     49The homepage for the Intel compiler (application developer license) is here: 
     50http://www.intel.com/cd/software/products/asmo-na/eng/compilers/clin/219856.htm 
     51 
     52The ICC-9.1 compiler is compatible with gcc-4.1 and supports the newest Intel 
     53CPU's. 
     54 
     55To obtain the Intel compiler, and user license, go to the homepage and 
     56register. You should receive an email with a URL for the ICC tarball, and a 
     57user license attachment. 
     58 
     59After that you should have two files (the versions may be different): 
     60 
     61l_cc_c_9.1.042.tar.gz (279MB) 
    6462and 
    65 noncommercial_cpp_l_N4R8-B2RV9P4B.lic 
    66  
    67 # INSTALLATION (Tested on LFS-SVN-20051127): 
    68  
    69 # At the end of chaper 5 we will need to install Cpio, and rpm2cpio. 
    70  
    71 # Get: ftp://ftp.gnu.org/pub/gnu/cpio/cpio-2.6.tar.gz 
    72 # And: http://www.linuxfromscratch.org/patches/downloads/cpio/\ 
    73 #       cpio-2.6-security_fixes-1.patch 
    74  
    75 # And install Cpio to /tools: 
    76  
    77 sed -i -e "s/invalid_arg/argmatch_invalid/" src/mt.c && 
    78 patch -Np1 -i ../cpio-2.6-security_fixes-1.patch && 
    79 ./configure CPIO_MT_PROG=mt --prefix=/tools \ 
    80         --libexecdir=/tmp --with-rmt=/tools/libexec/rmt && 
    81 echo "#define HAVE_SETLOCALE 1" >> config.h && 
    82 echo "#define HAVE_LSTAT 1" >> config.h && 
    83 make && 
    84 make install 
    85  
    86 # If you want to install Cpio to an existing system, follow the instructions in: 
     63NCOM_L_CMP_CPP_NZDM-FT472MJ3.lic 
     64 
     65***************** 
     66Table of contents 
     67***************** 
     68        - Installing ICC 
     69                Installing ICC files 
     70                Configuring ICC files 
     71                Configuring system files 
     72        - Optimizations 
     73        - Building LFS packages 
     74 
     75# *************************************** 
     76# - INSTALLING ICC - Installing ICC files 
     77# *************************************** 
     78 
     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. 
     87 
     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. 
     90 
     91# As a general rule, always apply GCC4 patches for packages if available. 
     92 
     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: 
    8795# http://www.linuxfromscratch.org/blfs/view/svn/general/cpio.html 
    88  
    89 # Then get: http://www.rpm.org/tools/scripts/rpm2cpio.sh 
    90  
    91 # And install rpm2cpio to /tools with: 
    92  
    93 install rpm2cpio.sh /tools/bin/rpm2cpio 
    94  
    95 # Or change it for /usr. 
    96  
    97 # Build chapter 6's Glibc, Binutils, and GCC normally. Install ICC after GCC is 
    98 # installed in chapter 6 (before Coreutils). 
    99  
    100 # ICC has a few headers that replace libc headers, so ICC should not be 
    101 # installed to /usr. Installing to /opt (or /usr/local) is suggested. Some 
    102 # shared libraries are moved to /lib, so that nothing is linked to /opt/lib, 
    103 # since any program linked to /opt/lib should live in /opt/bin too. 
    104  
    105 # Unpack the Intel CC tarball. Then install the ICC compiler: 
    106  
    107 rpm2cpio intel-icc9-9.0-???.i386.rpm | cpio -id && 
    108 rm -f opt/intel/cc/9.0/bin/uninstall.sh && 
    109 chown -R 0:0 opt/ && 
    110 mv opt/intel/cc/9.0/bin/* /opt/bin && 
    111 mv opt/intel/cc/9.0/doc /opt/doc/icc && 
    112 mv opt/intel/cc/9.0/include/* /opt/include && 
    113 mv opt/intel/cc/9.0/lib/* /opt/lib && 
    114 mv opt/intel/cc/9.0/licenses /opt/doc/icc && 
    115 mv opt/intel/cc/9.0/man/man1/* /opt/man/man1 && 
     96# You can rebuild Cpio with ICC later if you want. 
     97 
     98# We also need the rpm2cpio script: 
     99# http://www.rpm.org/tools/scripts/rpm2cpio.sh 
     100 
     101# Install rpm2cpio to /usr: 
     102 
     103install -v rpm2cpio.sh /usr/bin/rpm2cpio 
     104 
     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: 
     108 
     109export ICC_V_MAJOR=9 
     110export ICC_V_MINOR=1 
     111export ICC_V_PATCH=042 
     112export ICC_VERSION="${ICC_V_MAJOR}.${ICC_V_MINOR}.${ICC_V_PATCH}" 
     113 
     114# Unpack the Intel CC tarball and change to the data/ directory: 
     115 
     116tar zxvf l_cc_c_${ICC_VERSION}.tar.gz && 
     117cd l_cc_c_${ICC_VERSION}/data/ 
     118 
     119# Extract the rpm file for the C/C++ compiler: 
     120 
     121rpm2cpio intel-icc?????-${ICC_VERSION}*.i386.rpm | \ 
     122        cpio --make-directories --extract --verbose && 
     123rm -vf opt/intel/cc/${ICC_VERSION}/bin/uninstall.sh && 
     124chown -vR 0:0 opt/ 
     125 
     126# Copy the files to /usr: 
     127 
     128install -vd /usr/share/doc/icc-${ICC_VERSION} && 
     129mv -v opt/intel/cc/${ICC_VERSION}/doc /usr/share/doc/icc-${ICC_VERSION} && 
     130mv -v opt/intel/cc/${ICC_VERSION}/licenses /usr/share/doc/icc-${ICC_VERSION} && 
     131mv -v opt/intel/cc/${ICC_VERSION}/man/man1/* /usr/share/man/man1 && 
     132install -vd /usr/include/icc/ && 
     133mv -v opt/intel/cc/${ICC_VERSION}/include/* /usr/include/icc 
     134 
     135# The iccvars.*sh files are shell startup/profile files, and belong in /etc: 
     136 
     137mv -v opt/intel/cc/${ICC_VERSION}/bin/iccvars.*sh /etc && 
     138mv -v opt/intel/cc/${ICC_VERSION}/bin/* /usr/bin 
     139 
     140# Runtime libraries should be installed to /lib: 
     141 
     142mv -v opt/intel/cc/${ICC_VERSION}/lib/libirc.so /lib && 
     143mv -v opt/intel/cc/${ICC_VERSION}/lib/libsvml.so /lib && 
     144mv -v opt/intel/cc/${ICC_VERSION}/lib/libimf.so /lib 
     145 
     146# The rest of the libraries can go in /usr/lib: 
     147 
     148mv -v opt/intel/cc/${ICC_VERSION}/lib/locale /usr/lib/locale && 
     149mv -v opt/intel/cc/${ICC_VERSION}/lib/* /usr/lib && 
    116150rm -rf opt/ 
    117151 
     152# Extract the rpm and tar files for the ICC headers: 
     153 
     154rpm2cpio intel-isubh*-${ICC_VERSION}*.i386.rpm \ 
     155        | cpio --make-directories --extract --verbose && 
     156tar -zvxf opt/intel/cc/${ICC_VERSION}/substitute_headers/libio.tar.gz -C \ 
     157        opt/intel/cc/${ICC_VERSION}/substitute_headers/ && 
     158chown -vR 0:0 opt/ && 
     159find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type d \ 
     160        -exec chmod -v 755 {} \; && 
     161find opt/intel/cc/${ICC_VERSION}/substitute_headers/libio -type f \ 
     162        -exec chmod -v 644 {} \; 
     163 
    118164# Install the ICC headers: 
    119165 
    120 rpm2cpio intel-isubh9-9.0-???.i386.rpm | cpio -id && 
    121 tar -zxf opt/intel/cc/9.0/substitute_headers/libio.tar.gz -C \ 
    122         opt/intel/cc/9.0/substitute_headers/ && 
    123 chown -R 0:0 opt/ && 
    124 find opt/intel/cc/9.0/substitute_headers/libio -type d \ 
    125         -exec chmod 755 {} \; && 
    126 find opt/intel/cc/9.0/substitute_headers/libio -type f \ 
    127         -exec chmod 644 {} \; && 
    128 mv opt/intel/cc/9.0/substitute_headers/libio/* /opt/include && 
     166mv -v opt/intel/cc/${ICC_VERSION}/substitute_headers/libio/* \ 
     167        /usr/include/icc && 
    129168rm -rf opt/ 
    130169 
    131 # Install the debugger: 
    132  
    133 rpm2cpio intel-iidb9-9.0-???.i386.rpm | cpio -id && 
    134 rm -f opt/intel/idb/9.0//uninstall.sh && 
    135 chown -R 0:0 opt/ && 
    136 mv opt/intel/idb/9.0//bin/* /opt/bin && 
    137 mv opt/intel/idb/9.0//doc /opt/doc/idb && 
    138 mv opt/intel/idb/9.0//man/man1/* /opt/man/man1 && 
     170# Extract the rpm for the debugger: 
     171 
     172rpm2cpio intel-iidb*-${ICC_VERSION}*.i386.rpm | \ 
     173        cpio --make-directories --extract --verbose && 
     174rm -vf opt/intel/idb/${ICC_VERSION}/bin/uninstall.sh 
     175chown -vR 0:0 opt/ 
     176 
     177# Install the ICC debugger, idbvars.sh belongs in /etc: 
     178 
     179mv -v opt/intel/idb/${ICC_VERSION}/bin/idbvars.*sh /etc && 
     180mv -v opt/intel/idb/${ICC_VERSION}/bin/* /usr/bin && 
     181mv -v opt/intel/idb/${ICC_VERSION}/doc /usr/share/doc/idb-${ICC_VERSION} && 
     182mv -v opt/intel/idb/${ICC_VERSION}/man/man1/* /usr/share/man/man1 && 
    139183rm -rf opt/ 
    140184 
    141 # Install the license file: 
    142  
    143 install -m644 *_cpp_l_*.lic /opt/doc/icc/licenses 
    144  
    145 # Rebuild the linker cache file: 
    146  
    147 ldconfig 
    148  
    149 # Configure the compiler (you may need to correct your version number of the 
    150 # first one): 
    151  
    152 sed -e 's/<installpackageid>/l_cc_p_9\.0\.021/' \ 
    153         -i /opt/doc/icc/csupport 
    154  
    155 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    156         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    157         -e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' -i /opt/bin/icc 
    158  
    159 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    160         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    161         -e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' \ 
    162         -e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/iccvars.csh 
    163  
    164 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    165         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    166         -e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' \ 
    167         -e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/iccvars.sh 
    168  
    169 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    170         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    171         -e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' -i /opt/bin/icpc 
    172  
    173 source /opt/bin/iccvars.sh 
    174  
    175 # If you get "bash: man: command not found", don't worry about it right now. 
    176  
    177 # Configure the debugger (make sure the version of the first one is correct): 
    178  
    179 sed -e 's/<INSTALLTIMECOMBOPACKAGEID>/l_cc_p_9\.0\.026/' \ 
    180         -i /opt/doc/idb/idbsupport 
    181  
    182 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    183         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    184         -e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/idbvars.csh 
    185  
    186 sed -e 's/<INSTALLDIR>\/licenses/\/opt\/doc\/icc\/licenses/g' \ 
    187         -e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \ 
    188         -e 's/<INSTALLDIR>\/man/\/opt\/man/g' -i /opt/bin/idbvars.sh 
    189  
    190 source /opt/bin/idbvars.sh 
    191  
    192 # For reasons unknown to me, ICC links to libgcc_s.so. On an LFS system 
    193 # libgcc_s.so is in /usr/lib. Incase you have /usr on a seperate partition we 
    194 # need to move libgcc_s.so to /lib: 
    195  
    196 cp /usr/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 && 
    197 ln -s libgcc_s.so.1 /lib/libgcc_s.so && 
    198 rm -f /usr/lib/libgcc_s.so* 
    199  
    200 # If you plan to use ICC to compile most of the LFS system, the runtime 
    201 # library should be moved to /lib: 
    202  
    203 mv /opt/lib/libimf.so /lib && 
    204 ln -s ../../lib/libimf.so /opt/lib/libimf.so 
    205  
    206 # Now we can use the Intel compiler. You should read: 
     185# **************************************** 
     186# - INSTALLING ICC - Configuring ICC files 
     187# **************************************** 
     188 
     189# The compiler suite is installed. Now we set it up. First install the 
     190# license file: 
     191 
     192install -v -m444 *.lic /usr/share/doc/icc-${ICC_VERSION}/licenses/ 
     193 
     194# Configure the compiler: 
     195 
     196sed -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 
     199 
     200sed -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 
     204 
     205sed -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 
     209 
     210sed -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 
     215 
     216sed -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 
     221 
     222source /etc/iccvars.sh 
     223 
     224# If you get "bash: manpath: command not found", don't worry about it. 
     225 
     226# Configure the Intel debugger: 
     227 
     228sed -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 
     231 
     232sed -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 
     236 
     237sed -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 
     241 
     242source /etc/idbvars.sh 
     243 
     244# - INSTALLING ICC - Configuring system files: 
     245 
     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): 
     250 
     251mv -v /usr/lib/libgcc_s.so.1 /lib/ && 
     252rm -v /usr/lib/libgcc_s.so && 
     253ln -vs libgcc_s.so.1 /lib/libgcc_s.so 
     254 
     255# We also need to tell ICC where to find the headers we installed to 
     256# /usr/include/icc: 
     257 
     258echo "-I/usr/include/icc" >> /usr/bin/icc.cfg 
     259echo "-I/usr/include/icc" >> /usr/bin/icpc.cfg 
     260echo "-I/usr/include/icc/c++" >> /usr/bin/icpc.cfg 
     261 
     262# Now we can use the Intel compiler. 
     263 
     264# Test ICC to see that it is working: 
     265 
     266echo "int main () {return 0;}" > /tmp/main.c && 
     267icc -o /tmp/main /tmp/main.c && 
     268/tmp/main && 
     269rm /tmp/main{,.c} 
     270 
     271# If there are no errors then it worked. 
     272 
     273# You can unset these now: 
     274 
     275unset ICC_VERSION ICC_V_MAJOR ICC_V_MINOR ICC_V_PATCH 
     276 
     277# Now we can configure the system to use ICC. 
     278 
     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: 
     284 
     285cat > /usr/share/config.site-icc << "EOF" 
     286CC="icc" 
     287CXX="icpc" 
     288LD="xild" 
     289AR="xiar" 
     290LANG="en" 
     291LANGUAGE="en" 
     292LC_ALL="C" 
     293EOF 
     294 
     295# If you want to build most of your LFS system with ICC you should export 
     296# this site configuration: 
     297 
     298export CONFIG_SITE="/usr/share/config.site-icc" 
     299 
     300# If you only want to use ICC for specific packages then you can use this: 
     301 
     302env CONFIG_SITE="/usr/share/config.site-icc" ./configure... 
     303 
     304# *************** 
     305# - Optimizations 
     306# *************** 
     307 
     308# Now you can read the ICC man pages for more information about its features 
     309# and usage. 
     310 
     311# You should also look at: 
    207312# http://gentoo-wiki.com/HOWTO_ICC_and_Portage#CFLAGS 
    208313 
    209 # And figure out your CFLAGS, if you are using CFLAGS. You can't use 
    210 # -fomit-frame-pointer or -pipe, and a few others. For the sake of this hint, 
    211 # and copy pasting, lets set special ICC CFLAGS now. On my Prescott I use this: 
    212  
    213 export ICC_CFLAGS="-ip -xP -O3" 
    214 export ICC_CXXFLAGS="$ICC_CFLAGS" 
    215  
    216 # Interprocedural optimizations (IPO) is a fantastic feature which optimizes 
    217 # executables at link time. This allows the compiler to make better judgements. 
    218 # A similiar option was added to GCC-4.1, -fwhole-program --combine. Using this 
    219 # option is a bit touchy though. The -ipo flag can only be used on executables, 
    220 # and not static libraries. Almost every package has static libraries which are 
    221 # linked into the programs during the build. The HLFS book happens to use the 
    222 # -fpie option which has the same requirements. To use the ICC -ipo option, check 
    223 # the HLFS book for the sed commands which add -fpie to Makefile.in's. Replace the 
    224 # "-pie -fpie" with "-ipo". The sed command for each package is different. 
    225 # Unfortunetly these commands are not available for most of the BLFS packages. 
    226  
    227 # Run this to break GCC compatability (some packages need this): 
    228  
    229 echo "-no-gcc" >> /opt/bin/icc.cfg 
    230  
    231 # Libraries compiled with ICC should get -gcc added to CFLAGS, so that 
    232 # programs compiled with GCC can use the libraries compiled with ICC. 
    233  
    234 # INSTALLING PACKAGES (Chapter 6): 
    235  
    236 # Use the GCC4 patches from LFS. 
    237  
    238 # For every package built with ICC make sure to run the testsuite because this 
    239 # is still expirmental. If one or more tests fail, retry with GCC. If the 
    240 # results are better with GCC, then use GCC. 
    241  
    242 # Don't worry about: 
    243 # "icc: warning: PGOPTI instrumentation disables IP optimizations" 
    244 # This warning is given when using -ip (-fomit-frame-pointer) while generating 
    245 # code profiles. -ip will work with the second build. 
    246  
    247 # To keep this hint shorter, I won't give complete instructions for every 
    248 # package, but I'll give notes where needed. 
    249  
    250 # To use ICC profiling we need to add "-prof_gen" and "-prof_dir=$(pwd)" to 
    251 # CFLAGS/CXXFLAGS for the first build. Then run 'make check' in order to run the 
    252 # programs and generate profiling data. If you are able to run the programs better 
    253 # than how 'make check' does, then I suggest you do that. Then 'make clean', and 
    254 # make again with "-prof_use". You can run 'make check' again if you like, and 
    255 # finally 'make install'. 
    256  
    257 # In general, use this: 
    258  
    259 env CFLAGS="$ICC_CFLAGS -prof_gen -prof_dir=$(pwd)" \ 
    260         CXXFLAGS="$ICC_CXXFLAGS -prof_gen -prof_dir=$(pwd)" LC_ALL="C" \ 
    261         LANG="en" LANGUAGE="en" CC="icc" CXX="icpc" ./configure... 
    262  
    263 # Then 'make && make check && make clean', and final build with: 
    264  
    265 env CFLAGS="$ICC_CFLAGS -prof_use -prof_dir=$(pwd)" \ 
    266         CXXFLAGS="$ICC_CXXFLAGS -prof_use -prof_dir=$(pwd)" LC_ALL="C" \ 
    267         LANG="en" LANGUAGE="en" CC="icc" CXX="icpc" ./configure... 
    268  
    269 # Then 'make && make install'. 
    270  
    271 # DB can not be compiled with ICC. 
    272  
    273 # Coreutils can compile with ICC profiling. 
    274  
    275 # Zlib can compile with ICC, but X11 will not be able to link to it, so I do not 
    276 # suggest it. 
    277  
    278 # Mktemp can compile with ICC profiling. 
    279  
    280 # Iana-Etc has no C/C++ code. 
    281  
    282 # Findutils can be compiled with ICC profiling. 
    283  
    284 # Gawk can compile with ICC profiling. 
    285  
    286 # Ncurses can compile with ICC profiling. We add the -gcc flag because Ncurses 
    287 # is a library. Ncurses also has C++ code, so CXX flags are also added. 
    288  
    289 # Readline can compile with ICC profiling, and because it is a library -gcc 
    290 # needs to be added to CFLAGS. 
    291  
    292 # Vim can compile with ICC profiling. 
    293  
    294 # M4 can compile with ICC profiling. 
    295  
    296 # Bison can compile with ICC profiling. 
    297  
    298 # Less can compile with ICC profiling. 
    299  
    300 # Groff can compile with ICC profiling. 
    301  
    302 # Sed can compile with ICC profiling. 
    303  
    304 # Flex can compile with ICC profiling. 
    305  
    306 # Gettext can compile with ICC profiling, but because it's a library add -gcc. 
    307  
    308 # Inetutils can compile with ICC profiling. 
    309  
    310 # For Iproute2 do (Iproute2 needs -gcc): 
    311  
    312 sed -e 's/gcc/icc/g' -i Makefile && 
    313 sed -e "s|^CCOPTS .*$|& $ICC_CFLAGS -gcc -prof_gen -prof_dir=/tmp|" \ 
    314         -i Makefile 
    315  
    316 # Then 'make' and 'make clean', and: 
    317  
    318 sed -e 's/prof_gen/prof_use/g' -i Makefile 
    319  
    320 # And 'make' and 'make install'. 
    321  
    322 # Warning! Building Perl with profiling has frozen my desktop, beware. 
    323 # Perl can compile with ICC profiling. After 'make distclean' you will have to 
    324 # run ./configure again, substituting -prof_gen with -prof_use. 
    325  
    326 # Texinfo can compile with ICC profiling. 
    327  
    328 # Autoconf and Automake are scripts, and do not need to be compiled with ICC. 
    329  
    330 # Bash compiles with ICC but will crash at runtime. Do not compile Bash with 
    331 # ICC. 
    332  
    333 # File can compile with ICC profiling. 
    334  
    335 # Libtool can compile with ICC profiling. 
    336  
    337 # For Bzip2 do this after applying the patches (add -gcc to the library): 
    338  
    339 sed -e 's|gcc|icc|g' -i Makefile* && 
    340 sed -e "s|^CFLAGS.*$|& $ICC_CFLAGS -prof_gen -prof_dir=/tmp|g" -i Makefile && 
    341 sed -e "s|^CFLAGS.*$|& $ICC_CFLAGS -prof_gen -prof_dir=/tmp -gcc|g" \ 
    342         -i Makefile-libbz2_so 
    343  
    344 # After 'make clean': 
    345  
    346 make && 
    347 make -f Makefile-libbz2_so clean && 
    348 sed -e 's/prof_gen/prof_use/g' -i Makefile* && 
    349 make -f Makefile-libbz2_so && 
    350 make clean 
    351  
    352 # Then run 'make' and 'make install'. 
    353  
    354 # Diffutils can compile with ICC profiling. 
    355  
    356 # - For Kbd, after running ./configure, make like this: 
    357  
    358 make CC="icc" CFLAGS="$ICC_CFLAGS -prof_gen -prof_dir=$(pwd)" && 
    359 make clean && 
    360 make CC="icc" CFLAGS="$ICC_CFLAGS -prof_use -prof_dir=$(pwd)" 
    361  
    362 # E2fsprogs can compile with ICC profiling. We have to re-run ./configure 
    363 # like with Perl, substituting -prof_gen with -prof_use on the second pass. 
    364  
    365 # Grep can compile with ICC profiling. 
    366  
    367 # Grub does not compile with ICC. 
    368  
    369 # Gzip can compile with ICC profiling. 
    370  
    371 # Hotplug has no C code. 
    372  
    373 # Man doesn't do profiling, but can compile with ICC: 
    374  
    375 make CC="icc" CFLAGS="$ICC_CFLAGS" 
    376  
    377 # Make can compile with ICC profiling. 
    378  
    379 # - For Module-init-tools you will need to use a patch to disable the static 
    380 # linking of insmod: 
    381 # http://www.linuxfromscratch.org/patches/downloads/module-init-tools/\ 
    382 #       module-init-tools-3.2.1-nostatic-1.patch 
    383  
    384 # Module-init-tools can compile with ICC profiling. 
    385  
    386 # Patch can compile with ICC profiling. 
    387  
    388 # Procps does not compile with ICC. 
    389  
    390 # Psmisc can compile with ICC profiling. 
    391  
    392 # Shadow can compile with ICC profiling. 
    393  
    394 # Sysklogd doesn't do profiling, but can compile with ICC: 
    395  
    396 make CC="icc" CFLAGS="-DSYSV $ICC_CFLAGS" 
    397  
    398 # Sysvinit doesn't do profiling, but can compile with ICC: 
    399  
    400 make -C src CC="icc" CFLAGS="$ICC_CFLAGS -D_GNU_SOURCE" 
    401  
    402 # Tar can compile with ICC profiling. 
    403  
    404 # Udev does not compile with ICC. 
    405  
    406 # Util-linux needs GCC for mkfs.minix. 
     314# and: 
     315# http://sc.tamu.edu/help/intel/9.0/main_cls/mergedProjects/optaps_cls/whnjs.htm 
     316 
     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 
     319 
     320# We can add our optimizations to the ICC config file. This is what I use for 
     321# my Prescott: 
     322 
     323# The -xP optimization is just like GCC's -march=prescott: 
     324 
     325echo "-xP" >> /usr/bin/icc.cfg 
     326echo "-xP" >> /usr/bin/icpc.cfg 
     327 
     328# Note that -axP is just like '-march=i586 -mtune=prescott'. 
     329 
     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: 
     333 
     334echo "-fomit-frame-pointer" >> /usr/bin/icc.cfg 
     335echo "-fomit-frame-pointer" >> /usr/bin/icpc.cfg 
     336 
     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: 
     341 
     342echo "-mno-ieee-fp" >> /usr/bin/icc.cfg 
     343echo "-mno-ieee-fp" >> /usr/bin/icpc.cfg 
     344 
     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: 
     349 
     350echo "-no-prec-div" >> /usr/bin/icc.cfg 
     351echo "-no-prec-div" >> /usr/bin/icpc.cfg 
     352 
     353# The -rcd enabled fast float-to-int conversions. This option breaks ANSI 
     354# conformance: 
     355 
     356echo "-rcd" >> /usr/bin/icc.cfg 
     357echo "-rcd" >> /usr/bin/icpc.cfg 
     358 
     359# This option tells ICC which GCC version to be compatable with: 
     360 
     361echo "-gcc-version=410" >> /usr/bin/icc.cfg 
     362echo "-gcc-version=410" >> /usr/bin/icpc.cfg 
     363 
     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: 
     369 
     370echo "-no-gcc" >> /usr/bin/icc.cfg 
     371echo "-no-gcc" >> /usr/bin/icpc.cfg 
     372 
     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: 
     378 
     379-prof-gen 
     380./a.out 
     381-prof-gen-sampling -prof-use 
     382profrun -dcache ./a.out 
     383-prof-use -ssp 
     384 
     385# The newer Pentium4 cpus perform Hardware-based Speculative Pre-computation, 
     386# so I have never tried to use the -ssp option. 
     387 
     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. 
     392 
     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). 
     398 
     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. 
     402 
     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. 
     406 
     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. 
     413 
     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. 
     421 
     422# The -ipo option does not work with private static libraries, which most 
     423# packages have. So -ipo has to be surgically added. 
     424 
     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. 
     428 
     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. 
     440 
     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. 
     450 
     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. 
     459 
     460# The following commands will add the profiling options to a few scripts, 
     461# including additional optimizations when profile data is being used: 
     462 
     463cat > /usr/bin/prof_gen-env << "EOF" 
     464unset CONFIG_SITE 
     465export LANG="en" 
     466export LANGUAGE="en" 
     467export LC_ALL="C" 
     468export LD="xild" 
     469export AR="xiar" 
     470export CFLAGS="-O2" 
     471export CXXFLAGS="-O2" 
     472export CC="icc -prof_gen -prof_dir=$(pwd)" 
     473export CXX="icpc -prof_gen -prof_dir=$(pwd)" 
     474"$@" 
     475EOF 
     476chmod -v +x /usr/bin/prof_gen-env 
     477 
     478cat > /usr/bin/prof_use-env << "EOF" 
     479unset CONFIG_SITE 
     480export LANG="en" 
     481export LANGUAGE="en" 
     482export LC_ALL="C" 
     483export LD="xild" 
     484export AR="xiar" 
     485export CFLAGS="-O2 -ipo0" 
     486export CXXFLAGS="-O2 -ipo0" 
     487export CC="icc -prof_use -prof_dir=$(pwd)" 
     488export CXX="icpc -prof_use -prof_dir=$(pwd)" 
     489nice -n 19 "$@" 
     490EOF 
     491chmod -v +x /usr/bin/prof_use-env 
     492 
     493cat > /usr/bin/prof_use-fast-env << "EOF" 
     494unset CONFIG_SITE 
     495export LANG="en" 
     496export LANGUAGE="en" 
     497export LC_ALL="C" 
     498export LD="xild" 
     499export AR="xiar" 
     500export CFLAGS="-O3 -fast -ipo0" 
     501export CXXFLAGS="-O3 -fast -ipo0" 
     502export CC="icc -prof_use -prof_dir=$(pwd)" 
     503export CXX="icpc -prof_use -prof_dir=$(pwd)" 
     504nice -n 19 "$@" 
     505EOF 
     506chmod -v +x /usr/bin/prof_use-fast-env 
     507 
     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: 
     512 
     513cat > /usr/bin/icc-make << "EOF" 
     514nice make AR="xiar" LD="xild" "$@" 
     515EOF 
     516chmod -v +x /usr/bin/icc-make 
     517 
     518# Use 'icc-make' instead of 'make' whenever you are compiling with ICC. 
     519 
     520# *********************** 
     521# - Building LFS packages 
     522# *********************** 
     523 
     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: 
     527 
     528echo 'CFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc 
     529echo 'CXXFLAGS="-ipo0 -O2"' >> /usr/share/config.site-icc 
     530 
     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. 
     535 
     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. 
     539 
     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 ???'. 
     545 
     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. 
     553 
     554# In general, to profile packages, we would do something like this: 
     555 
     556prof_gen-env ./configure && 
     557icc-make && 
     558icc-make check && 
     559icc-make distclean && 
     560prof_use-env ./configure && 
     561icc-make && 
     562icc-make install 
     563 
     564# Packages (in the "Linux From Scratch - Version SVN-20061029" order): 
     565 
     566# You should unset environment CFLAGS/CXXFLAGS, if you set them, so that 
     567# ICC will use the optimizations in the icc config files. 
     568 
     569# You should also run the testsuies whether you are using profiling or not. 
     570 
     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. 
     577 
     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: 
     584 
     585sed -e 's/-.*PIC/& -gcc /' -i unix/configure 
     586 
     587# To profile TCL (make sure the ./configure --options are the same as in the 
     588# BLFS book): 
     589 
     590cd unix && 
     591prof_gen-env ./configure --prefix=/usr --enable-threads && 
     592icc-make && 
     593icc-make test 
     594 
     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: 
     598 
     599icc-make distclean && 
     600prof_use-env ./configure --prefix=/usr --enable-threads && 
     601icc-make 
     602 
     603# You can 'make test' again if you're paranoid. Then install TCL. 
     604 
     605# We need GCC compatability with Berkeley DB libraries for Man-DB: 
     606 
     607sed -e 's/-.*PIC/& -gcc /' -i dist/configure 
     608 
     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: 
     611 
     612cd build_unix && 
     613prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \ 
     614        --enable-tcl --with-tcl=/usr/lib --enable-test && 
     615icc-make 
     616 
     617# Then to run the testsuite open the tclsh shell: 
     618 
     619tclsh 
     620 
     621# At the % promt run the tests (this will take hours): 
     622 
     623source ../test/test.tcl 
     624run_parallel 5 run_std 
     625exit 
     626 
     627# Then clean Berkeley DB and rebuild: 
     628 
     629icc-make realclean && 
     630prof_gen-env ../dist/configure --prefix=/usr --enable-cxx \ 
     631        --enable-tcl --with-tcl=/usr/lib && 
     632icc-make 
     633 
     634# Then install Berkeley DB. 
     635 
     636# - E2fsprogs 
     637# E2fsprogs does not build properly with ICC. Build E2fsprogs with GCC: 
     638 
     639env -u CONFIG_SITE ../configure... 
     640make 
     641 
     642# - Coreutils 
     643# Build Coreutils with profiling: 
     644 
     645prof_gen-env ./configure --prefix=/usr && 
     646icc-make 
     647 
     648# Then run the testsuite, distclean, and rebuild with the profiling 
     649# information: 
     650 
     651prof_use-env ./configure --prefix=/usr && 
     652icc-make 
     653 
     654# Then install Coreutils. 
     655 
     656# - Iana-Etc has nothing to compile. 
     657 
     658# - M4 
     659# M4 is typical. Build and install it just like Coreutils. 
     660 
     661# - Bison: 
     662# Bison is a typical build, like M4. 
     663 
     664# - Ncurses 
     665# Ncurses builds with ICC, but I had serious issues with Bash. So for now 
     666# I suggest building Ncurses with GCC: 
     667 
     668env -u CONFIG_SITE ./configure... 
     669 
     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. 
     673 
     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: 
     678 
     679prof_gen-env ./configure... 
     680icc-make 
     681icc-make check 
     682icc-make distclean 
     683prof_use-fast-env ./configure... 
     684icc-make 
     685 
     686# Then install Sed. 
     687 
     688# - Libtool 
     689# 'libtool' itself is a script, but the package includes a library. To add 
     690# GCC compatability (this is optional): 
     691 
     692sed -e 's/^CFLAGS =/& -gcc/' -i libltdl/Makefile.in 
     693 
     694# Then profile Libtool like Coreutils, but use 'make clean' instead of 
     695# 'distclean'. 
     696 
     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. 
     702 
     703# - Readline 
     704# Readline is a library and you may want to add -gcc (I don't): 
     705 
     706sed -e 's/^CFLAGS =/& -gcc/' -i {,shlib/}Makefile.in 
     707 
     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'. 
     711 
     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: 
     714 
     715env -u CONFIG_SITE ./configure... 
     716 
     717# - Autoconf and Automake are perl scripts. 
     718 
     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: 
     725 
     726prof_gen-env ./configure... 
     727icc-make 
     728icc-make tests 
     729icc-make distclean 
     730nice -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... 
     733icc-make 
     734 
     735# Then install Bash. 
     736 
     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. 
     740 
     741icc-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 && 
     744icc-make clean && 
     745icc-make CC=icc CFLAGS="-prof_gen -prof_dir=$(pwd) \ 
     746        -D_FILE_OFFSET_BITS=64 -O2" \ 
     747                AR=xiar LD=xild 
     748 
     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: 
     752 
     753dd if=/dev/urandom of=urandom.file bs=1M count=17 
     754env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared urandom.file 
     755env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d urandom.file.bz2 
     756cat CHANGES LICENSE bzip2 | \ 
     757        env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -4 -c > non-random.bz2 
     758env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared -d non-random.bz2 
     759env LD_PRELOAD=./libbz2.so.1.0 ./bzip2-shared --help 
     760 
     761# Then rebuild Bzip2 with the profiling data: 
     762 
     763icc-make clean && 
     764icc-make -f Makefile-libbz2_so clean && 
     765icc-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 && 
     767icc-make clean && 
     768icc-make CC=icc CFLAGS="-prof_use -prof_dir=$(pwd) -D_FILE_OFFSET_BITS=64 \ 
     769        -ipo0 -fast" AR=xiar LD=xild 
     770 
     771# Then when installing bzip2, do not install the 'bzip2-shared' version, 
     772# install the statically linked (with -fast) 'bzip2' file instead. 
     773 
     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'. 
     776 
     777# - File 
     778# File builds with ICC, and does not have a testsuite, just like Diffutils. 
     779 
     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: 
     785 
     786prof_gen-env ./configure... 
     787icc-make 
     788icc-make check 
     789icc-make distclean 
     790prof_use-fast-env ./configure... 
     791icc-make 
     792  
     793# Then install Findutils. 
     794 
     795# - Flex 
     796# Build and install Flex typically, like Coreutils and M4. 
     797 
     798# - Grub does not compile with ICC: 
     799 
     800env -u CONFIG_SITE ./configure... 
     801 
     802# - Gawk 
     803# Build and install Gawk typically, like Flex. I used -fast with Gawk, via 
     804# prof_use-fast-env. 
     805 
     806sed -e 's/CFLAGS =/& -fast/' -i {,awklib/}Makefile && 
     807make-icc-prof_use 
     808 
     809# Then install Gawk. 
     810 
     811# - Gettext 
     812# Gettext contains libraries, so you may want to add -gcc (I don't): 
     813 
     814find gettext-runtime/ -name Makefile.in \ 
     815        -exec sed -e 's/^CFLAGS =/& -gcc/' -i {} \; 
     816 
     817# I couldn't get Gettext to build with -ipo, but it builds with profiling. 
     818# After 'make distclean': 
     819 
     820nice -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.. 
     822 
     823# - Grep 
     824# Build and install Grep typically. I used -fast for Grep too. 
     825 
     826# - Groff 
     827# Groff does not build with -ipo, and does not have a testsuite. Build Groff 
     828# like this: 
     829 
     830env -u CONFIG_SITE CC="icc" CXX="icpc" LD="xild" AR="xiar" \ 
     831        LANG="en" LANGUAGE="en" LC_ALL="C" ... 
     832 
     833# Remember to use 'icc-make'. 
     834 
     835# - Gzip 
     836# Gzip doesn't have a testsuite, but we can mimick one: 
     837 
     838dd if=/dev/urandom of=urandom.file bs=2M count=10 
     839./gzip -9 urandom.file 
     840./gzip -d urandom.file.gz 
     841cat AUTHORS README README-alpha ChangeLog | ./gzip -4 -c > non-random.gz 
     842./gzip -d non-random.gz 
     843 
     844# I build Gzip with -fast too. 
     845 
     846# - Inetutils 
     847# Inetutils does not have a testsuite but will compile with ICC. 
     848 
     849# - Iproute2 
     850# Iproute2 needs the -gcc option, and does not have a testsuite: 
     851 
     852icc-make SBINDIR=/sbin CC="icc -gcc" && 
     853icc-make SBINDIR=/sbin CC="icc -gcc" install 
     854 
     855# - Kdb 
     856# Kbd does not have a testsuite: 
     857 
     858icc-make CC="icc" 
     859 
     860# - Less 
     861# Less does not have a testsuite. Configure and build it normally. 
     862 
     863# - Make 
     864# Build and install Make typically. 
     865 
     866# - Man-DB 
     867# Man-DB does not have a testsuite. Configure and build it normally. 
     868 
     869# - Mktemp 
     870# Mktemp does not have a testsuite, but we can simulate one: 
     871 
     872./mktemp --help 
     873./mktemp -V 
     874./mktemp -p . && ./mktemp -p . XXXXXXXX 
     875./mktemp -p . -d && ./mktemp -p . -d XXXXXXXX 
     876