Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 302129 | Differences between
and this patch

Collapse All | Expand All

(-)handbook/cross-compiler.xml (-41 / +71 lines)
Lines 152-175 Link Here
152
</p>
152
</p>
153
153
154
<pre caption="Using SH4 cross-compiler">
154
<pre caption="Using SH4 cross-compiler">
155
$ <i>sh4-unknown-linux-gnu-gcc --version</i>
155
# <i>sh4-unknown-linux-gnu-gcc --version</i>
156
sh4-unknown-linux-gnu-gcc (GCC) 4.2.0 (Gentoo 4.2.0 p1.4)
156
sh4-unknown-linux-gnu-gcc (GCC) 4.2.0 (Gentoo 4.2.0 p1.4)
157
Copyright (C) 2007 Free Software Foundation, Inc.
157
Copyright (C) 2007 Free Software Foundation, Inc.
158
This is free software; see the source for copying conditions.  There is NO
158
This is free software; see the source for copying conditions.  There is NO
159
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
159
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
160
$ <i>echo 'int main(){return 0;}' > sh4-test.c</i>
160
# <i>echo 'int main(){return 0;}' > sh4-test.c</i>
161
$ <i>sh4-unknown-linux-gnu-gcc -Wall sh4-test.c -o sh4-test</i>
161
# <i>sh4-unknown-linux-gnu-gcc -Wall sh4-test.c -o sh4-test</i>
162
$ <i>file sh4-test</i>
162
# <i>file sh4-test</i>
163
sh4-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), not stripped
163
sh4-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), not stripped
164
</pre>
164
</pre>
165
165
166
<p>
166
<p>
167
If the crossdev command failed, you have the log file which you can review to
167
If the crossdev command failed, you are told the log file which you can review to
168
see if the problem is local.  If you're unable to fix the issue, you're welcome
168
see if the problem is local.  If you're unable to fix the issue, you're welcome
169
to file a bug in our bugzilla.  See the <uri
169
to file a bug in our bugzilla.  See the <uri
170
link="communication.xml">Communication page</uri> for more information.
170
link="communication.xml">Communication page</uri> for more information.
171
</p>
171
</p>
172
172
173
<p>
174
To find out which tuple you should use, look over the output from the following
175
command:
176
</p>
177
178
<pre caption="crossdev Tuples">
179
# <i>crossdev -t help</i>
180
</pre>
181
	
182
<p>
183
You can now find a newly compiled cross-compiler in the sysroot at
184
<path>/usr/CTARGET/</path>. It's a good idea to create pre-built binary packages
185
so you don't end up waiting another two to three hours every time you want to
186
reinstall this toolchain.
187
</p>
188
189
<pre caption="Create binpkgs">
190
# <i>quickpkg --include-unmodified-config=y cross-sh4-unknown-linux-gnu/gcc</i>
191
# <i>quickpkg --include-unmodified-config=y cross-sh4-unknown-linux-gnu/glibc</i>
192
# <i>quickpkg --include-unmodified-config=y cross-sh4-unknown-linux-gnu/binutils</i>
193
# <i>quickpkg --include-unmodified-config=y cross-sh4-unknown-linux-gnu/linux-headers</i>
194
</pre>
195
196
<note>
197
If quickpkg warns you about excluded files, please follow its prompts to include
198
all files.
199
</note>
200
201
<p>
202
In the future you can reinstall your sysroot by executing the following simple
203
portage command:
204
</p>
205
206
<pre caption="Emerge binpkgs">
207
# <i>emerge -k cross-sh4-unknown-linux-gnu/gcc cross-sh4-unknown-linux-gnu/glibc cross-sh4-unknown-linux-gnu/binutils cross-sh4-unknown-linux-gnu/linux-headers</i>
208
</pre>
209
173
</body>
210
</body>
174
</subsection>
211
</subsection>
175
212
Lines 179-186 Link Here
179
216
180
<p>
217
<p>
181
To uninstall a toolchain, simply use the <c>--clean</c> option.  If you modified
218
To uninstall a toolchain, simply use the <c>--clean</c> option.  If you modified
182
the sysroot by hand, you'll be prompted to delete things inside of it, so you
219
the sysroot by hand, you'll be prompted to delete every file inside, so you will
183
may want to pipe <c>yes |</c> into the command.
220
want to prepend <c>yes |</c> to this command <b>if</b> you are sure.
184
</p>
221
</p>
185
222
186
<pre caption="Uninstalling cross-compiler">
223
<pre caption="Uninstalling cross-compiler">
Lines 194-210 Link Here
194
231
195
</body>
232
</body>
196
</subsection>
233
</subsection>
197
<subsection>
198
<title>Options</title>
199
<body>
200
201
<p>
202
Obviously crossdev can do a lot more, so to find out more, simply run
203
<c>crossdev --help</c>.
204
</p>
205
206
</body>
207
</subsection>
208
</section>
234
</section>
209
235
210
<section>
236
<section>
Lines 220-235 Link Here
220
meant to cover/document/whatever the myriad of build failures you are likely
246
meant to cover/document/whatever the myriad of build failures you are likely
221
to see along the way.  If you need such help, see the
247
to see along the way.  If you need such help, see the
222
<uri link="the-more-you-know.xml">Beyond section</uri> in the handbook for
248
<uri link="the-more-you-know.xml">Beyond section</uri> in the handbook for
223
some pointers.  You certainly should not bug me or anyone else in Gentoo.
249
some pointers.
224
</warn>
250
</warn>
225
251
226
<warn>
252
<warn>
253
Let's be very clear: we do <b>not</b> support toolchains which are built by hand!
254
</warn>
255
256
<note>
227
If you're still reading, you should really check out the crosstool project
257
If you're still reading, you should really check out the crosstool project
228
(refer to the <uri link="the-more-you-know.xml">Beyond section</uri>) as
258
(refer to the <uri link="the-more-you-know.xml">Beyond section</uri>) as
229
that provides a distribution independent method for generating cross-compilers.
259
that provides a distribution independent method for generating cross-compilers.
230
While it does kind of suck (imo), it is certainly the best (and really only)
260
While it does kind of suck (imo), it is certainly the best (and really only)
231
option out there for creating cross-compilers.
261
option out there for creating cross-compilers.
232
</warn>
262
</note>
233
</body>
263
</body>
234
</subsection>
264
</subsection>
235
265
Lines 349-361 Link Here
349
	</p>
379
	</p>
350
380
351
<pre caption="configure and build binutils">
381
<pre caption="configure and build binutils">
352
$ <i>./configure \
382
# <i>./configure \
353
	--target=$CTARGET \
383
	--target=$CTARGET \
354
	--prefix=/usr \
384
	--prefix=/usr \
355
	--with-sysroot=/usr/$CTARGET \
385
	--with-sysroot=/usr/$CTARGET \
356
	--disable-werror</i>
386
	--disable-werror</i>
357
$ <i>make</i>
387
# <i>make</i>
358
$ <i>make install DESTDIR=$PWD/install-root</i>
388
# <i>make install DESTDIR=$PWD/install-root</i>
359
</pre>
389
</pre>
360
390
361
	<p>
391
	<p>
Lines 366-372 Link Here
366
	</p>
396
	</p>
367
397
368
<pre caption="cleaning binutils">
398
<pre caption="cleaning binutils">
369
$ <i>rm -rf install-root/usr/{info,lib,man,share}</i>
399
# <i>rm -rf install-root/usr/{info,lib,man,share}</i>
370
</pre>
400
</pre>
371
401
372
	<p>
402
	<p>
Lines 395-401 Link Here
395
	</note>
425
	</note>
396
426
397
<pre caption="building/installing unsanitized headers">
427
<pre caption="building/installing unsanitized headers">
398
$ <i>yes "" | make ARCH=$ARCH oldconfig prepare</i>
428
# <i>yes "" | make ARCH=$ARCH oldconfig prepare</i>
399
# <i>mkdir -p /usr/$CTARGET/usr/include</i>
429
# <i>mkdir -p /usr/$CTARGET/usr/include</i>
400
# <i>cp -a include/linux include/asm-generic /usr/$CTARGET/usr/include/</i>
430
# <i>cp -a include/linux include/asm-generic /usr/$CTARGET/usr/include/</i>
401
# <i>cp -a include/asm-$ARCH /usr/$CTARGET/usr/include/asm</i>
431
# <i>cp -a include/asm-$ARCH /usr/$CTARGET/usr/include/asm</i>
Lines 416-424 Link Here
416
	</p>
446
	</p>
417
447
418
<pre caption="building/installing glibc headers">
448
<pre caption="building/installing glibc headers">
419
$ <i>mkdir build</i>
449
# <i>mkdir build</i>
420
$ <i>cd build</i>
450
# <i>cd build</i>
421
$ <i>../configure \
451
# <i>../configure \
422
	--host=$CTARGET \
452
	--host=$CTARGET \
423
	--prefix=/usr \
453
	--prefix=/usr \
424
	--with-headers=/usr/$CTARGET/usr/include \
454
	--with-headers=/usr/$CTARGET/usr/include \
Lines 455-463 Link Here
455
	</p>
485
	</p>
456
486
457
<pre caption="building gcc stage 1">
487
<pre caption="building gcc stage 1">
458
$ <i>mkdir build</i>
488
# <i>mkdir build</i>
459
$ <i>cd build</i>
489
# <i>cd build</i>
460
$ <i>../configure \
490
# <i>../configure \
461
	--target=$CTARGET \
491
	--target=$CTARGET \
462
	--prefix=/usr \
492
	--prefix=/usr \
463
	--with-sysroot=/usr/$CTARGET \
493
	--with-sysroot=/usr/$CTARGET \
Lines 468-475 Link Here
468
	--disable-libmudflap \
498
	--disable-libmudflap \
469
	--disable-libssp \
499
	--disable-libssp \
470
	--disable-libgomp</i>
500
	--disable-libgomp</i>
471
$ <i>make</i>
501
# <i>make</i>
472
$ <i>make install DESTDIR=$PWD/install-root</i>
502
# <i>make install DESTDIR=$PWD/install-root</i>
473
</pre>
503
</pre>
474
504
475
	<p>
505
	<p>
Lines 477-483 Link Here
477
	</p>
507
	</p>
478
508
479
<pre caption="cleaning gcc stage 1">
509
<pre caption="cleaning gcc stage 1">
480
$ <i>rm -rf install-root/usr/{info,include,lib/libiberty.a,man,share}</i>
510
# <i>rm -rf install-root/usr/{info,include,lib/libiberty.a,man,share}</i>
481
</pre>
511
</pre>
482
512
483
	<p>
513
	<p>
Lines 499-512 Link Here
499
	</p>
529
	</p>
500
530
501
<pre caption="building/installing glibc">
531
<pre caption="building/installing glibc">
502
$ <i>rm -rf build</i>
532
# <i>rm -rf build</i>
503
$ <i>mkdir build</i>
533
# <i>mkdir build</i>
504
$ <i>cd build</i>
534
# <i>cd build</i>
505
$ <i>../configure \
535
# <i>../configure \
506
	--host=$CTARGET \
536
	--host=$CTARGET \
507
	--prefix=/usr \
537
	--prefix=/usr \
508
	--without-cvs</i>
538
	--without-cvs</i>
509
$ <i>make</i>
539
# <i>make</i>
510
# <i>make install install_root=/usr/$CTARGET</i>
540
# <i>make install install_root=/usr/$CTARGET</i>
511
</pre>
541
</pre>
512
	</body>
542
	</body>
Lines 521-527 Link Here
521
	</p>
551
	</p>
522
552
523
<pre caption="building/installing gcc stage 2">
553
<pre caption="building/installing gcc stage 2">
524
$ <i>./configure \
554
# <i>./configure \
525
	--target=$CTARGET \
555
	--target=$CTARGET \
526
	--prefix=/usr \
556
	--prefix=/usr \
527
	--with-sysroot=/usr/$CTARGET \
557
	--with-sysroot=/usr/$CTARGET \
Lines 529-535 Link Here
529
	--enable-shared \
559
	--enable-shared \
530
	--disable-checking \
560
	--disable-checking \
531
	--disable-werror</i>
561
	--disable-werror</i>
532
$ <i>make</i>
562
# <i>make</i>
533
# <i>make install</i>
563
# <i>make install</i>
534
</pre>
564
</pre>
535
	</body>
565
	</body>
(-)handbook/cross-compiling-packages.xml (-22 / +53 lines)
Lines 60-71 Link Here
60
<body>
60
<body>
61
61
62
<p>
62
<p>
63
Cross-compiling a system generally involves two directory trees.  The first is
63
Cross-compiling a system generally involves two directory trees. The differences
64
where all development files are normally installed.  This is your sysroot.  The
64
between them can be difficult to understand, but they are important concepts to
65
other tree is where only your runtime files are installed.  You emerge all of
65
cross-compiling.
66
your fun packages into your sysroot (without trimming down any files), and then
66
</p>
67
either install via binary packages or copying files by hand all the stuff you
67
68
need in your runtime tree.
68
<p>
69
The first tree to consider is sysroot. Please read the
70
<uri link="intro.xml">Introduction</uri> chapter for the sysroot definition.
71
</p>
72
73
<p>
74
The second tree is real root. This one is much simpler to understand: it's
75
where you're trying to create a bootable stage3-like installation of Gentoo
76
that you can copy to your target device.
69
</p>
77
</p>
70
78
71
<p>
79
<p>
Lines 73-84 Link Here
73
sysroot as the include/library directories in this tree are already encoded
81
sysroot as the include/library directories in this tree are already encoded
74
into the gcc cross-compiler for searching.  You could use another directory
82
into the gcc cross-compiler for searching.  You could use another directory
75
and then add custom -I/-L paths to your CPPFLAGS/LDFLAGS, but this has
83
and then add custom -I/-L paths to your CPPFLAGS/LDFLAGS, but this has
76
historically proven to be problematic.  Yes, it works most of the time, but
84
historically proven to be problematic in enough corner cases to be discouraged
77
the corner cases are why this method is discouraged.  In the embedded handbook,
85
for practical use.
78
we'll assume you're using the sysroot as your development ROOT.
79
</p>
86
</p>
80
87
81
<p>
88
<p>
89
A less common convention, but common nonetheless, is to set <c>ROOT</c> and
90
<c>SYSROOT</c> to exactly the same thing. This seems odd, given the definitions
91
and differences of <c>ROOT</c> and <c>SYSROOT</c>. Remember from the
92
<uri link="intro.xml">Introduction</uri> chapter that the cross-compiler
93
sometimes wants libraries preinstalled to <c>SYSROOT</c> first before they're
94
used in <c>ROOT</c>, which often is enough aggravation to cause some to install
95
everything to <c>SYSROOT</c>. What ends up happening is a mixed, somewhat messy
96
<c>ROOT</c>/<c>SYSROOT</c> tree is installed to <c>SYSROOT</c>. However, as
97
long as you're generating binary packages, you can later ignore the
98
<c>SYSROOT</c>/<c>ROOT</c> directories entirely and install a new <c>ROOT</c>
99
elsewhere using those binary packages.
100
</p>
101
102
<!-- The following section needs more information about "why" and "how", if it's desired at all
103
<p>
82
For your runtime system, you'll need a much slimmer/trimmed-down setup.  The
104
For your runtime system, you'll need a much slimmer/trimmed-down setup.  The
83
files you remove from a normal installed package is why this tree is not
105
files you remove from a normal installed package is why this tree is not
84
suitable for compiling against.  If you build binary packages while installing
106
suitable for compiling against.  If you build binary packages while installing
Lines 86-91 Link Here
86
the <c>INSTALL_MASK</c> variable to trim out most things. See <c>man
108
the <c>INSTALL_MASK</c> variable to trim out most things. See <c>man
87
make.conf</c> for more information.
109
make.conf</c> for more information.
88
</p>
110
</p>
111
-->
89
112
90
</body>
113
</body>
91
</section>
114
</section>
Lines 106-111 Link Here
106
# <i>emerge crossdev</i>
129
# <i>emerge crossdev</i>
107
</pre>
130
</pre>
108
131
132
<warn>
133
crossdev's wrappers automatically configure <c>CBUILD</c> and <c>CHOST</c>.
134
Do not set these by hand in your environment!
135
</warn>
136
109
<p>
137
<p>
110
We can use these tools for both installing into your development root 
138
We can use these tools for both installing into your development root 
111
(sysroot) and into your runtime root.  For the latter, simply specify 
139
(sysroot) and into your runtime root.  For the latter, simply specify 
Lines 126-132 Link Here
126
</p>
154
</p>
127
155
128
<p>
156
<p>
129
By default the wrappers will link to the generic embedded profile. This 
157
By default crossdev will link to the generic embedded profile. This 
130
is done to simpilify things, but the user may wish to use a more 
158
is done to simpilify things, but the user may wish to use a more 
131
advanced targeted profile. In order to do that we can update the profile symlink.
159
advanced targeted profile. In order to do that we can update the profile symlink.
132
</p>
160
</p>
Lines 136-143 Link Here
136
</pre>
164
</pre>
137
165
138
<p>
166
<p>
139
And naturally to change settings for the target system like USE flags, 
167
To change settings for the target system like USE flags, FEATURES, and 
140
FEATURES, and VIDEO_CARDS. We would edit the standard portage config files.
168
VIDEO_CARDS, edit the standard portage config files, wherever
169
<c>PORTAGE_CONFIGROOT</c> points.
141
</p>
170
</p>
142
171
143
<pre caption="${SYSROOT}/etc/make.conf">
172
<pre caption="${SYSROOT}/etc/make.conf">
Lines 145-160 Link Here
145
</pre>
174
</pre>
146
175
147
<p>
176
<p>
148
Sometimes there are some additional tests we need override for configure
177
Sometimes there are some additional, cross-compile-incomplatible tests we
149
scripts. To do this the wrappers export a few variables to force the test to get
178
need override for configure scripts. To do this crossdev exports a few variables
150
the answer it should. This will help prevent bloat in packages which add local
179
to force the test to get the answer it should. This will help prevent bloat
151
functions to workaround issues it assumes your system has because it could not
180
in packages which add local functions to workaround issues it assumes your
152
run the test. From time to time you may find you need to add additional
181
<e>target</e> system has because it could not run the test while cross-compiling
153
variables to these files in <path>/usr/share/crossdev/include/site/</path> to
182
(because, of course, it's not running on the target system). From time to
154
get a package to compile. To figure out the variable you need to add, it's often
183
time you may find you need to add additional variables to these files in
155
as simple as greping the configure script for the autoconf variable and adding
184
<path>/usr/share/crossdev/include/site/</path> to get a package to compile.
156
it to the appropriate target file. This becomes obvious after the first few
185
To figure out the variable you need to add, it's often as simple as greping
157
times of doing it.
186
the configure script for the autoconf variable (which often begins with "ac_")
187
and adding it to the appropriate target file. This becomes easy once you
188
know what you're looking for.
158
</p>
189
</p>
159
190
160
</body>
191
</body>
(-)handbook/intro.xml (-2 / +6 lines)
Lines 176-183 Link Here
176
176
177
<dt><c>sysroot: system root</c></dt>
177
<dt><c>sysroot: system root</c></dt>
178
<dd>
178
<dd>
179
  The root directory a compiler uses to find its standard headers and
179
  This is where all the cross-compiler libraries and headers are installed.
180
  libraries
180
  In other words, every library and header the cross-compiler needs to generate
181
  cross-compiled binaries are put here. In theory, this means the toolchain
182
  is good enough. In practice, the cross-compiler often wants some of a
183
  packages's library dependancies, such as ncurses, installed into sysroot
184
  first.
181
</dd>
185
</dd>
182
186
183
<dt><c>hardfloat</c></dt>
187
<dt><c>hardfloat</c></dt>

Return to bug 302129