1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
[[meta copyright="Copyright © 2007, 2008 Free Software Foundation, Inc."]]
[[meta license="""[[toggle id="license" text="GFDL 1.2+"]][[toggleable
id="license" text="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license
is included in the section entitled
[[GNU_Free_Documentation_License|/fdl]]."]]"""]]
# `cross-gnu`
[[Thomas_Schwinge|tschwinge]] has written a shell script for building a
complete cross-build environment for GNU/Hurd systems.
For now, find the shell scripts at
<http://nic-nac-project.de/~schwinge/tmp/cross-gnu> and
<http://nic-nac-project.de/~schwinge/tmp/cross-gnu-env>.
## Using
Read through it. Understand it. Only then use it by following the next steps.
/!\ Be made aware that -- while it is of course possible to build a working
cross-compiler -- this is not trivial to do. You'll have to patch source
packages. See the following list about needed patches, which have not yet been
installed in the upstream repositories.
### Supported Versions of Source Packages
The following ones are known to work. Others may work as well, but no
guarantee is given. Always the preferred version is listed first.
* `src/binutils`: [[GNU_Binutils|binutils]]
* CVS `binutils-2_19-branch`
$ mkdir binutils-2_19-branch
$ cd binutils-2_19-branch
$ cvs -d:pserver:anoncvs@sources.redhat.com:/cvs/src ↩
co -r binutils-2_19-branch binutils
The sources are rooted in `binutils-2_19-branch/src/`. Also use these
commands for updating, instead of the usual `cvs update`.
* The 2.19 release tarball from <ftp://ftp.gnu.org/gnu/binutils/> should
also be fine.
* CVS `binutils-2_18-branch`
$ mkdir binutils-2_18-branch
$ cd binutils-2_18-branch
$ cvs -d:pserver:anoncvs@sources.redhat.com:/cvs/src ↩
co -r binutils-2_18-branch binutils
The sources are rooted in `binutils-2_18-branch/src/`. Also use these
commands for updating, instead of the usual `cvs update`.
* The 2.18 release tarball from <ftp://ftp.gnu.org/gnu/binutils/> should
also be fine, as should be all other recent releases.
* `src/gcc`: [[GNU_Compiler_Collection|gcc]]
* SVN `gcc-4_1-branch`
$ svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_1-branch
Prepare:
$ ( cd gcc-4_1-branch/ && contrib/gcc_update --touch )
* Releases of the 4.1 series from <ftp://ftp.gnu.org/gnu/gcc/> should
also be fine.
* SVN `gcc-4_2-branch`
$ svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_2-branch
* Patches:
<http://lists.gnu.org/archive/html/bug-hurd/2007-11/msg00034.html>
Prepare:
$ ( cd gcc-4_2-branch/ && contrib/gcc_update --touch )
* Releases of the 4.2 series from <ftp://ftp.gnu.org/gnu/gcc/> should
also be fine, but need the same set of patches as the `gcc-4_2-branch`
needs.
* SVN `gcc-4_3-branch`
$ svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_3-branch
* Patches:
<http://lists.gnu.org/archive/html/bug-hurd/2007-11/msg00034.html>
Prepare:
$ ( cd gcc-4_3-branch/ && contrib/gcc_update --touch )
* Releases of the 4.3 series from <ftp://ftp.gnu.org/gnu/gcc/> should
also be fine, but need the same set of patches as the `gcc-4_3-branch`
needs.
* SVN `trunk` -- upcoming 4.4 series
$ svn co svn://gcc.gnu.org/svn/gcc/trunk
Prepare:
$ ( cd trunk/ && contrib/gcc_update --touch )
* `src/gnumach`: [[GNU_Mach|microkernel/mach/gnumach]]
* CVS `gnumach-1-branch`
$ cvs -d:pserver:anoncvs@cvs.gnu.org:/cvsroot/hurd ↩
co -r gnumach-1-branch gnumach
$ mv gnumach gnumach-1-branch
Prepare:
$ ( cd gnumach-1-branch/ && autoreconf -vfi )
* `src/mig`: [[microkernel/mach/mig/GNU_MIG]]
* CVS `HEAD`
$ cvs -d:pserver:anoncvs@cvs.gnu.org:/cvsroot/hurd co mig
Prepare:
$ ( cd mig/ && autoreconf -vfi )
* `src/hurd`: [[GNU_Hurd|hurd]]
* CVS `HEAD`
$ cvs -d:pserver:anoncvs@cvs.gnu.org:/cvsroot/hurd co hurd
* `src/glibc`: [[GNU_C_Library|glibc]]
* CVS `glibc-2_7-branch`
$ cvs -d:pserver:anoncvs@sources.redhat.com:/cvs/glibc ↩
co -r glibc-2_7-branch glibc
$ mv libc glibc-2_7-branch
* Patches:
<http://lists.gnu.org/archive/html/bug-hurd/2007-11/msg00030.html>
* Recent releases of the 2.7 series from <ftp://ftp.gnu.org/gnu/glibc/>
should also be fine, but need the same set of patches as the
`glibc-2_7-branch` needs.
<!--
* CVS `HEAD`
$ cvs -d:pserver:anoncvs@sources.redhat.com:/cvs/glibc ↩
co glibc
$ mv libc glibc-HEAD
* TODO.
<http://lists.gnu.org/archive/html/bug-hurd/2007-11/msg00026.html>
-->
<!--
* `src/gdb`: [[GNU_Debugger|gdb]]
This is optional and will only be compiled if present.
* CVS `gdb_6_6-branch`
$ cvs -d:pserver:anoncvs@sources.redhat.com:/cvs/src ↩
co -r gdb_6_6-branch gdb
$ mv src gdb_6_6-branch
Also needs some patch because of MIG changes, if I remember correctly.
* Recent tarballs from <ftp://ftp.gnu.org/gnu/gdb/> should also work.
-->
### Preparation
Unpack the tarballs if you downloaded any.
Create a directory where the cross build shall be rooted in and a `src`
subdirectory in there. Then create symbolic links for every of the above
packages: from `src/PACKAGE` to where you stored or unpacked it. If you don't
intend to build several cross compilers or use the source trees otherwise, you
can also directly store the source trees in `src/`. The source trees can be
shared between multiple cross build trees since the packages' build systems are
supposed not to modify the files in the source trees. Not all packages adhere
to that, but they fail to do so only for pre-processed documentation, etc.
Either make sure that `cross-gnu-env` and `cross-gnu` are found in `$PATH`
(`~/bin/`, for example) or alternatively remember to use their full paths in
the following.
The system you're running the script on (the *build* system) needs to have a
basic compiling environment installed, i.e., a C compiler with the basic
libraries and `make`. You might also need `flex` and `bison`. For building
recent version of GCC (e.g., the upcoming 4.3, which is not yet supported)
you'll need to have development packages of GMP and MPFR installed.
### Setting Up the Environment
Do this every time you intend to use the cross compiler:
$ ROOT=to/the/cross/build/root
$ . cross-gnu-env
This will set several environment variables, which are later used by (a) the
`cross-gnu` script and (b) by you, the user of the cross compiler. `$TARGET`
will be set by the script, `$PATH` will be adjusted, etc. See the
`cross-gnu-env` file for all environment variables that are set, as well as
their default values. `$ROOT` will be made an absolute path if it isn't
already.
Later, you'll be able to do things like `../configure --host="$TARGET"` and the
cross compiler will be found automatically.
### Creating the Cross Build Environment
After setting up the environemt, just run `cross-gnu` and watch the messages
flow by. In the end you should see a message: *[...]/cross-gnu: Everything
should be in place now.*
### Makefile
A [[Makefile]] has been written to automate the above steps. You will require
an Internet connection and atleast 1.5 GiB of hard-disk space. Just run...
make
... to build the toolchain. To clean up, use...
make clean
### Staying Up-To-Date
You can re-run `cross-gnu` to rebuild the parts of the sources that have
changed since the last run. This will save a lot of time compared to starting
from scratch again. Also, it is especially useful if you aren't working with
unpacked tarballs, but on CVS's branches or want to quickly get a new tool
chain with patches you applied to the source trees. However: do *not* use this
technique when doing major changes to the source trees, like switching from GCC
4.0 to GCC 4.1.
# References
* <http://lists.gnu.org/archive/html/bug-hurd/2004-09/msg00030.html>
|