]> git.saurik.com Git - bison.git/blame_incremental - README-hacking
bison: avoid warnings from static code analysis
[bison.git] / README-hacking
... / ...
CommitLineData
1This file attempts to describe the rules to use when hacking Bison.
2Don't put this file into the distribution.
3
4Everything related to the development of Bison is on Savannah:
5
6 http://savannah.gnu.org/projects/bison/
7
8
9* Administrivia
10
11** If you incorporate a change from somebody on the net:
12First, if it is a large change, you must make sure they have signed
13the appropriate paperwork. Second, be sure to add their name and
14email address to THANKS.
15
16** If a change fixes a test, mention the test in the commit message.
17
18** Bug reports
19If somebody reports a new bug, mention his name in the commit message
20and in the test case you write. Put him into THANKS.
21
22The correct response to most actual bugs is to write a new test case
23which demonstrates the bug. Then fix the bug, re-run the test suite,
24and check everything in.
25
26
27* Hacking
28
29** Visible changes
30Which include serious bug fixes, must be mentioned in NEWS.
31
32** Translations
33Only user visible strings are to be translated: error messages, bits
34of the .output file etc. This excludes impossible error messages
35(comparable to assert/abort), and all the --trace output which is
36meant for the maintainers only.
37
38** Horizontal tabs
39Do not add horizontal tab characters to any file in Bison's repository
40except where required. For example, do not use tabs to format C code.
41However, make files, ChangeLog, and some regular expressions require
42tabs. Also, test cases might need to contain tabs to check that Bison
43properly processes tabs in its input.
44
45
46* Working from the repository
47
48These notes intend to help people working on the checked-out sources.
49These requirements do not apply when building from a distribution tarball.
50
51** Requirements
52
53We've opted to keep only the highest-level sources in the repository. This
54eases our maintenance burden, (fewer merges etc.), but imposes more
55requirements on anyone wishing to build from the just-checked-out sources.
56For example, you have to use the latest stable versions of the maintainer
57tools we depend upon, including:
58
59- Autoconf <http://www.gnu.org/software/autoconf/>
60- Automake <http://www.gnu.org/software/automake/>
61- Flex <http://www.gnu.org/software/flex/>
62- Gettext <http://www.gnu.org/software/gettext/>
63- Graphviz <http://www.graphviz.org>
64- Gzip <http://www.gnu.org/software/gzip/>
65- Help2man <http://www.gnu.org/software/help2man/>
66- Perl <http://www.cpan.org/>
67- Rsync <http://samba.anu.edu.au/rsync/>
68- Tar <http://www.gnu.org/software/tar/>
69- Texinfo <http://www.gnu.org/software/texinfo/>
70
71Valgrind <http://valgrind.org/> is also highly recommended, if it supports
72your architecture.
73
74If you're using a GNU/Linux distribution, the easiest way to install the
75above packages depends on your system. The following shell command should
76work for Debian-based systems such as Ubuntu:
77
78 sudo apt-get install \
79 autoconf automake autopoint flex graphviz help2man texinfo valgrind
80
81Bison is written using Bison grammars, so there are bootstrapping issues.
82The bootstrap script attempts to discover when the C code generated from the
83grammars is out of date, and to bootstrap with an out-of-date version of the
84C code, but the process is not foolproof. Also, you may run into similar
85problems yourself if you modify Bison.
86
87Only building the initial full source tree will be a bit painful. Later,
88after synchronizing from the repository a plain 'make' should be sufficient.
89Note, however, that when gnulib is updated, running './bootstrap' again
90might be needed.
91
92** First checkout
93
94Obviously, if you are reading these notes, you did manage to check out
95this package from the repository. For the record, you will find all the
96relevant information on:
97
98 http://savannah.gnu.org/git/?group=bison
99
100Bison uses Git submodules: subscriptions to other Git repositories.
101In particular it uses gnulib, the GNU portability library. To ask Git
102to perform the first checkout of the submodules, run
103
104 $ git submodule update --init
105
106Git submodule support is weak before versions 1.6 and later, you
107should probably upgrade Git if your version is older.
108
109The next step is to get other files needed to build, which are
110extracted from other source packages:
111
112 $ ./bootstrap
113
114And there you are! Just
115
116 $ ./configure
117 $ make
118 $ make check
119
120At this point, there should be no difference between your local copy,
121and the master copy:
122
123 $ git diff
124
125should output no difference.
126
127Enjoy!
128
129** Updating
130
131The use of submodules make things somewhat different because git does
132not support recursive operations: submodules must be taken care of
133explicitly by the user.
134
135*** Updating Bison
136
137If you pull a newer version of a branch, say via "git pull", you might
138import requests for updated submodules. A simple "git diff" will
139reveal if the current version of the submodule (i.e., the actual
140contents of the gnulib directory) and the current request from the
141subscriber (i.e., the reference of the version of gnulib that the
142Bison repository requests) differ. To upgrade the submodules (i.e.,
143to check out the version that is actually requested by the subscriber,
144run "git submodule update".
145
146 $ git pull
147 $ git submodule update
148
149*** Updating a submodule
150To update a submodule, say gnulib, do as follows:
151
152Get the most recent version of the master branch from git.
153
154 $ cd gnulib
155 $ git fetch
156 $ git checkout -b master --track origin/master
157
158Make sure Bison can live with that version of gnulib.
159
160 $ cd ..
161 $ ./bootstrap
162 $ make distcheck
163
164Register your changes.
165
166 $ git checkin ...
167
168For a suggestion of what gnulib commit might be stable enough for a
169formal release, see the ChangeLog in the latest gnulib snapshot at:
170
171 http://erislabs.net/ianb/projects/gnulib/
172
173The Autoconf files we use are currently:
174
175 m4/m4.m4
176 lib/m4sugar/m4sugar.m4
177 lib/m4sugar/foreach.m4
178
179These files don't change very often in Autoconf, so it should be
180relatively straight-forward to examine the differences in order to
181decide whether to update.
182
183* Test suite
184
185** make check
186Use liberally.
187
188** TESTSUITEFLAGS
189
190The default is for make check to run all tests sequentially. This can be
191very time consumming when checking repeatedly or on slower setups. This can
192be sped up in two ways:
193
194Using -j, in a make-like fashion, for example:
195 $ make check TESTSUITEFLAGS='-j8'
196
197Running only the tests of a certain category, as specified in the AT files
198with AT_KEYWORDS([[category]]). Categories include:
199 - c++, for c++ parsers
200 - deprec, for tests concerning deprecated constructs.
201 - glr, for glr parsers
202 - java, for java parsers
203 - report, for automaton dumps
204
205To run a specific set of tests, use -k (for "keyword"). For example:
206 $ make check TESTSUITEFLAGS='-k c++'
207
208Both can be combined.
209
210** Typical errors
211If the test suite shows failures such as the following one
212
213 .../bison/lib/getopt.h:196:8: error: redefinition of 'struct option'
214 /usr/include/getopt.h:54:8: error: previous definition of 'struct option'
215
216it probably means that some file was compiled without
217AT_DATA_SOURCE_PROLOGUE. This error is due to the fact that our -I options
218pick up gnulib's replacement headers, such as getopt.h, and this will go
219wrong if config.h was not included first.
220
221See tests/local.at for details.
222
223** make maintainer-check-valgrind
224This target uses valgrind both to check bison, and the generated parsers.
225
226This is not mature on Mac OS X. First, Valgrind does support the way bison
227calls m4, so Valgrind cannot be used to check bison on Mac OS X.
228
229Second, there are many errors that come from the platform itself, not from
230bison. build-aux/darwin11.4.0.valgrind addresses some of them.
231
232Third, valgrind issues warnings such as:
233
234 --99312:0:syswrap- WARNING: Ignoring sigreturn( ..., UC_RESET_ALT_STACK );
235
236which cause the test to fail uselessly. It is hard to ignore these errors
237with a major overhaul of the way instrumentation is performed in the test
238suite. So currently, do not try to run valgrind on Mac OS X.
239
240** Release checks
241Try to run the test suite with more severe conditions before a
242release:
243
244- Configure the package with --enable-gcc-warnings, so that one checks
245 that 1. Bison compiles cleanly, 2. the parsers it produces compile
246 cleanly too.
247
248- Maybe build with -DGNULIB_POSIXCHECK, which suggests gnulib modules
249 that can fix portability issues. See if you really want to pay
250 attention to its warnings; there's no need to obey blindly to it
251 (<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00057.html>).
252
253- Check with "make syntax-check" if there are issues diagnosed by
254 gnulib.
255
256- run "make maintainer-check" which:
257 - runs "valgrind -q bison" to run Bison under Valgrind.
258 - runs the parsers under Valgrind.
259 - runs the test suite with G++ as C compiler...
260
261- run "make maintainer-push-check", which runs "make maintainer-check"
262 while activating the push implementation and its pull interface wrappers
263 in many test cases that were originally written to exercise only the
264 pull implementation. This makes certain the push implementation can
265 perform every task the pull implementation can.
266
267- run "make maintainer-xml-check", which runs "make maintainer-check"
268 while checking Bison's XML automaton report for every working grammar
269 passed to Bison in the test suite. The check just diffs the output of
270 Bison's included XSLT style sheets with the output of --report=all and
271 --graph.
272
273- running "make maintainer-release-check" takes care of running
274 maintainer-check, maintainer-push-check and maintainer-xml-check.
275
276- Change tests/atlocal/CFLAGS to add your preferred options. For
277 instance, "-traditional" to check that the parsers are K&R. Note
278 that it does not make sense for glr.c, which should be ANSI, but
279 currently is actually GNU C, nor for lalr1.cc.
280
281- Test with a very recent version of GCC for both C and C++. Testing
282 with older versions that are still in use is nice too.
283
284
285* Release Procedure
286This section needs to be updated to take into account features from
287gnulib. In particular, be sure to read README-release.
288
289** Update the submodules. See above.
290
291** Update maintainer tools, such as Autoconf. See above.
292
293** Try to get the *.pot files to the Translation Project at least one
294week before a stable release, to give them time to translate them.
295Before generating the *.pot files, make sure that po/POTFILES.in and
296runtime-po/POTFILES.in list all files with translatable strings.
297This helps: grep -l '\<_(' *
298
299** Tests
300See above.
301
302** Update the foreign files
303Running "./bootstrap" in the top level should update them all for you.
304This covers PO files too. Sometimes a PO file contains problems that
305causes it to be rejected by recent Gettext releases; please report
306these to the Translation Project.
307
308** Update README
309Make sure the information in README is current. Most notably, make sure
310it recommends a version of GNU M4 that is compatible with the latest
311Bison sources.
312
313** Check copyright years.
314We update years in copyright statements throughout Bison once at the
315start of every year by running "make update-copyright". However, before
316a release, it's good to verify that it's actually been run. Besides the
317copyright statement for each Bison file, check the copyright statements
318that the skeletons insert into generated parsers, and check all
319occurrences of PACKAGE_COPYRIGHT_YEAR in configure.ac.
320
321** Update NEWS, commit and tag.
322See do-release-commit-and-tag in README-release. For a while, we used
323beta names such as "2.6_rc1". Now that we use gnulib in the release
324procedure, we must use "2.5.90", which has the additional benefit of
325being properly sorted in "git tag -l".
326
327** make alpha, beta, or stable
328See README-release.
329
330** Upload
331There are two ways to upload the tarballs to the GNU servers: using
332gnupload (from gnulib), or by hand. Obviously prefer the former. But
333in either case, be sure to read the following paragraph.
334
335*** Setup
336You need "gnupg".
337
338Make sure your public key has been uploaded at least to
339keys.gnupg.net. You can upload it with:
340
341 gpg --keyserver keys.gnupg.net --send-keys F125BDF3
342
343where F125BDF3 should be replaced with your key ID.
344
345*** Using gnupload
346You need "ncftp".
347
348At the end "make stable" (or alpha/beta) will display the procedure to
349run. Just copy and paste it in your shell.
350
351*** By hand
352
353The generic GNU upload procedure is at:
354
355 http://www.gnu.org/prep/maintain/maintain.html#Automated-FTP-Uploads
356
357Follow the instructions there to register your information so you're permitted
358to upload.
359
360Here's a brief reminder of how to roll the tarballs and upload them:
361
362*** make distcheck
363*** gpg -b bison-2.3b.tar.gz
364*** In a file named "bison-2.3b.tar.gz.directive", type:
365
366 version: 1.1
367 directory: bison
368 filename: bison-2.3b.tar.gz
369
370*** gpg --clearsign bison-2.3b.tar.gz.directive
371*** ftp ftp-upload.gnu.org # Log in as anonymous.
372*** cd /incoming/alpha # cd /incoming/ftp for full release.
373*** put bison-2.3b.tar.gz # This can take a while.
374*** put bison-2.3b.tar.gz.sig
375*** put bison-2.3b.tar.gz.directive.asc
376*** Repeat all these steps for bison-2.3b.tar.xz.
377
378** Update Bison manual on www.gnu.org.
379
380*** You need a non-anonymous checkout of the web pages directory.
381
382 $ cvs -d YOUR_USERID@cvs.savannah.gnu.org:/web/bison checkout bison
383
384*** Get familiar with the instructions for web page maintainers.
385http://www.gnu.org/server/standards/readme_index.html
386http://www.gnu.org/server/standards/README.software.html
387especially the note about symlinks.
388
389*** Build the web pages.
390Assuming BISON_CHECKOUT refers to a checkout of the Bison dir, and
391BISON_WWW_CHECKOUT refers to the web directory created above, do:
392
393 $ cd $BISON_CHECKOUT/doc
394 $ make stamp-vti
395 $ ../build-aux/gendocs.sh -o "$BISON_WWW_CHECKOUT/manual" \
396 bison "Bison - GNU parser generator"
397 $ cd $BISON_WWW_CHECKOUT
398
399Verify that the result looks sane.
400
401*** Commit the modified and the new files.
402
403*** Remove old files.
404Find the files which have not been overwritten (because they belonged to
405sections that have been removed or renamed):
406
407 $ cd manual/html_node
408 $ ls -lt
409
410Remove these files and commit their removal to CVS. For each of these
411files, add a line to the file .symlinks. This will ensure that
412hyperlinks to the removed files will redirect to the entire manual; this
413is better than a 404 error.
414
415There is a problem with 'index.html' being written twice (once for POSIX
416function 'index', once for the table of contents); you can ignore this
417issue.
418
419** Announce
420The "make stable" (or alpha/beta) command just created a template,
421$HOME/announce-bison-X.Y. Otherwise, to generate it, run:
422
423 make RELEASE_TYPE=alpha gpg_key_ID=F125BDF3 announcement
424
425where alpha can be replaced by beta or stable and F125BDF3 should be
426replaced with your key ID.
427
428Complete/fix the announcement file. The generated list of recipients
429(info-gnu@gnu.org, bug-bison@gnu.org, help-bison@gnu.org,
430bison-patches@gnu.org, and coordinator@translationproject.org) is
431appropriate for a stable release or a "serious beta". For any other
432release, drop at least info-gnu@gnu.org. For an example of how to
433fill out the rest of the template, search the mailing list archives
434for the most recent release announcement.
435
436For a stable release, send the same announcement on the comp.compilers
437newsgroup by sending email to compilers@iecc.com. Do not make any Cc as
438the moderator will throw away anything cross-posted or Cc'ed. It really
439needs to be a separate message.
440
441** Prepare NEWS
442So that developers don't accidentally add new items to the old NEWS
443entry, create a new empty entry in line 3 (without the two leading
444spaces):
445
446 * Noteworthy changes in release ?.? (????-??-??) [?]
447
448Push these changes.
449
450-----
451
452Copyright (C) 2002-2005, 2007-2015 Free Software Foundation, Inc.
453
454This file is part of GNU Bison.
455
456This program is free software: you can redistribute it and/or modify
457it under the terms of the GNU General Public License as published by
458the Free Software Foundation, either version 3 of the License, or
459(at your option) any later version.
460
461This program is distributed in the hope that it will be useful,
462but WITHOUT ANY WARRANTY; without even the implied warranty of
463MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
464GNU General Public License for more details.
465
466You should have received a copy of the GNU General Public License
467along with this program. If not, see <http://www.gnu.org/licenses/>.
468
469 LocalWords: Automake Autoconf Gettext Gzip Rsync Valgrind gnulib submodules
470 LocalWords: submodule init cd distcheck checkin ChangeLog valgrind sigreturn
471 LocalWords: UC gcc DGNULIB POSIXCHECK xml XSLT glr lalr README po runtime rc
472 LocalWords: gnupload gnupg gpg keyserver BDF ncftp filename clearsign cvs dir
473 LocalWords: symlinks vti html lt POSIX Cc'ed
474
475Local Variables:
476mode: outline
477fill-column: 76
478End: