Gentoo Archives: gentoo-doc-cvs

From: Xavier Neys <neysx@×××××××××××.org>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] cvs commit: cross-compiling-distcc.xml
Date: Mon, 23 Jan 2006 12:31:37
Message-Id: 200601231231.k0NCVSop031691@robin.gentoo.org
1 neysx 06/01/23 12:31:26
2
3 Modified: xml/htdocs/doc/en metadoc.xml
4 Added: xml/htdocs/doc/en cross-compiling-distcc.xml
5 Log:
6 #116575 new guide about X-compiling w/distcc
7
8 Revision Changes Path
9 1.137 +7 -2 xml/htdocs/doc/en/metadoc.xml
10
11 file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/metadoc.xml?rev=1.137&content-type=text/x-cvsweb-markup&cvsroot=gentoo
12 plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/metadoc.xml?rev=1.137&content-type=text/plain&cvsroot=gentoo
13 diff : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/metadoc.xml.diff?r1=1.136&r2=1.137&cvsroot=gentoo
14
15 Index: metadoc.xml
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v
18 retrieving revision 1.136
19 retrieving revision 1.137
20 diff -u -r1.136 -r1.137
21 --- metadoc.xml 20 Jan 2006 20:55:07 -0000 1.136
22 +++ metadoc.xml 23 Jan 2006 12:31:26 -0000 1.137
23 @@ -1,9 +1,9 @@
24 <?xml version='1.0' encoding="UTF-8"?>
25 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v 1.136 2006/01/20 20:55:07 swift Exp $ -->
26 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/metadoc.xml,v 1.137 2006/01/23 12:31:26 neysx Exp $ -->
27 <!DOCTYPE metadoc SYSTEM "/dtd/metadoc.dtd">
28
29 <metadoc lang="en">
30 -<version>1.65</version>
31 +<version>1.66</version>
32 <members>
33 <lead>neysx</lead>
34 <member>fox2mike</member>
35 @@ -111,6 +111,7 @@
36 <file id="cvs-tutorial">/doc/en/cvs-tutorial.xml</file>
37 <file id="devfs-guide">/doc/en/devfs-guide.xml</file>
38 <file id="distcc">/doc/en/distcc.xml</file>
39 + <file id="cross-distcc">/doc/en/cross-compiling-distcc.xml</file>
40 <file id="dri-howto">/doc/en/dri-howto.xml</file>
41 <file id="ebuild-submit">/doc/en/ebuild-submit.xml</file>
42 <file id="gentoo-upgrading">/doc/en/gentoo-upgrading.xml</file>
43 @@ -731,6 +732,10 @@
44 <memberof>sysadmin_specific</memberof>
45 <fileid>distcc</fileid>
46 </doc>
47 + <doc id="cross-distcc">
48 + <memberof>sysadmin_specific</memberof>
49 + <fileid>cross-distcc</fileid>
50 + </doc>
51 <doc id="devfs-guide">
52 <memberof>sysadmin_specific</memberof>
53 <fileid>devfs-guide</fileid>
54
55
56
57 1.1 xml/htdocs/doc/en/cross-compiling-distcc.xml
58
59 file : http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/cross-compiling-distcc.xml?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=gentoo
60 plain: http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/cross-compiling-distcc.xml?rev=1.1&content-type=text/plain&cvsroot=gentoo
61
62 Index: cross-compiling-distcc.xml
63 ===================================================================
64 <?xml version="1.0" encoding="UTF-8"?>
65 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
66 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/cross-compiling-distcc.xml,v 1.1 2006/01/23 12:31:26 neysx Exp $ -->
67
68 <guide link="/doc/en/cross-compiling-distcc.xml">
69 <title>DistCC Cross-compiling Guide</title>
70
71 <author title="Author">
72 <mail link="agaffney@g.o">Andrew Gaffney</mail>
73 </author>
74 <author title="Editor">
75 <mail link="jackdark@×××××.com">Joshua Saddler</mail>
76 </author>
77
78 <abstract>
79 This guide shows you how to set up distcc for cross-compiling across different
80 processor architectures.
81 </abstract>
82
83 <!-- The content of this document is licensed under the CC-BY-SA license -->
84 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
85 <license/>
86
87 <version>1.0</version>
88 <date>2006-01-22</date>
89
90 <chapter>
91 <title>Cross-compiling with distcc</title>
92 <section>
93 <title>Introduction</title>
94 <body>
95
96 <p>
97 <c>distcc</c> is a tool that lets you share the burden of software compiling
98 across several networked computers. As long as the networked boxes are all using
99 the same toolchain built for the same processor architecture, no special
100 <c>distcc</c> setup is required. But what do you do if you need to compile for a
101 different architecture using differing computers? This guide will show you how
102 to configure <c>distcc</c> to compile for different architectures.
103 </p>
104
105 </body>
106 </section>
107 <section>
108 <title>Emerge the needed utilities</title>
109 <body>
110
111 <p>
112 First, you will need to emerge <c>crossdev</c> on all the machines that will be
113 involved in the compiling process. <c>crossdev</c> is a tool that makes building
114 cross-architecture toolchains easy. It was originally written by <mail
115 link="kumba@g.o">Joshua Kinard</mail> and was re-written from the ground
116 up by <mail link="vapier@g.o">Mike Frysinger</mail>. Its usage is
117 straightforward: <c>crossdev -t sparc</c> will build a full cross-toolchain
118 targetting the Sparc architecture. This includes binutils, gcc, glibc, and
119 linux-headers. If you need more help, try running <c>crossdev --help</c>.
120 Obviously, you will need to emerge the proper cross-toolchain on all the helper
121 boxes.
122 </p>
123
124 <p>
125 Next, you will need to emerge <c>distcc</c> on all the machines that will be
126 involved in the process. This includes the box that will run emerge and the
127 boxes with the cross-compilers. Please see the <uri
128 link="/doc/en/distcc.xml">Gentoo Distcc Documentation</uri> for more
129 information on setting up and using <c>distcc</c>.
130 </p>
131
132 </body>
133 </section>
134 <section>
135 <title>Arch-specific notes</title>
136 <body>
137
138 <p>
139 If you are cross-compiling between different subarchitectures for Intel x86
140 (e.g. i586 and i686), you must still build a full cross-toolchain for the
141 desired CHOST, or else the compilation will fail. This is because i586 and i686
142 are actually different CHOSTs, despite the fact that they are both considered
143 "x86." Please keep this in mind when you build your cross-toolchains. For
144 example, if the target box is i586, this means that you must build i586
145 cross-toolchains on your i686 helper boxes.
146 </p>
147
148 </body>
149 </section>
150 <section>
151 <title>Configuring distcc to cross-compile correctly</title>
152 <body>
153
154 <p>
155 In the default distcc setup, cross-compiling will <e>not</e> work properly. The
156 problem is that many builds just call <c>gcc</c> instead of the full compiler
157 name (e.g. <c>sparc-unknown-linux-gnu-gcc</c>). When this compile gets
158 distributed to a distcc helper box, the native compiler gets called instead of
159 your shiny new cross-compiler.
160 </p>
161
162 <p>
163 Fortunately, there is a workaround for this little problem. All it takes is a
164 wrapper script and a few symlinks on the box that will be running
165 <c>emerge</c>. I'll use my Sparc box as an example. Wherever you see
166 <c>sparc-unknown-linux-gnu</c> below, you will want to insert your own CHOST
167 (<c>x86_64-pc-linux-gnu</c> for an AMD64 box, for example). When you first
168 emerge distcc, the <path>/usr/lib/distcc/bin</path> directory looks like this:
169 </p>
170
171 <note>
172 The following instructions are to be performed only on the box running the
173 emerge. Do not perform these steps on the helper boxes.
174 </note>
175
176 <pre caption="Available compilers">
177 # <i>cd /usr/lib/distcc/bin</i>
178 # <i>ls -l</i>
179 total 0
180 lrwxrwxrwx 1 root root 15 Dec 23 20:13 c++ -&gt; /usr/bin/distcc
181 lrwxrwxrwx 1 root root 15 Dec 23 20:13 cc -&gt; /usr/bin/distcc
182 lrwxrwxrwx 1 root root 15 Dec 23 20:13 g++ -&gt; /usr/bin/distcc
183 lrwxrwxrwx 1 root root 15 Dec 23 20:13 gcc -&gt; /usr/bin/distcc
184 lrwxrwxrwx 1 root root 15 Dec 23 20:13 sparc-unknown-linux-gnu-c++ -&gt; /usr/bin/distcc
185 lrwxrwxrwx 1 root root 15 Dec 23 20:13 sparc-unknown-linux-gnu-g++ -&gt; /usr/bin/distcc
186 lrwxrwxrwx 1 root root 15 Dec 23 20:13 sparc-unknown-linux-gnu-gcc -&gt; /usr/bin/distcc
187 </pre>
188
189 <p>
190 Here is what you want to do:
191 </p>
192
193 <pre caption="Modifying distcc">
194 # <i>rm c++ g++ gcc cc</i>
195 </pre>
196
197 <p>
198 Next, we'll create the new script on this box. Fire up your favorite editor and
199 create a file with the following text in it, then save it as
200 <path>sparc-unknown-linux-gnu-wrapper</path>. Remember to change the CHOST (in
201 this case, <c>sparc-unknown-linux-gnu</c>) to the actual CHOST of the box that
202 will be running the emerge.
203 </p>
204
205 <pre caption="The new wrapper script">
206 #!/bin/bash
207
208 exec /usr/lib/distcc/bin/sparc-unknown-linux-gnu-${0##*/} "$@"
209 </pre>
210
211 <p>
212 Next, we'll make the script executable and create the proper symlinks:
213 </p>
214
215 <pre caption="Creating the symlinks">
216 # <i>chmod a+x sparc-unknown-linux-gnu-wrapper</i>
217 # <i>ln -s /usr/bin/distcc sparc-unknown-linux-gnu-cc</i>
218 # <i>ln -s sparc-unknown-linux-gnu-wrapper gcc</i>
219 # <i>ln -s sparc-unknown-linux-gnu-wrapper cc</i>
220 # <i>ln -s sparc-unknown-linux-gnu-wrapper c++</i>
221 # <i>ln -s sparc-unknown-linux-gnu-wrapper g++</i>
222 </pre>
223
224 <p>
225 When you're done, <path>/usr/lib/distcc/bin</path> will look like this:
226 </p>
227
228 <pre caption="A proper set of compilers">
229 # <i>ls -l</i>
230 total 4
231 lrwxrwxrwx 1 root root 25 Jan 18 14:20 c++ -&gt; sparc-unknown-linux-gnu-wrapper
232 lrwxrwxrwx 1 root root 25 Jan 18 14:20 cc -&gt; sparc-unknown-linux-gnu-wrapper
233 lrwxrwxrwx 1 root root 25 Jan 18 14:20 g++ -&gt; sparc-unknown-linux-gnu-wrapper
234 lrwxrwxrwx 1 root root 25 Jan 18 14:20 gcc -&gt; sparc-unknown-linux-gnu-wrapper
235 lrwxrwxrwx 1 root root 15 Nov 21 10:42 sparc-unknown-linux-gnu-c++ -&gt; /usr/bin/distcc
236 lrwxrwxrwx 1 root root 15 Jan 18 14:20 sparc-unknown-linux-gnu-cc -&gt; /usr/bin/distcc
237 lrwxrwxrwx 1 root root 15 Nov 21 10:42 sparc-unknown-linux-gnu-g++ -&gt; /usr/bin/distcc
238 lrwxrwxrwx 1 root root 15 Jul 27 10:52 sparc-unknown-linux-gnu-gcc -&gt; /usr/bin/distcc
239 -rwxr-xr-x 1 root root 70 Jan 18 14:20 sparc-unknown-linux-gnu-wrapper
240 </pre>
241
242 <p>
243 Congratulations; you now have a (hopefully) working cross-distcc setup.
244 </p>
245
246 </body>
247 </section>
248 <section>
249 <title>How this works</title>
250 <body>
251
252 <p>
253 When <c>distcc</c> is called, it checks to see what it was called as (e.g.
254 <c>i686-pc-linux-gnu-gcc</c>, <c>sparc-unknown-linux-gnu-g++</c>, etc.) When
255 distcc then distributes the compile to a helper box, it passes along the name
256 it was called as. The distcc daemon on the other helper box then looks for a
257 binary with that same name. If it sees just <c>gcc</c>, it will look for
258 <c>gcc</c>, which is likely to be the native compiler on the helper box, if it
259 is not the same architecture as the box running <c>emerge</c>. When the
260 <e>full</e> name of the compiler is sent (e.g.
261 <c>sparc-unknown-linux-gnu-gcc</c>), there is no confusion.
262 </p>
263
264 </body>
265 </section>
266 </chapter>
267 </guide>
268
269
270
271 --
272 gentoo-doc-cvs@g.o mailing list