~ubuntu-branches/debian/sid/gcc-4.8/sid

« back to all changes in this revision

Viewing changes to .svn/pristine/56/56cd7b799eeaaff2f9a78771a829f406b3c5d981.svn-base

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-12-19 19:48:34 UTC
  • Revision ID: package-import@ubuntu.com-20141219194834-4dz1q7rrn5pad823
Tags: 4.8.4-1
* GCC 4.8.4 release.
  - Fix PR target/61407 (darwin), PR middle-end/58624 (ice),
    PR sanitizer/64265 (wrong code).
* Require recent binutils to pass go test failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-*- Outline -*-
 
2
 
 
3
Read this file if you are a Debian Developer or would like to become
 
4
one, or if you would like to create your own binary packages of GCC.
 
5
 
 
6
* Overview
 
7
 
 
8
From the GCC sources, Debian currently builds 3 source packages and
 
9
almost 100 binary packages, using a single set of build scripts.  The
 
10
3 source packages are:
 
11
 
 
12
gcc-4.3: C, C++, Fortran, Objective-C and Objective-C++, plus many
 
13
         common libraries like libssp and libgcc.
 
14
gcj-4.3: Java.
 
15
gnat-4.3: Ada.
 
16
 
 
17
The way we do this is quite peculiar, so listen up :)
 
18
 
 
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
 
21
upstream tarball and some Debian-specific patches.  Any user can then
 
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
 
24
Makefile snippets that unpack and patch them.
 
25
 
 
26
The intended use for this package is twofold: (a) allow users to build
 
27
their own cross-compilers, and (b) build the other two packages,
 
28
gcj-4.3 and gnat-4.3.
 
29
 
 
30
For gcj-4.3 and gnat-4.3, the "source tarball" just contains an empty
 
31
directory; e.g.:
 
32
 
 
33
$ tar tzf gnat-4.3_4.3-20070609.orig.tar.gz
 
34
gnat-4.3-4.3-20070609.orig/
 
35
 
 
36
The build scripts for all source packages are the same, and they are
 
37
included, as usual, in the .diff.gz file.
 
38
 
 
39
* The build sequence
 
40
 
 
41
As for all other Debian packages, you build GCC by calling
 
42
debian/rules.
 
43
 
 
44
The first thing debian/rules does it to look at the top-most entry in
 
45
debian/changelog: this tells it which source package it is building.
 
46
For example, if the first entry in debian/changelog reads:
 
47
 
 
48
gcj-4.3 (4.3-20070609-1) unstable; urgency=low
 
49
 
 
50
  * Upload as gcj-4.3.
 
51
 
 
52
 -- Ludovic Brenta <lbrenta@debian.org>  Tue, 26 Jun 2007 00:26:42 +0200
 
53
 
 
54
then, debian/rules will build only the Java binary packages.
 
55
 
 
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
 
59
source packages).
 
60
 
 
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
 
63
control file contains only the binary packages to be built.
 
64
 
 
65
The fourth step is to select which patches to apply (this is done in
 
66
debian/rules.defs), and then to apply the selected patches (see
 
67
debian/rules.patch).
 
68
 
 
69
The fifth step is to create a "build" directory, cd into it, call
 
70
../src/configure, and bootstrap the compiler and libraries selected.
 
71
This is in debian/rules2.
 
72
 
 
73
The sixth step is to call "make install" in the build directory: this
 
74
installs the compiler and libraries into debian/tmp
 
75
(i.e. debian/tmp/usr/bin/gcc, etc.)
 
76
 
 
77
The seventh step is to run the GCC test suite (this actually takes at
 
78
least as much time as bootstrapping, and you can disable it by setting
 
79
WITHOUT_CHECK to "yes" in the environment).
 
80
 
 
81
The eighth step is to build the binary packages, i.e. the .debs.  This
 
82
is done by a set of language- and architecture-dependent Makefile
 
83
snippets in the debian/rules.d/ directory, which move files from the
 
84
debian/tmp tree to the debian/<package> trees.
 
85
 
 
86
* Making your own packages
 
87
 
 
88
In this example, we will build our own gnat-4.3 package.
 
89
 
 
90
1) Create a .orig.tar.gz tarball containing a single, empty directory.
 
91
 
 
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
 
94
 
 
95
2) Install gcc-4.3-source, which contains the real sources:
 
96
 
 
97
# apt-get install gcc-4.3-source
 
98
 
 
99
3) Create a build directory:
 
100
 
 
101
$ mkdir gnat-4.3-4.3-20070609; cd gnat-4.3-4.3-20070609
 
102
 
 
103
4) Checkout from Subversion:
 
104
 
 
105
$ svn checkout svn://svn.debian.org/gcccvs/branches/sid/gcc-4.3/debian
 
106
 
 
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".
 
109
 
 
110
6) Generate the debian/control file, adjusted for gnat:
 
111
 
 
112
$ debian/rules control
 
113
 
 
114
7) Build:
 
115
 
 
116
$ dpkg-buildpackage -rfakeroot
 
117
 
 
118
* Hints
 
119
 
 
120
You need a powerful machine to build GCC.  The larger, the better.
 
121
The build scripts take advantage of as many CPU threads as are
 
122
available in your box (for example: 2 threads on a dual-core amd64; 4
 
123
threads on a dual-core POWER5; 32 threads on an 8-core UltraSPARC T1,
 
124
etc.).
 
125
 
 
126
If you have 2 GB or more of physical RAM, you can achieve maximum
 
127
performance by building in a tmpfs, like this:
 
128
 
 
129
1) as root, create the new tmpfs:
 
130
 
 
131
# mount -t tmpfs -o size=1280m none /home/lbrenta/src/debian/ram
 
132
 
 
133
By default, the tmpfs will be limited to half your physical RAM.  The
 
134
beauty of it is that it only consumes as much physical RAM as
 
135
necessary to hold the files in it; deleting files frees up RAM.
 
136
 
 
137
2) As your regular user, create the working directory in the tmpfs
 
138
 
 
139
$ cp --archive ~/src/debian/gcc-4.3-4.3-20070901 ~/src/debian/ram
 
140
 
 
141
3) Build in there.  On my dual-core, 2 GHz amd64, it takes 34 minutes
 
142
   to build gnat, and the tmpfs takes 992 MiB of physical RAM but
 
143
   exceeds 1 GiB during the build.
 
144
 
 
145
Note that the build process uses a lot of temporary files.  Your $TEMP
 
146
directory should therefore also be in a ram disk.  You can achieve
 
147
that either by mounting it as tmpfs, or by setting TEMP to point to
 
148
~/src/debian/ram.
 
149
 
 
150
Also note that each thread in your processor(s) will run a compiler in
 
151
it and use up RAM.  Therefore your physical memory should be:
 
152
 
 
153
Physical_RAM >= 1.2 + 0.4 * Threads (in GiB)
 
154
 
 
155
(this is an estimate; your mileage may vary).  If you have less
 
156
physical RAM than recommended, reduce the number of threads allocated
 
157
to the build process, or do not use a tmpfs to build.
 
158
 
 
159
* Patching GCC
 
160
 
 
161
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.
 
168
 
 
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:
 
171
 
 
172
1) Apply all patches up to and EXCLUDING the patch you intend to
 
173
   modify, in order.
 
174
 
 
175
2) Make a deep copy of the src directory, e.g.
 
176
   $ cp --archive src src.bak
 
177
 
 
178
3) Apply the patch you intend to modify.
 
179
 
 
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.
 
182
 
 
183
5) Change the files you want in the src directory.  After making
 
184
   changes, you can experiment with
 
185
   $ make -C build -jK
 
186
   (where K is the number of processor threads you have)
 
187
 
 
188
6) $ diff -rNu src.bak src >> debian/patches/<file>.dpatch
 
189
 
 
190
7) Apply all remaining patches, to see if your change broke any of
 
191
   them.
 
192
 
 
193
8) $ svn commit debian/patches/<file>.dpatch
 
194
 
 
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
 
199
debian/rules.patch.
 
200
 
 
201
** Patching GCC with Quilt
 
202
 
 
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.
 
209
 
 
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:
 
213
 
 
214
$ egrep '^[^ ]+:' stamps/02-patch-stamp | \
 
215
  sed 's!:!.dpatch -p0!' > debian/patches/series
 
216
 
 
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
 
219
patches.
 
220
 
 
221
Once you have your debian/patches/series:
 
222
 
 
223
$ debian/rules unpatch
 
224
$ export QUILT_PATCHES=$PWD/debian/patches
 
225
$ cd src
 
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
 
228
$ make -C ../build
 
229
$ quilt refresh
 
230
$ quilt push -a # check that no patch is broken
 
231
$ quilt pop -a
 
232
$ cd ..
 
233
$ debian/rules clean build
 
234
$ svn commit
 
235
 
 
236
-- 
 
237
Ludovic Brenta, 2007-12-05.