File: INSTALL-cross

package info (click to toggle)
hurd 1:0.9.git20190331-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 37,860 kB
  • sloc: ansic: 540,570; sh: 5,033; asm: 3,099; makefile: 2,201; yacc: 1,288; perl: 589; pascal: 484; awk: 183
file content (335 lines) | stat: -rw-r--r-- 11,299 bytes parent folder | download | duplicates (2)
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
Cross-compiling the GNU Hurd                             -*- Outline -*-

* READ HERE!

The procedure described below -- albeit not completely obsolete, of course --
is outdated a bit.  If you attempt to build a cross compiler, have a look at
<http://www.gnu.org/software/hurd/toolchain/cross-gnu.html> for now.

Last update 1998-06-01  Gordon Matzigkeit  <gord@gnu.org>.
Previous update 1996-04-11  Thomas Bushnell, n/BSG  <thomas@gnu.org>.

* Introduction
These are instructions for building the Hurd as in cross-development
environment.  Unless you are building the Hurd on an already running
Hurd system, you will need these directions to build the Hurd from any
other kind of system.  Even if you are using a Mach system (Lites,
say) you will *STILL* need to follow these directions; this is still
cross-compilation.

IMPORTANT: If you are not prepared to fix bugs without begging other
people for help, or you lack patience, then this process is *not for
you*!  Go get a binary distribution... downloading 80MB of files over
a 9600 baud PPP connection takes far less time and effort than
cross-compiling, especially when you consider that the size of the
source code for all the packages in the Hurd binary distribution is
larger than the distribution itself.

You will need *at least* 500 MB of free disk space for the build
process.  More is always better.

NOTE: On the other hand, do not be sloppy with any of these
instructions, until you have tried following them exactly, and they
didn't work for you the first time. There are all sorts of pitfalls
and untested paths, so it is better not to be creative with things
(like trying to install the cross-compiler somewhere other than
/usr/local).  Expect random problems if you deviate from these
instructions.  You have been warned.

In other words, follow these instructions closely, but not blindly.

You may wish to create build logs, so that you can trace any problems
after you let a compilation run unattended.  To do this, background
and redirect all make output to a file (i.e. `nohup make -k >&
make.out &').  If you wish to monitor the build, you can use a command
like `tail -f make.out'.  After the build completes, simply search the
log for `***' (i.e. `grep '\*\*\*' make.out'), and you'll find any
errors.

* Cross-compiler tools

First you must install a cross-GCC and binutils.  Currently, GCC 2.8.1
and binutils version 2.9.1 are the minimum suggested versions.

Even if you are building the Hurd on a 586, even if it's running a
different Mach-based OS, you are still cross-compiling.  Don't attempt
to use tools that have been configured for something other than
i586-gnu (unless, of course, you are trying to port the Hurd to a
different processor).

** Binutils

The cross-binutils installation is quite straightforward.  Just
configure, build and install them with commands like:

$ [cd to top of binutils source tree]
$ mkdir obj
$ cd obj
$ ../configure --prefix=/usr/local --target=i586-gnu
[...]
$ make
[...]
$ su
Password:
# make install
[...]
#

The above instructions show you how to create a new build
subdirectory, `obj', and then configure and build the package there.
You should get used to this process, because some of the Hurd packages
will not build properly in any other way.

This installation should be smooth.  If you see any strange errors
during the build process, you should investigate them, since they are
probably bugs.

** GCC (attempt #1)

Bootstrapping a GCC cross-compiler is only slightly more difficult
than installing a cross-binutils.  GCC has a few interdependencies
with the Hurd libc, such as the creation of the `libgcc2.a' library.

Therefore, the first time you try compiling and installing GCC, you
will need to kludge things so that you can get a mostly-working
compiler, then come back and redo them to get a fully-working
compiler.

There is a bug when creating a cross-compiler on certain platforms.
In order to avoid this bug, you should copy a working `float.h' header
file from a known working GCC installation for the same processor.  On
a GNU/Linux machine using gcc-2.7.2.1, `float.h' can be found in
`/usr/lib/gcc-lib/i386-linux/2.7.2.1/include/float.h'.  In general,
you can find it in
`$(prefix)/lib/gcc-lib/$(host)/$(VERSION)/include/float.h'.  You will
need to copy this file into the `include' subdirectory of the unpacked
GCC distribution, overwriting the old `include/float.h' if it exists.

The build process should look something like the following.  Be sure
to use the `-k' and `LANGUAGES=c' make arguments this time around, or
else the build will fail in random places:

$ [cd to top of gcc source tree]
$ cp /usr/lib/gcc-lib/i386-linux/2.7.2.1/include/float.h include/float.h
$ mkdir obj
$ cd obj
$ ../configure --prefix=/usr/local --target=i586-gnu --with-gnu-as --with-gnu-ld
[...]
$ make -k CFLAGS="-g -O2" LANGUAGES=c
[... fails while trying to build libgcc2.a]
$ su
Password:
# make -k install LANGUAGES=c
[again, fails on libgcc2.a]
#

If the build fails anywhere except on libgcc2, you have a problem.
Investigate it.  Otherwise, you should now have a mostly-working
cross-compiler suite in /usr/local.

NOTE: Do not delete the GCC compile tree.  You will need it later in
order to finish the installation.  If you choose to delete it, you
will have to repeat this step in its entirety.

* Set up the Hurd root

You need space to "install" the compiled Hurd, its libraries, include
files, and binaries that will run on the Hurd.  In these instructions,
we will refer to this as the "installation staging area".  This will,
more or less, be a suitable image to use as a Hurd root image when you
are finished.

This space needs to be accessible to the machine doing the
cross-compilation, because the libc and include files that go in the
Hurd's root filesystem are the same ones that are needed during
cross-compilation.

We strongly advise that this directory not be put in /usr/local.  This
will tend to cause confusion.  It would be a good idea to create a new
filesystem, and mount it on your cross-compilation machine as /hurd.

If you followed the directions above, then in /usr/local/i586-gnu you
already have a number of cross-development tools (ar, ranlib, ld, as
and so forth).  This is the place where the compiler looks for
cross-development stuff.  So now make two symlinks, named
/usr/local/i586-gnu/include and /usr/local/i586-gnu/lib, and point
them at /hurd/include and /hurd/lib, where `/hurd' is the name of your
Hurd installation staging area.

If /usr/local/i586-gnu/include or /usr/local/i586-gnu/lib already
exists, you should move their contents to your Hurd installation
staging area before creating the symlinks.

If you don't do these steps, you will lose.  Do them now.

* Install Mach

Get the latest gnumach distribution, and configure it to cross
compile.  You should read the README in order to determine which
device driver options you should use.  You should also specify your
current build platform... in the following example, we are
cross-compiling from an i586-linux-gnu machine:

$ [cd to top of gnumach source tree]
$ mkdir obj
$ cd obj
$ CC=i586-gnu-gcc ../configure --build=i586-linux-gnu --host=i586-gnu \
  --enable-com --enable-floppy --enable-ide --enable-aha152x
[...]
$ make
[...]
$ su
Password:
# make install prefix=/hurd
[...]
#

Besides building the Mach kernel, this step installs several Mach
headers and interface files into the staging area.  These files are
required for cross-compilation.

* Install a cross-MiG

This process can be confusing, because there are so many different
varieties of cross-compilers:

1) When you were building Mach, above, the build process needed a MiG
which can could run on the build machine, but create code for GNU.
This is called `local-mig' in the Mach Makefiles.

2) Then, when you installed Mach, you also installed a MiG which can
run on GNU and create code for GNU.  This is called `cross-mig' in the
Makefiles.

3) Now, you need to install a version of MiG like #1, so that you can
use it to build the C library and the Hurd.  Unfortunately, the shell
script wrapper used in #1 is not appropriate for installation, so you
need to generate Yet-Another-MiG:

# make install-local-mig prefix=/usr/local
[...]
#

Be sure to set the `prefix' variable as indicated, or you will
accidentally clobber the MiG you installed in the previous step.

* Build the GNU C library

In order to build the GNU C library for the Hurd, you will need recent
versions of several tools, including gawk.  See the glibc INSTALL file
for more details.

** Install Hurd headers

The Hurd interface definitions and include files need to be visible to
the cross-compiler so that the C library can use them.

$ [cd to top of hurd source tree]
$ mkdir obj
$ cd obj
$ ../configure --build=i586-linux-gnu --host=i586-gnu \
  --prefix=/hurd --disable-profile
[...]
$ su
Password:
# make install-headers no_deps=t
[...]
#

This step may spout a few warning messages, but you don't need to
worry about them, because you aren't interested in compiling any of
the Hurd (yet).


** Build and install C library

Configure, compile, and install the core GNU C library (note that we
reset the `install_root' variable instead of `prefix'):

$ [cd to top of glibc source tree]
$ mkdir obj
$ cd obj
$ ../configure --build=i586-linux-gnu --host=i586-gnu \
   --prefix= --enable-add-ons=crypt --disable-profile
[...]
$ make -k
[... fails when trying to link programs]
$ su
Password:
# make -k install install_root=/hurd
[... again, fails]
#

This process fails because the cross-GCC you installed is missing
libgcc2.a, which is required to link working programs.  Do not delete
the libc source files... you will need them again very soon.

** Finish GCC install

If you were silly, and deleted the GCC source tree, you need to go
back to the first GCC build step and follow those instructions again
(which should successfully build and install the entire C
cross-compiler).

Otherwise, there are now enough headers to finish installing the GCC
cross-compiler, so do it:

$ [cd to top of gcc source tree]
$ cd obj
$ make -k
[...]
$ su
Password:
# make -k install
[...]
#

This time there should be no failures.

** Finish libc install

Now there is a fully-working GCC, so the libc programs can be built.
Continue the build process:

$ [cd to top of glibc source tree]
$ cd obj
$ make -k
[...]
$ su
Password:
# make -k install install_root=/hurd
[...]
#

There should be no errors or warnings from this step.


* Install the Hurd

Since you already configured the Hurd in a previous step, you can now
build and install it:

$ [cd to top of hurd source tree]
$ cd obj
$ make -k
[...]
$ su
Password:
# make -k install prefix=/hurd
[...]
#

This step should complete with no problems.


* Final details

Now in your Hurd staging area are the complete binaries for the Hurd
and its programs, and the C library and its associated programs.  You
will want binaries for other programs too, of course--for example, you
have no shell yet.  In general, you can build most GNU packages
without too much hassle using your cross compilers.  In this way you
can build up as much of a binary distribution as you like.

See the file `INSTALL-binary' for instructions on bootstrapping and
running your new binaries.