- add a new article describing how to use custom gcc from ports
Submitted by: mm Reviewed by: doc (Wayne Sierke, rene, tabthorpe, trhodes)
This commit is contained in:
parent
c79b4cbb0e
commit
df84f188c2
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=34669
3 changed files with 245 additions and 0 deletions
|
@ -13,6 +13,7 @@ SUBDIR+= contributing
|
|||
SUBDIR+= contributing-ports
|
||||
SUBDIR+= contributors
|
||||
SUBDIR+= cups
|
||||
SUBDIR+= custom-gcc
|
||||
SUBDIR+= cvs-freebsd
|
||||
SUBDIR+= cvsup-advanced
|
||||
SUBDIR+= dialup-firewall
|
||||
|
|
18
en_US.ISO8859-1/articles/custom-gcc/Makefile
Normal file
18
en_US.ISO8859-1/articles/custom-gcc/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
DOC?= article
|
||||
|
||||
FORMATS?= html
|
||||
WITH_ARTICLE_TOC?= YES
|
||||
|
||||
INSTALL_COMPRESSED?= gz
|
||||
INSTALL_ONLY_COMPRESSED?=
|
||||
|
||||
SRCS= article.sgml
|
||||
|
||||
URL_RELPREFIX?= ../../../..
|
||||
DOC_PREFIX?= ${.CURDIR}/../../..
|
||||
|
||||
.include "${DOC_PREFIX}/share/mk/doc.project.mk"
|
226
en_US.ISO8859-1/articles/custom-gcc/article.sgml
Normal file
226
en_US.ISO8859-1/articles/custom-gcc/article.sgml
Normal file
|
@ -0,0 +1,226 @@
|
|||
<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
|
||||
<!ENTITY % articles.ent PUBLIC "-//FreeBSD//ENTITIES DocBook FreeBSD Articles Entity Set//EN">
|
||||
%articles.ent;
|
||||
]>
|
||||
|
||||
<article>
|
||||
<articleinfo>
|
||||
<title>Using newer version of <application>GCC</application> and
|
||||
<application>binutils</application> with the &os; Ports
|
||||
Collection</title>
|
||||
|
||||
<author>
|
||||
<firstname>Martin</firstname>
|
||||
<surname>Matuska</surname>
|
||||
<affiliation>
|
||||
<address><email>mm@FreeBSD.org</email></address>
|
||||
</affiliation>
|
||||
</author>
|
||||
|
||||
<pubdate>$FreeBSD$</pubdate>
|
||||
|
||||
<legalnotice id="trademarks" role="trademarks">
|
||||
&tm-attrib.freebsd;
|
||||
&tm-attrib.general;
|
||||
</legalnotice>
|
||||
|
||||
<copyright>
|
||||
<year>2009</year>
|
||||
<holder>The &os; Documentation Project</holder>
|
||||
</copyright>
|
||||
|
||||
<abstract>
|
||||
<para>This article describes how to use newer versions of the
|
||||
<application>GCC</application> compilers and
|
||||
<application>binutils</application> from the &os; ports tree.
|
||||
Custom <application>GCC</application> configurations are also
|
||||
discussed.</para>
|
||||
</abstract>
|
||||
</articleinfo>
|
||||
|
||||
<sect1 id="intro">
|
||||
<title>Introduction</title>
|
||||
|
||||
<para>The default system compiler as of &os; 8.0 is
|
||||
<application>GCC</application> version 4.2.1. In addition, the
|
||||
base system of &os; includes <application>binutils</application>
|
||||
version 2.15. These versions are several years old and lack,
|
||||
among other things, support for recent <acronym>CPU</acronym>
|
||||
instructions like <acronym>SSSE3</acronym>,
|
||||
<acronym>SSE4.1</acronym>, <acronym>SSE4.2</acronym>, etc.
|
||||
Due to licensing issues, new versions of these applications will
|
||||
not be integrated into the base system. Luckily, it is possible
|
||||
to use a newer version of the <application>GCC</application>
|
||||
compiler (e.g. version 4.4) with the help of the &os; ports
|
||||
tree.</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="prerequisites">
|
||||
<title>Prerequisites</title>
|
||||
|
||||
<sect2 id="installing-binutils">
|
||||
<title>Installing binutils from ports</title>
|
||||
|
||||
<para>To make use of all of the new features in the latest
|
||||
<application>GCC</application> versions, the latest version of
|
||||
<application>binutils</application> needs to be installed.
|
||||
Installation of the newer version of
|
||||
<application>binutils</application> is optional; but without it,
|
||||
there will be no support for new <acronym>CPU</acronym>
|
||||
instructions.</para>
|
||||
|
||||
<para>To install the latest available version of
|
||||
<application>binutils</application> using the &os; ports tree,
|
||||
issue the following command:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>cd /usr/ports/devel/binutils && make install</userinput></screen>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="installing-gcc">
|
||||
<title>Installing GCC from ports</title>
|
||||
|
||||
<para>The &os; ports tree offers several new versions of
|
||||
<application>GCC</application>. The following example is for
|
||||
the stable version 4.4. However, it is possible to install
|
||||
previous or later development versions (e.g.
|
||||
<filename role="package">lang/gcc43</filename> or
|
||||
<filename role="package">lang/gcc45</filename>).</para>
|
||||
|
||||
<para>To install one of the mentioned
|
||||
<application>GCC</application> ports, run the following
|
||||
command:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>cd /usr/ports/lang/<replaceable>gcc44</replaceable> && make install</userinput></screen>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="configuring-ports-gcc">
|
||||
<title>Configuring ports for custom version of
|
||||
<application>GCC</application></title>
|
||||
|
||||
<para>Additional system configuration is required in order to use
|
||||
custom version of <application>GCC</application> installed from
|
||||
the &os; ports tree.<para>
|
||||
|
||||
<sect2 id="adjusting-make.conf">
|
||||
<title>Adjusting <filename>make.conf</filename></title>
|
||||
|
||||
<para>Add the following lines to the
|
||||
<filename>/etc/make.conf</filename> file (or modify
|
||||
appropriately):</para>
|
||||
|
||||
<programlisting>.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44)
|
||||
USE_GCC=4.4
|
||||
CPP=cpp44
|
||||
.endif</programlisting>
|
||||
|
||||
<para>Alternatively, it is possible to specify the
|
||||
<envar>${CC}</envar> and <envar>${CPP}</envar> variables
|
||||
manually.</para>
|
||||
|
||||
<note>
|
||||
<para>The examples above are for <application>GCC</application>
|
||||
version 4.4. To use <command>gcc43</command>, replace
|
||||
<literal>"gcc44"</literal> with <literal>"gcc43"</literal> and
|
||||
<literal>"4.4"</literal> with <literal>"4.3"</literal> and so
|
||||
on.</para>
|
||||
</note>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="adjusting-libmap.conf">
|
||||
<title>Adjusting <filename>libmap.conf</filename></title>
|
||||
|
||||
<para>Many of the ports' binaries and libraries link to libgcc_s
|
||||
or libstdc++. The base system already includes these libraries,
|
||||
but from an earlier version of <application>GCC</application>
|
||||
(version 4.2.1). To supply rtld (and ldd) with correct versions,
|
||||
add the following lines to the
|
||||
<filename>/etc/libmap.conf</filename> file (or modify
|
||||
appropriately):</para>
|
||||
|
||||
<programlisting>libgcc_s.so.1 gcc44/libgcc_s.so.1
|
||||
libgomp.so.1 gcc44/libgomp.so.1
|
||||
libobjc.so.3 gcc44/libobjc.so.2
|
||||
libssp.so.0 gcc44/libssp.so.0
|
||||
libstdc++.so.6 gcc44/libstdc++.so.6</programlisting>
|
||||
|
||||
<note>
|
||||
<para>The examples above are for <application>GCC</application>
|
||||
version 4.4. To use <command>gcc43</command>, replace
|
||||
<literal>"gcc44"</literal> with <literal>"gcc43"</literal>
|
||||
and so on. Note also that all of these libraries are fully
|
||||
backwards compatible with base system libraries.</para>
|
||||
</note>
|
||||
|
||||
<warning>
|
||||
<para>Some C++ programs may refuse to work if these libraries
|
||||
are not mapped correctly. If it is not feasible to map them
|
||||
all, it is recommended to map at least libstdc++.so.</para>
|
||||
</warning>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="custom-cflags">
|
||||
<title>Custom <literal>CFLAGS</literal> for the ports tree</title>
|
||||
|
||||
<para>To add custom <literal>CFLAGS</literal> for the ports tree
|
||||
which are unsupported by the base system, adjust the
|
||||
<filename>/etc/make.conf</filename> according to the following
|
||||
example:</para>
|
||||
|
||||
<programlisting>.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44)
|
||||
USE_GCC=4.4
|
||||
CPP=cpp44
|
||||
CFLAGS+=-mssse3
|
||||
.endif</programlisting>
|
||||
|
||||
<para>It is possible to completely replace
|
||||
<literal>CFLAGS</literal> and/or define custom
|
||||
<literal>CPUTYPE</literal> as well. We recommend setting
|
||||
<literal>CPUTYPE</literal> because many ports decide their
|
||||
optimizations flags based on this variable.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="excluding-unbuildable-ports">
|
||||
<title>Excluding ports that do not build with new version of
|
||||
<application>GCC</application></title>
|
||||
|
||||
<para>To exclude ports that have problems with custom version of
|
||||
<application>GCC</application>, adjust the
|
||||
<filename>/etc/make.conf</filename> according to the following
|
||||
example:</para>
|
||||
|
||||
<programlisting>.if !empty(.CURDIR:M/usr/ports/*) && exists(/usr/local/bin/gcc44)
|
||||
.if empty(.CURDIR:M/usr/ports/net/openldap*)
|
||||
USE_GCC=4.X
|
||||
.endif
|
||||
.endif</programlisting>
|
||||
|
||||
<para>The example above excludes the forced use of
|
||||
<command>gcc</command> 4.4 for the
|
||||
<filename role="package">net/openldap</filename>* ports. It is
|
||||
also possible to specify more ports on a single line:</para>
|
||||
|
||||
<programlisting>.if empty(.CURDIR:M/usr/ports/net/openldap*) && empty(.CURDIR:M/usr/ports/xxx/yyy) && ...</programlisting>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="performance-imparct">
|
||||
<title>Impact on the binary performance</title>
|
||||
|
||||
<para>Using <application>GCC</application> version 4.4 with
|
||||
<acronym>SSSE3</acronym> instruction set enabled (if supported by
|
||||
the <acronym>CPU</acronym>) may yield up to 10% average increase
|
||||
in binary performance. In certain tests, the results show
|
||||
more than a 20% performance boost (e.g. in multimedia
|
||||
processing).</para>
|
||||
|
||||
<para>The table located at <ulink
|
||||
url="http://people.freebsd.org/~mm/benchmarks/perlbench/"></ulink>
|
||||
shows a comparison of <application>GCC</application> versions
|
||||
currently available in base &os; system,
|
||||
<application>GCC</application> version 4.3 and
|
||||
<application>GCC</application> version 4.4 with various
|
||||
combinations of <literal>CFLAGS</literal> using the perlbench
|
||||
benchmark suite.</para>
|
||||
</sect1>
|
||||
</article>
|
Loading…
Reference in a new issue