9
9
almost 100 binary packages, using a single set of build scripts. The
10
10
3 source packages are:
12
gcc-4.3: C, C++, Fortran, Objective-C and Objective-C++, plus many
12
gcc-x.y: C, C++, Fortran, Objective-C and Objective-C++, plus many
13
13
common libraries like libssp and libgcc.
17
17
The way we do this is quite peculiar, so listen up :)
19
When we build from the gcc-4.3 source package, we produce, among many
20
others, a gcc-4.3-source binary package that contains the pristine
19
When we build from the gcc-x.y source package, we produce, among many
20
others, a gcc-x.y-source binary package that contains the pristine
21
21
upstream tarball and some Debian-specific patches. Any user can then
22
22
install this package on their Debian system, and will have the full
23
souces in /usr/src/gcc-4.3/gcc-<timestamp>.tar.bz2, along with the
23
souces in /usr/src/gcc-x.y/gcc-<timestamp>.tar.bz2, along with the
24
24
Makefile snippets that unpack and patch them.
26
26
The intended use for this package is twofold: (a) allow users to build
27
27
their own cross-compilers, and (b) build the other two packages,
30
For gcj-4.3 and gnat-4.3, the "source tarball" just contains an empty
33
$ tar tzf gnat-4.3_4.3-20070609.orig.tar.gz
34
gnat-4.3-4.3-20070609.orig/
36
The build scripts for all source packages are the same, and they are
37
included, as usual, in the .diff.gz file.
30
- gcc-x.y requires only a C compiler to build and produces C, C++,
31
Fortran, Go and Objective-C compilers and libraries. It also
32
produces the binary package gcc-x.y-source containing all the
33
sources and patches in a tarball.
35
- gcj-x.y build-depends on gcc-x.y-source and C++ and Java compilers.
36
Its .orig.tar.bz2 file only contains an empty directory; the real
37
sources from which it builds the binary packages are in
40
- gnat-x.y build-depends on gcc-x.y-source and an Ada compiler. It
41
does not even have an .orig.tar.bz2 package; it is a Debian native
44
The benefits of this split are many:
46
- bootstrapping a subset of languages is much faster than
47
bootstrapping all languages and libraries (which can take a full
48
week on slow architectures like mips or arm)
50
- the language maintainers don't have to wait for each other
52
- for new ports, the absence of a port of, say, gnat-x.y does not
53
block the porting of gcc-x.y.
55
gcc-x.y-source is also intended for interested users to build
56
cross-compiler packages. Debian cannot provide all possible
57
cross-compiler packages (i.e. all possible host, target, language and
58
library combinations), so instead tries to facilitate building them.
39
60
* The build sequence
54
75
then, debian/rules will build only the Java binary packages.
56
The second step is to unpack the GCC source tarball. This tarball is
57
either in the build directory (when building gcc-4.3), or in
58
/usr/src/gcc-4.3/gcc-<timestamp>.tar.bz2 (when building the other
61
The third step is to build debian/control from debian/control.m4 and a
62
complex set of rules specified in debian/rules.conf. The resulting
77
The second step is to build debian/control from debian/control.m4 and
78
a complex set of rules specified in debian/rules.conf. The resulting
63
79
control file contains only the binary packages to be built.
65
The fourth step is to select which patches to apply (this is done in
81
The third step is to select which patches to apply (this is done in
66
82
debian/rules.defs), and then to apply the selected patches (see
69
The fifth step is to create a "build" directory, cd into it, call
83
debian/rules.patch). The result of this step is a generated
84
debian/patches/series file for use by quilt.
86
The fourth step is to unpack the GCC source tarball. This tarball is
87
either in the build directory (when building gcc-x.y), or in
88
/usr/src/gcc-x.y/gcc-x.y.z.tar.xz (when building the other source
91
The fifth step is to apply all patches to the unpacked sources with
94
The sixth step is to create a "build" directory, cd into it, call
70
95
../src/configure, and bootstrap the compiler and libraries selected.
71
96
This is in debian/rules2.
73
The sixth step is to call "make install" in the build directory: this
74
installs the compiler and libraries into debian/tmp
98
The seventh step is to call "make install" in the build directory:
99
this installs the compiler and libraries into debian/tmp
75
100
(i.e. debian/tmp/usr/bin/gcc, etc.)
77
The seventh step is to run the GCC test suite (this actually takes at
102
The eighth step is to run the GCC test suite. This actually takes at
78
103
least as much time as bootstrapping, and you can disable it by setting
79
WITHOUT_CHECK to "yes" in the environment).
104
WITHOUT_CHECK to "yes" in the environment.
81
The eighth step is to build the binary packages, i.e. the .debs. This
106
The ninth step is to build the binary packages, i.e. the .debs. This
82
107
is done by a set of language- and architecture-dependent Makefile
83
108
snippets in the debian/rules.d/ directory, which move files from the
84
109
debian/tmp tree to the debian/<package> trees.
86
111
* Making your own packages
88
In this example, we will build our own gnat-4.3 package.
90
1) Create a .orig.tar.gz tarball containing a single, empty directory.
92
$ mkdir gnat-4.3-4.3-20070609.orig
93
$ tar czf gnat-4.3_4.3-20070609.orig.tar.gz gnat-4.3-4.3-20070609.orig
95
2) Install gcc-4.3-source, which contains the real sources:
97
# apt-get install gcc-4.3-source
99
3) Create a build directory:
101
$ mkdir gnat-4.3-4.3-20070609; cd gnat-4.3-4.3-20070609
103
4) Checkout from Subversion:
105
$ svn checkout svn://svn.debian.org/gcccvs/branches/sid/gcc-4.3/debian
107
5) Edit the debian/changelog file, adding a new entry at the top that
108
starts with "gnat-4.3" instead of "gcc-4.3".
110
6) Generate the debian/control file, adjusted for gnat:
113
In this example, we will build our own gnat-x.y package.
115
1) Install gcc-x.y-source, which contains the real sources:
117
# aptitude install gcc-x.y-source
119
2) Create a build directory:
121
$ mkdir gnat-x.y-x.y.z; cd gnat-x.y-x.y.z
123
3) Checkout from Subversion:
125
$ svn checkout svn://svn.debian.org/gcccvs/branches/sid/gcc-x.y/debian
127
4) Edit the debian/changelog file, adding a new entry at the top that
128
starts with "gnat-x.y".
130
5) Generate the debian/control file, adjusted for gnat:
112
132
$ debian/rules control
116
$ dpkg-buildpackage -rfakeroot
161
181
Debian applies a large number of patches to GCC as part of the build
162
process. The patches are shell scripts located in debian/patches.
163
The file debian/rules.defs selects the language front-ends and
164
libraries to build. Then, based on that, debian/rules.patch selects
165
which patches to apply and in which order, then applies them and
166
produces a file listing the applied patches in order in
167
stamps/02-patch-stamp.
169
There is currently no tool to help modify patches; you have to do it
170
by hand. Here is one possible way to do it:
172
1) Apply all patches up to and EXCLUDING the patch you intend to
175
2) Make a deep copy of the src directory, e.g.
176
$ cp --archive src src.bak
178
3) Apply the patch you intend to modify.
180
4) Open the .dpatch file in your editor and remove the entire patch
181
section; leave alone the shell script part at the top.
183
5) Change the files you want in the src directory. After making
184
changes, you can experiment with
186
(where K is the number of processor threads you have)
188
6) $ diff -rNu src.bak src >> debian/patches/<file>.dpatch
190
7) Apply all remaining patches, to see if your change broke any of
193
8) $ svn commit debian/patches/<file>.dpatch
195
If you want to add a new patch, the procedure is similar. You must
196
first choose where in the list of patches you want to insert your new
197
patch. Then, apply all patches up to that point and start editing.
198
Do not forget to add a reference to your patch at the proper place in
201
** Patching GCC with Quilt
203
The above method uses an entire copy of the source tree, which is
204
currently 474 megabytes in size. If you are in a one-gigabyte ram
205
disk (see Hints above), this may be a problem. One solution to this
206
problem is to use quilt, which will only keep copies of the files
207
touched by patches, not all files. It also automates the updating of
208
a patch after you change the sources.
210
Quilt however does not take into account the selection of patches made
211
in debian/rules.defs; instead it has a static list of patches. After
212
calling "debian/rules patch", you can generate such a list like this:
214
$ egrep '^[^ ]+:' stamps/02-patch-stamp | \
215
sed 's!:!.dpatch -p0!' > debian/patches/series
217
Unfortunately, not all patches are applied with -p0; you must then
218
edit debian/patches/series by hand to replace -p0 with -p1 for a few
221
Once you have your debian/patches/series:
223
$ debian/rules unpatch
182
process. It uses quilt but the necessary debian/patches/series is not
183
part of the packaging scripts; instead, "debian/rules patch" generates
184
this file by looking at debian/control (which is itself generated!),
185
debian/changelog and other files. Then it applies all the patches.
186
At this point, you can use quilt as usual:
188
$ cd ~/src/debian/gcc-x.y
224
189
$ export QUILT_PATCHES=$PWD/debian/patches
226
$ quilt push -a (or quilt push <patch_name>)
227
edit files at will; quilt add <file_name> to add a new file to the patch
230
$ quilt push -a # check that no patch is broken
233
$ debian/rules clean build
192
If you add new patches, remember to add them to the version control
237
Ludovic Brenta, 2007-12-05.
196
Ludovic Brenta, 2012-04-02.