intel-c-compiler hint

Robert Connolly robert at linuxfromscratch.org
Mon Jul 4 16:18:40 PDT 2005


This hint works now (I can reboot it). The attached hint is a proposed 
adoption of the intel-c-compiler hint.

robert
-------------- next part --------------
AUTHOR:	Robert Connolly <robert at linuxfromscratch dot org> (ashes)
	Daniel Baumann <daniel.baumann at panthera-systems.net>

DATE: 2005-07-04

LICENSE: GNU General Public License

SYNOPSIS: How to install the Intel C/C++ Compiler for LFS.

PRIMARY URI:
http://www.linuxfromscratch.org/hints/downloads/files/intel-c-compiler.txt

DESCRIPTION:
How to install the Intel C/C++ Compiler for your LFS-system.

PREREQUISITES:
An Intel CPU (this does not work with AMD or other non-Intel).

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 Glibc, the Linux kernel, or X11; maybe they will in the future.

The homepage for the Intel compiler is here:
http://www.intel.com/software/products/compilers/clin/

You should also see:
http://gentoo-wiki.com/HOWTO_ICC_and_Portage

This compiler is not free, and there is no source provided. It only links to
/lib (without radical CFLAGS).

This hint will give instructions to build the 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 many packages. You can choose to install ICC
without using it to build the LFS system, or build just some packages, it's upto
you.

Intel's compiler is only free of charge for non-commercial use. If that is what
you want then go here:

http://www.intel.com/software/products/compilers/clin/noncom.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.

After that you should have two files (the numbers may be different):

l_cc_pc_8.1.028.tar.gz
and
noncommercial_cpp_l_N4R8-B2RV9P4B.lic

# INSTALLATION:

# At the end of chaper 5 we will need to install Cpio, and rpm2cpio.

# Get: ftp://ftp.gnu.org/pub/gnu/cpio/cpio-2.6.tar.gz

# And install Cpio to /tools:

sed -i -e "s/invalid_arg/argmatch_invalid/" src/mt.c &&
./configure CPIO_MT_PROG=mt --prefix=/tools \
	--bindir=/tools/bin --libexecdir=/tmp \
	--with-rmt=/tools/bin/rmt &&
echo "#define HAVE_SETLOCALE 1" >> config.h &&
make &&
make install

# If you want to install Cpio to an existing system then follow the instructions
# in: http://www.linuxfromscratch.org/blfs/view/svn/general/cpio.html

# Then get: http://www.rpm.org/tools/scripts/rpm2cpio.sh

# And install rpm2cpio to /tools with:

install rpm2cpio.sh /tools/bin/rpm2cpio

# Or change it for /usr.

# Build chapter 6's Glibc, Binutils, and GCC normally. Install ICC after GCC is
# installed in chapter 6 (before Coreutils).

# Install the ICC compiler:

rpm2cpio intel-icc8-8.1-028.i386.rpm | cpio -id &&
rm -f opt/intel_cc_80/bin/uninstall.sh &&
chown -R 0:0 opt/ &&
cp opt/intel_cc_80/bin/* /opt/bin &&
cp -r opt/intel_cc_80/doc /opt/doc/icc &&
cp -r opt/intel_cc_80/include/* /opt/include &&
cp opt/intel_cc_80/lib/* /opt/lib &&
cp -r opt/intel_cc_80/licenses /opt/doc/icc &&
cp opt/intel_cc_80/man/man1/* /opt/man/man1 &&
rm -rf opt/

# Install the ICC headers:

rpm2cpio intel-isubh8-8.1-028.i386.rpm | cpio -id &&
tar --no-same-owner --no-same-permissions -zxf \
	opt/intel_cc_80/substitute_headers/libio.tar.gz -C /opt/include &&
rm -rf opt/

# Install the debugger:

rpm2cpio intel-iidb8-8.1-045.i386.rpm | cpio -id &&
rm -f opt/intel_idb_80/bin/uninstall.sh &&
chown -R 0:0 opt/ &&
mv opt/intel_idb_80/bin/* /opt/bin &&
mv opt/intel_idb_80/doc /opt/doc/idb &&
mv opt/intel_idb_80/man/man1/* /opt/man/man1 &&
rm -rf opt/

# Install the license file:

install -m644 *_cpp_l_*.lic /opt/doc/icc/licenses

# Rebuild the linker cache file:

ldconfig

# Configure the compiler (you may need to correct your version number of the
# first one):

sed -e 's/<installpackageid>/l_cc_p_8\.1\.028/' \
	-i /opt/doc/icc/csupport

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/\/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/\/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/\/opt\/doc\/icc\/licenses/g' \
	-e 's/<INSTALLDIR>\/bin/\/opt\/bin/g' \
	-e 's/<INSTALLDIR>\/lib/\/opt\/lib/g' -i /opt/bin/icpc

source /opt/bin/iccvars.sh

# If you get "bash: man: command not found" then don't worry about it right now.

# Configure the debugger (make sure the version of the first one is correct):

sed -e 's/<INSTALLTIMECOMBOPACKAGEID>/l_cc_p_8\.1\.028/' \
	-i /opt/doc/idb/idbsupport

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/\/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 /opt/bin/idbvars.sh

# 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:

cp /usr/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 &&
ln -s libgcc_s.so.1 /lib/libgcc_s.so &&
rm /usr/lib/libgcc_s.so*

# If you plan to use ICC to compile must of the LFS system, the runtime
# library should be moved to /lib:

mv /opt/lib/libimf.so /lib &&
ln -s ../../lib/libimf.so /opt/lib/libimf.so

# Now we can use the Intel compiler. You should read:
# 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:

export ICC_CFLAGS="-ip -xP -O2"
export ICC_CXXFLAGS="$ICC_CFLAGS"

# INSTALLING PACKAGES (Chapter 6):

# All you need to do is reset CC, CXX, CFLAGS, and CXXFLAGS. The first package
# that can be compiled wih ICC is Coreutils. So use something like this:

env CFLAGS="$ICC_CFLAGS" CXXFLAGS="$ICC_CXXFLAGS" \
	CC="/opt/bin/icc" CXX="/opt/bin/icc" \
	DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/usr

# 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. Coreutils tests should pass.

# Before ./configure of each package you want to compile with ICC use this:

env CFLAGS="$ICC_CFLAGS" CXXFLAGS="$ICC_CXXFLAGS" \
	CC="/opt/bin/icc" CXX="/opt/bin/icc"

# The LFS packages that will compile well with ICC are:
#
# Coreutils

# Zlib <-- Remember to add -fpic to CFLAGS
# If you are planning to install X11 then you should build Zlib with GCC, or
# else you will have errors linking X11 to libz.

# Mktemp
# Findutils
# Readline
# Vim
# M4
# Bison
# Less
# Gettext
# Inetutils
# Iproute2

# For Iproute2 do:

sed -e 's at gcc@/opt/bin/icc at g' -i Makefile &&
sed -e "s/^CFLAGS .*$/& $ICC_CFLAGS/" -i Makefile

# Perl
# Texinfo
# Autoconf
# Automake
# File
# Libtool
# Bzip2

# For Bzip2 do:

sed -e 's at gcc@/opt/bin/icc at g' -i Makefile &&
sed -e "s/^CFLAGS .*$/& $ICC_CFLAGS/" -i Makefile

# Other programs will have problems linking to libbz2 if it is compiled
# with ICC, so libbz2 should be compiled with GCC. Bzip2 itself can work with
# ICC.

# Diffutils
# Kbd
# E2fsprogs
# Grep
# Gzip
# Man
# Make
# Module-init-tools

# 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.1-nostatic-1.patch

# Patch
# Psmisc
# Shadow
# Sysvinit

# For Sysvinit do:

sed -e 's at gcc@/opt/bin/icc at g' \
	-e 's/-fomit-frame-pointer//g' \
	-e "s/^CFLAGS.*$/& $ICC_CFLAGS/" -i src/Makefile

# Tar
# Udev

# For Udev do:

make udevdir=/dev CC=/opt/bin/icc LD=/opt/bin/icc HOSTCC=/opt/bin/icc

# Util-linux

# For Util-linux do:

sed -e 's/-mtune=i486//g' -i configure &&
sed -e 's/-fomit-frame-pointer//g' -i MCONFIG

# And then use the env command before ./configure.

# After LFS is installed do this:

echo "source /opt/bin/idbvars.sh" >> /etc/profile
echo "source /opt/bin/iccvars.sh" >> /etc/profile
echo 'export ICC_CFLAGS="-ip -xP -O2"' >> /etc/profile
echo 'export ICC_CXXFLAGS="$ICC_CFLAGS"' >> /etc/profile
source /etc/profile

# Beyond LFS packages which compile well with ICC:

# OpenSSL

# For OpenSSL do this after ./config, and before make:

sed -e 's at gcc@/opt/bin/icc at g' \
	-e 's/-fomit-frame-pointer//g' \
	-e 's/-mcpu=pentium//g' \
	-e 's/-O3//g' \
	-e "s/^CFLAG.*$/& $ICC_CFLAGS/" -i Makefile

# OpenSSH
# Freetype
# Expat
# Fontconfig
# Jpeg-6b
# Freeglut
# Lcms
# Libmng

# For Libmng do:

sed -e 's at gcc@/opt/bin/icc@' -i Makefile &&
sed -e "s/^CFLAGS .*$/& $ICC_CFLAGS/" -i Makefile

# Qt

# For Qt do:

sed -e "s/^QMAKE_CFLAGS_RELEASE.*$/& $ICC_CFLAGS/" \
        -i mkspecs/linux-icc/qmake.conf

# And add "-platform linux-icc -thread" to the ./configure command.

# Glib
# Gtk
# Pkgconfig
# Glib2
# Pango
# Atk
# Gtk2
# Libogg
# Libxml
# Libxst
# Audiofile
# Libmad
# Which
# GnuPG
# Cdparanoia
# Libungif
# Giflib
# Imlib2
# Aalib
# SDL
# Libdvdcs
# Libdvdread
# Xvidcore
# Lzo

# Lame
# If Lame is compiled with ICC it will cause problems with other packages, like
# FFmpeg, which try to link to libmp3lame. This package should be compiled with
# GCC.

# Xine-lib
# Popt
# Libao
# Flac123
# Wget
# Cvs
# Ncftp
# Subversion
# Ntp
# Lynx
# Bind-utils
# Vorbis-tools
# Mpg123

# For Mpg123 do:

sed -e 's at gcc@/opt/bin/icc at g' -i Makefile

# LibIDL
# Zip

# For Zip do:

sed -e 's at gcc@icc at g' -i unix/Makefile

# And use "generic_icc" when you run make.

# Unzip

# For Unzip do this after applying the patches to Unzip:

sed -e 's at gcc@icc at g' -i unix/Makefile

# Vorbisgain
# Libaal
# Reiser4progs
# Cdrtools

# 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...

ACKNOWLEDGMENTS:
	* Thanks to Daniel Baumann for the original hint.
	* Thanks to Gentoo for their wiki page:
		http://gentoo-wiki.com/HOWTO_ICC_and_Portage

CHANGELOG:
[2005-06-25]
	* Adopted hint.
[2005-06-26]
	* Added more supported packages.
{2005-07-04]
	* It can reboot now.


More information about the hints mailing list