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

(-)a/xml/htdocs/proj/en/base/embedded/handbook/cross-compiling-packages.xml (-68 / +114 lines)
Lines 17-55 Leverage Portage as a cross-compiling package manager. Link Here
17
<body>
17
<body>
18
18
19
<p>
19
<p>
20
There are a few important variables that we will use throughout this section.
20
There are a few important variables that we will use throughout this section
21
</p>
21
which we discussed earlier: <c>CBUILD</c>, <c>CHOST</c>, <c>CTARGET</c>,
22
22
<c>ROOT</c>, and <c>PORTAGE_CONFIGROOT</c>.
23
<table>
23
</p>
24
 <tr>
24
25
  <th>Variable</th>
25
<p>
26
  <th>Meaning</th>
26
You can set this all by hand, but that obviously gets quite tedious very
27
 </tr>
28
 <tr>
29
  <ti>CBUILD</ti>
30
  <ti>Platform you are building on</ti>
31
 </tr>
32
 <tr>
33
  <ti>CHOST</ti>
34
  <ti>Platform you are compiling for</ti>
35
 </tr>
36
 <tr>
37
  <ti>ROOT</ti>
38
  <ti>The virtual <path>/</path> you are installing into</ti>
39
 </tr>
40
 <tr>
41
  <ti>PORTAGE_CONFIGROOT</ti>
42
  <ti>
43
    The virtual <path>/</path> portage can find its config files (like
44
    <path>make.conf</path>)
45
  </ti>
46
 </tr>
47
</table>
48
49
<p>
50
You can either set this all by hand, but that obviously gets quite tedious very
51
quickly.  A better idea is to stick these into a shell script so you can avoid
27
quickly.  A better idea is to stick these into a shell script so you can avoid
52
typing it out all the time.
28
typing it out all the time. Having it all in a shell script also allows
29
you to set autoconf test assumptions to skip ./configure tests that are
30
troublesome for cross-compiling.
31
</p>
32
33
<p>
34
Something like the following works well to start, and can be tweaked as
35
desired:
36
</p>
37
<pre caption="set_environment.sh">
38
export CBUILD="powerpc-unknown-linux-gnu"
39
export CHOST="sh4-unknown-linux-gnu"
40
export CTARGET="$CHOST"
41
export SYSROOT="/usr/$CHOST"
42
export ROOT="/path/to/some/dir"
43
export PORTAGE_CONFIGROOT="${SYSROOT}"
44
45
echo "  CBUILD:  "$CBUILD
46
echo "  CTARGET: "$CTARGET
47
echo "  CHOST: "$CHOST
48
echo "  SYSROOT: "$SYSROOT
49
echo "  ROOT:    "$ROOT
50
echo "  PORTAGE_CONFIGROOT:    "$PORTAGE_CONFIGROOT
51
</pre>
52
<note>
53
If you're not sure what any of these do, please read the
54
<uri link="intro.xml">Introduction</uri> chapter.
55
</note>
56
57
<p>
53
</p>
58
</p>
54
59
55
</body>
60
</body>
Lines 60-71 typing it out all the time. Link Here
60
<body>
65
<body>
61
66
62
<p>
67
<p>
63
Cross-compiling a system generally involves two directory trees.  The first is
68
Cross-compiling a system generally involves two directory trees. The differences
64
where all development files are normally installed.  This is your sysroot.  The
69
between them can be difficult to understand, but they are important concepts
65
other tree is where only your runtime files are installed.  You emerge all of
70
to cross-compiling.
66
your fun packages into your sysroot (without trimming down any files), and then
71
</p>
67
either install via binary packages or copying files by hand all the stuff you
72
68
need in your runtime tree.
73
<p>
74
The first tree to consider is sysroot. Please read the
75
<uri link="intro.xml">Introduction</uri> chapter for the sysroot definition.
76
</p>
77
78
<p>
79
The second tree is real root. This one is much simpler to understand: it's
80
where you're trying to create a bootable stage3-like installation of Gentoo
81
that you can copy to your target device.
69
</p>
82
</p>
70
83
71
<p>
84
<p>
Lines 73-84 The common convention is to use your <path>/usr/CTARGET/</path> tree as your Link Here
73
sysroot as the include/library directories in this tree are already encoded
86
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
87
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
88
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
89
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,
90
for practical use.
78
we'll assume you're using the sysroot as your development ROOT.
79
</p>
91
</p>
80
92
81
<p>
93
<p>
94
A less common convention, but common nonetheless, is to set <c>ROOT</c> and
95
<c>SYSROOT</c> to exactly the same thing. This seems odd, given the definitions
96
and differences of <c>ROOT</c> and <c>SYSROOT</c>. Remember from the
97
<uri link="intro.xml">Introduction</uri> chapter that the cross-compiler
98
sometimes wants libraries preinstalled to <c>SYSROOT</c> first before they're
99
used in <c>ROOT</c>, which often is enough aggravation to cause some to install
100
everything to <c>SYSROOT</c>. What ends up happening is a mixed, somewhat messy
101
<c>ROOT</c>/<c>SYSROOT</c> tree is installed to <c>SYSROOT</c>. However, as
102
long as you're generating binary packages, you can later ignore the
103
<c>SYSROOT</c>/<c>ROOT</c> directories entirely and install a new <c>ROOT</c>
104
elsewhere using those binary packages.
105
</p>
106
<!-- The following section needs more information about "why" and "how", if it's desired at all
107
<p>
82
For your runtime system, you'll need a much slimmer/trimmed-down setup.  The
108
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
109
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
110
suitable for compiling against.  If you build binary packages while installing
Lines 86-117 into your sysroot, then you can use those binary packages in conjunction with Link Here
86
the <c>INSTALL_MASK</c> variable to trim out most things. See <c>man
112
the <c>INSTALL_MASK</c> variable to trim out most things. See <c>man
87
make.conf</c> for more information.
113
make.conf</c> for more information.
88
</p>
114
</p>
89
115
-->
90
</body>
116
</body>
91
</section>
117
</section>
92
118
93
<section>
119
<section>
94
<title>Intro: crossdev-wrappers</title>
120
<title>Intro: crossdev's wrappers</title>
95
<body>
121
<body>
96
122
97
<p>
123
<p>
98
These are simple wrapper scripts that will setup the environment 
124
These are simple wrapper scripts that will setup the environment 
99
variables to point to the right places for you to be able to cross 
125
variables to point to the right places for you to be able to cross 
100
compile using emerge. PORTAGE_CONFIGROOT and ROOT both point to the 
126
compile using emerge. <c>PORTAGE_CONFIGROOT</c> and <c>ROOT</c> both point to the 
101
SYSROOT.
127
<c>SYSROOT</c> by default, but you can change that with the example script above.
102
</p>
128
</p>
103
129
130
<warn>
131
crossdev's wrappers automatically configure <c>CBUILD</c> and <c>CHOST</c>.
132
Do not set these by hand in your environment! (Bug #301751 states that CTARGET
133
is not set, so you may wish to do so by hand.)
134
</warn>
135
104
<pre caption="crossdev-wrappers">
136
<pre caption="crossdev-wrappers">
105
# <i>echo sys-devel/crossdev-wrappers >> /etc/portage/package.keywords</i>
137
# <i>echo sys-devel/crossdev-wrappers >> /etc/portage/package.keywords</i>
106
# <i>emerge crossdev-wrappers</i>
138
# <i>emerge crossdev-wrappers</i>
107
</pre>
139
</pre>
140
<note>
141
crossdev-wrappers has been merged into crossdev as of version 20100108. If
142
you have crossdev 20100108 or later, crossdev-wrappers should not and will
143
not be installed.
144
</note>
145
146
<p>
147
We can use these tools for installing into whichever directory <c>ROOT</c>
148
points to.  You can set <c>ROOT</c> equal to <c>SYSROOT</c> for installation
149
into sysroot, or <c>ROOT</c> to a different directory for installation into
150
a "runtime" root.
151
</p>
108
152
109
<p>
153
<p>
110
We can use these tools for both installing into your development root 
154
If you had merged via crossdev an <c>armv4tl-softfloat-linux-gnueabi</c>
111
(sysroot) and into your runtime root.  For the latter, simply specify 
155
toolchain, you would invoke emerge normally, but prepend "emerge" with the
112
by using the <c>--root</c> option. For example if you had merged via crossdev 
156
<c>ctarget</c> prefix:
113
an <c>armv4tl-softfloat-linux-gnueabi</c> toolchain you would then invoke the 
114
command just like normal emerge. But using the <c>ctarget</c> prefix:
115
</p>
157
</p>
116
158
117
<pre caption="CTARGET-emerge">
159
<pre caption="CTARGET-emerge">
Lines 124-130 dependencies from being pulled into the deptree. Link Here
124
</p>
166
</p>
125
167
126
<p>
168
<p>
127
By default the wrappers will link to the generic embedded profile. This 
169
By default crossdev will link to the generic embedded profile. This 
128
is done to simpilify things, but the user may wish to use a more 
170
is done to simpilify things, but the user may wish to use a more 
129
advanced targeted profile. In order to do that we can update the profile symlink.
171
advanced targeted profile. In order to do that we can update the profile symlink.
130
</p>
172
</p>
Lines 134-158 advanced targeted profile. In order to do that we can update the profile symlink Link Here
134
</pre>
176
</pre>
135
177
136
<p>
178
<p>
137
And naturally to change settings for the target system like USE flags, 
179
To change additional portage settings like <c>USE</c> flags, <c>FEATURES</c>, and <c>VIDEO_CARDS</c>, 
138
FEATURES, and VIDEO_CARDS. We would edit the standard portage config files.
180
we would edit the standard portage config files, but this time wherever
181
<c>PORTAGE_CONFIGROOT</c> points.
139
</p>
182
</p>
140
183
141
<pre caption="${SYSROOT}/etc/make.conf">
184
<pre caption="${PORTAGE_CONFIGROOT}/etc/make.conf">
142
# <i>$EDITOR ${SYSROOT}/etc/make.conf</i>
185
# <i>$EDITOR ${PORTAGE_CONFIGROOT}/etc/make.conf</i>
143
</pre>
186
</pre>
144
187
145
<p>
188
<p>
146
Sometimes there are some additional tests we need override for configure
189
Sometimes there are some additional, cross-compile-incomplatible tests we
147
scripts. To do this the wrappers export a few variables to force the test to get
190
need override for configure scripts. To do this crossdev exports a few variables
148
the answer it should. This will help prevent bloat in packages which add local
191
to force the test to get the answer it should. This will help prevent bloat
149
functions to workaround issues it assumes your system has because it could not
192
in packages which add local functions to workaround issues it assumes your
150
run the test. From time to time you may find you need to add additional
193
<e>target</e> system has because it could not run the test while cross-compiling
151
variables to these files in <path>/usr/share/crossdev/include/site/</path> to
194
(because, of course, it's not running on the target system). From time to
152
get a package to compile. To figure out the variable you need to add, it's often
195
time you may find you need to add additional variables to these files in
153
as simple as greping the configure script for the autoconf variable and adding
196
<path>/usr/share/crossdev/include/site/</path> to get a package to compile.
154
it to the appropriate target file. This becomes obvious after the first few
197
To figure out the variable you need to add, it's often as simple as greping
155
times of doing it.
198
the configure script for the autoconf variable (which often begins with "ac_")
199
and adding it to the appropriate target file. This becomes easy once you
200
know what you're looking for.
156
</p>
201
</p>
157
202
158
</body>
203
</body>
Lines 163-171 times of doing it. Link Here
163
<body>
208
<body>
164
209
165
<p>
210
<p>
166
If you want to uninstall and delete your work, then you can safely remove the
211
You can safely remove the sysroot tree at any time without affecting any
167
sysroot tree without affecting any native packages.  See also the section in
212
native packages.  See the section in the
168
the <uri link="cross-compiler.xml">crossdev guide</uri> about uninstalling.
213
<uri link="cross-compiler.xml">crossdev guide</uri> about uninstalling for
214
more information.
169
</p>
215
</p>
170
216
171
</body>
217
</body>
(-)a/xml/htdocs/proj/en/base/embedded/handbook/intro.xml (-2 / +7 lines)
Lines 174-180 PDA we wanted to develop for, the above table would look like: Link Here
174
</dd>
174
</dd>
175
175
176
<dt><c>sysroot: system root</c></dt>
176
<dt><c>sysroot: system root</c></dt>
177
<dd>The root directory a compiler uses to find its standard headers and libraries. Sometimes a compiler wants more than just standard headers and libraries in this directory, as though they were "standard" too. We'll explain how to resolve this when it happens in future chapters.</dd>
177
<dd>
178
	This is where all the cross-compiler libraries and headers are installed.
179
	In other words, every library and header the cross-compiler needs to generate
180
	cross-compiled binaries are put here. In theory, this means the toolchain
181
	is good enough. In practice, the cross-compiler often wants some of a package's
182
	library dependancies, such as ncurses, installed into sysroot first.
183
</dd>
178
184
179
<dt><c>hardfloat</c></dt>
185
<dt><c>hardfloat</c></dt>
180
<dd>The system has a hardware Floating Point Unit (FPU) to handle floating point math.</dd>
186
<dd>The system has a hardware Floating Point Unit (FPU) to handle floating point math.</dd>
181
- 

Return to bug 302129