summaryrefslogtreecommitdiff
path: root/hurd/building.mdwn
blob: 7cfc7c7ea0eea0530deb1618e410ea04b70313c6 (plain)
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
/!\ The following information may very well be incomplete and out-dated.

If you want to build the Hurd libraries and servers (translators) yourself
instead of just using pre-built binaries, follow these instructions.

One note before we begin: the likelihood that the compiled result will actually
do what you expect it to do is the highest if you try building from the Debian
source packages.  This is especially true if you want to use your compilation
within a Debian system.

Note that for building code to run on GNU/Hurd systems, you need a toolchain
for the GNU Hurd.  You can either compile on a GNU/Hurd system, or need a
cross-compiler targeting GNU/Hurd.  Our [[toolchain page|toolchain]] has the
details.

[[!toc]]


# Preparing for the Build

## ... on Debian systems

Building the Hurd requires the *build-essential* and *fakeroot* packages, their
dependencies and additional packages that are specified by the source hurd
package:

    # apt install build-essential fakeroot
    # apt build-dep hurd

## ... on non-Debian systems

[TODO]

# Getting the Source Code

You can chose between getting the [sources from the developers's
git](http://savannah.gnu.org/git/?group=hurd):

    $ git clone git://git.sv.gnu.org/hurd/hurd.git

... or (if you are working on a Debian system) the ones that are used for the
[current Debian hurd package](http://packages.debian.net/source/unstable/hurd):

    $ apt source hurd

Please see the Debian [[FAQ]] before using `apt source`.

The unpacked source tree is around 20 MiB, and the build tree (configured with
`--disable-profile`) is around 100 MiB.

# Building

## Debian `.deb` Files

Change into the directory with the downloaded / unpacked Hurd sources, e.g.

    $ cd hurd-VERSION

If you want to work on the sources before building them, it's advisable to
first make sure that patches that the Debian hurd package additionally contains
are applied:

    $ dh_quilt_patch

Then edit and change whatever files you want and finally start the build
process with

    $ dpkg-buildpackage -us -uc -nc -b -rfakeroot

The `.deb` packages will then drop out at the `../` directory.

## Building, but not the Debian Way

First create configure file:

    $ cd hurd-VERSION/
    $ autoreconf --install
    $ cd ..

Note: You need GNU MiG to compile the GNU Hurd [TODO: add how]

The Hurd has to be built in a separate directory:

    $ mkdir hurd-build
    $ cd hurd-build

    $ [...]/hurd-VERSION/configure --disable-profile
    $ make
    $ make install

Notice that `make install` will install the Hurd in `/`, not in `/usr/local/`
or `/local/`, so your current Hurd servers will be replaced.
To install to a different location, specify `--prefix=PREFIX` as `configure`
parameter, e.g. `--prefix=/usr` (as done when having a real `/usr`).

By default profiling versions of all the libraries and code are generated but
this is useless in most of the cases, so we disable them by specifying
`--disable-profile` on `configure`'s command line.

If you just want to build a specific server or library, you can pass its name
to `make`:

    $ make ext2fs
    $ make libtrivfs

This will automatically build all libraries that are required to build the
requested server or library.


# RPC IDs

[TODO: update / integrate somewhere.]

If you want to trace the RPC calls made by some process by using `rpctrace`
command, you will also want some more human-readable output of this
command. This is achieved by generating `hurd.msgids` file that includes the
mapping between the number of the RPC call and its name:

    $ cd build/hurd
    $ make hurd.msgids
    $ cp hurd.msgids ~

Now you can use this file in the following way:

    $ rpctrace -i ~/hurd.msgids ls


# Testing

Any statically linked binaries (`make proc && (cd proc/ && make proc.static)`)
can be used directly, as they are self-contained regarding the Hurd libraries
they're using.

Dynamically linked binaries will use the system's shared Hurd libraries, which
may be or may not be what you want.

Check:

    $ ldd utils/ps
            libhurdbugaddr.so.0.3 => /lib/libhurdbugaddr.so.0.3 (0x01036000)
            libps.so.0.3 => /lib/libps.so.0.3 (0x01038000)
            libihash.so.0.3 => /lib/libihash.so.0.3 (0x0104a000)
            libshouldbeinlibc.so.0.3 => /lib/libshouldbeinlibc.so.0.3 (0x0104e000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x0105a000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x011eb000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x01211000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Run:

    $ utils/ps
    [...]

For example, if you have done changes to [[libps]] and now want to test them
with `ps` (which dynamically links to libps), this is not good.  To overcome
this, `LD_LIBRARY_PATH` can be used:

Check:

    $ LD_LIBRARY_PATH="$PWD"/libps ldd utils/ps
            libhurdbugaddr.so.0.3 => /lib/libhurdbugaddr.so.0.3 (0x01036000)
            libps.so.0.3 => /home/thomas/tmp/hurd/git.build/libps/libps.so.0.3 (0x01038000)
            libihash.so.0.3 => /lib/libihash.so.0.3 (0x0104b000)
            libshouldbeinlibc.so.0.3 => /lib/libshouldbeinlibc.so.0.3 (0x0104e000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x0105a000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x011eb000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x01211000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Run:

    $ LD_LIBRARY_PATH="$PWD"/libps utils/ps
    [...]

Additionally, a `hurd-build/lib` directory is populated with links to *all*
shared Hurd libraries.

Check:

    $ LD_LIBRARY_PATH="$PWD"/lib ldd utils/ps
            libhurdbugaddr.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libhurdbugaddr.so.0.3 (0x0102b000)
            libps.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libps.so.0.3 (0x0102d000)
            libihash.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libihash.so.0.3 (0x01040000)
            libshouldbeinlibc.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libshouldbeinlibc.so.0.3 (0x01043000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x0105a000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x011eb000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x01211000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Run:

    $ LD_LIBRARY_PATH="$PWD"/lib utils/ps
    [...]

Likewise, if there is a reason to, it is possible to use the system's `/bin/ps`
with a freshly built libps:

    $ LD_LIBRARY_PATH="$PWD"/libps /bin/ps
    [...]

Etc.

And, the same is possible with [[translator]]s, too.

Check, system's shared Hurd libraries:

    $ ldd tmpfs/tmpfs
            libhurdbugaddr.so.0.3 => /lib/libhurdbugaddr.so.0.3 (0x01036000)
            libdiskfs.so.0.3 => /lib/libdiskfs.so.0.3 (0x01038000)
            libpager.so.0.3 => /lib/libpager.so.0.3 (0x01060000)
            libiohelp.so.0.3 => /lib/libiohelp.so.0.3 (0x01069000)
            libfshelp.so.0.3 => /lib/libfshelp.so.0.3 (0x0106c000)
            libstore.so.0.3 => /lib/libstore.so.0.3 (0x01072000)
            libthreads.so.0.3 => /lib/libthreads.so.0.3 (0x010ba000)
            libports.so.0.3 => /lib/libports.so.0.3 (0x010c1000)
            libihash.so.0.3 => /lib/libihash.so.0.3 (0x010ca000)
            libshouldbeinlibc.so.0.3 => /lib/libshouldbeinlibc.so.0.3 (0x010ce000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x010da000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x0126b000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x01282000)
            libparted.so.0 => /lib/libparted.so.0 (0x012a8000)
            libuuid.so.1 => /lib/libuuid.so.1 (0x01315000)
            libdl.so.2 => /lib/i386-gnu/libdl.so.2 (0x01319000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Check, local libdiskfs, and otherwise system's shared Hurd libraries:

    $ LD_LIBRARY_PATH="$PWD"/libdiskfs ldd tmpfs/tmpfs
            libhurdbugaddr.so.0.3 => /lib/libhurdbugaddr.so.0.3 (0x01036000)
            libdiskfs.so.0.3 => /home/thomas/tmp/hurd/git.build/libdiskfs/libdiskfs.so.0.3 (0x01038000)
            libpager.so.0.3 => /lib/libpager.so.0.3 (0x01061000)
            libiohelp.so.0.3 => /lib/libiohelp.so.0.3 (0x01069000)
            libfshelp.so.0.3 => /lib/libfshelp.so.0.3 (0x0106c000)
            libstore.so.0.3 => /lib/libstore.so.0.3 (0x01072000)
            libthreads.so.0.3 => /lib/libthreads.so.0.3 (0x010ba000)
            libports.so.0.3 => /lib/libports.so.0.3 (0x010c1000)
            libihash.so.0.3 => /lib/libihash.so.0.3 (0x010cb000)
            libshouldbeinlibc.so.0.3 => /lib/libshouldbeinlibc.so.0.3 (0x010ce000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x010da000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x0126b000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x01282000)
            libparted.so.0 => /lib/libparted.so.0 (0x012a9000)
            libuuid.so.1 => /lib/libuuid.so.1 (0x01315000)
            libdl.so.2 => /lib/i386-gnu/libdl.so.2 (0x01319000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Check, all local shared Hurd libraries:

    $ LD_LIBRARY_PATH="$PWD"/lib ldd tmpfs/tmpfs
            libhurdbugaddr.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libhurdbugaddr.so.0.3 (0x0102b000)
            libdiskfs.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libdiskfs.so.0.3 (0x0102d000)
            libpager.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libpager.so.0.3 (0x01056000)
            libiohelp.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libiohelp.so.0.3 (0x0105e000)
            libfshelp.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libfshelp.so.0.3 (0x01061000)
            libstore.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libstore.so.0.3 (0x01066000)
            libthreads.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libthreads.so.0.3 (0x010ae000)
            libports.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libports.so.0.3 (0x010b6000)
            libihash.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libihash.so.0.3 (0x010be000)
            libshouldbeinlibc.so.0.3 => /home/thomas/tmp/hurd/git.build/lib/libshouldbeinlibc.so.0.3 (0x010c1000)
            libc.so.0.3 => /lib/i386-gnu/libc.so.0.3 (0x010d8000)
            libmachuser.so.1 => /lib/i386-gnu/libmachuser.so.1 (0x01269000)
            libhurduser.so.0.3 => /lib/i386-gnu/libhurduser.so.0.3 (0x01281000)
            libparted.so.0 => /lib/libparted.so.0 (0x012a7000)
            libuuid.so.1 => /lib/libuuid.so.1 (0x01313000)
            libdl.so.2 => /lib/i386-gnu/libdl.so.2 (0x01317000)
            /lib/ld.so => /lib/ld.so.1 (0x00001000)

Run, system's shared Hurd libraries:

    $ settrans -ca tmp-0 /usr/bin/env "$PWD"/tmpfs 32M

Run, local libdiskfs, and otherwise system's shared Hurd libraries:

    $ settrans -ca tmp-0 /usr/bin/env LD_LIBRARAY_PATH="$PWD"/libdiskfs "$PWD"/tmpfs 32M

Run, all local shared Hurd libraries:

    $ settrans -ca tmp-0 /usr/bin/env LD_LIBRARAY_PATH="$PWD"/lib "$PWD"/tmpfs 32M

Likewise, if there is a reason to, it is possible to use the system's
`/hurd/tmpfs` with a freshly built libdiskfs:

    $ settrans -ca tmp-0 /usr/bin/env LD_LIBRARAY_PATH="$PWD"/libdiskfs /hurd/tmpfs 32M

Etc.