1 Information for GNU Gnulib maintainers and contributors
2 *******************************************************
7 * We don't use topic branches. Changes are usually small enough that
8 they can be committed directly to the master branch, after appropriate
11 * We maintain stable branches, though, as described in the documentation:
12 https://www.gnu.org/software/gnulib/manual/html_node/Stable-Branches.html
13 When backporting a commit to a stable branch of the last year, be sure
14 to update the copyright year of each modified file (since we don't run
15 "make update-copyright" on the stable branches).
17 * We use a linear git history — no merges. To work in this setting, it's
18 recommended that you configure git with 'git config pull.rebase = true'.
20 * Before pushing a commit, it is highly recommended that you review it in
21 its entirety. The easiest ways to do so are
24 and then read the patch in an editor that has syntax-colouring of patch
29 * We update the ChangeLog by hand. The commit message is usually identical
30 to the ChangeLog entry, with the date and author line removed, with
31 the leading tabs removed, and with a blank line after the commit's
33 In order to work efficiently with ChangeLog files, it is recommended that
34 you configure git to use the git-merge-changelog driver; see the instructions
35 in the lib/git-merge-changelog.c file.
36 Note: This driver reasonably keeps the ChangeLog entries together; however,
37 it does not always keep them in the order you would desire. For example,
38 when you had prepared a commit, you try to "git push" it but that fails due
39 to someone else's commit that came earlier, what you need to do is:
41 2. Verify that your ChangeLog entry is still the top-most one.
42 3. If it is not, then edit ChangeLog to move it to the top, and
43 $ git commit --amend ChangeLog
47 * When you commit a contributor's patch, please
48 - add a reasonable ChangeLog entry in the usual style (meaningful
49 summary line and detailed change list),
50 - if the contribution is so small that it does not require a
51 copyright assignment (cf.
52 https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html )
54 Copyright-paperwork-exempt: Yes
55 - use the 'git commit' option --author="Contributor Name <email@address>"
61 In *.m4 files, use a notice like this:
62 dnl Copyright (C) YEARS Free Software Foundation, Inc.
63 dnl This file is free software; the Free Software Foundation
64 dnl gives unlimited permission to copy and/or distribute it,
65 dnl with or without modifications, as long as this notice is preserved.
67 In lib/, tests/, build-aux/ files, except those that are shared with glibc,
68 use the license notices from etc/license-notices/ . This avoids gratuitous
69 differences in wording, as well misunderstandings when a license notice
70 would say "This program ...".
76 When adding a module, add a unit test module as well. This is our best
77 chance to catch portability problems.
79 A unit test can have many sub-tests. Try to make the sub-tests independent
80 of each other, so that it becomes easy to disable some sub-tests by enclosing
81 them in #if 0 ... #endif.
83 The main() function's exit code meaning is:
85 - 77: SKIP; you should print the reason why the test is skipped.
86 - 99: ERROR, i.e. test framework error
87 - any other exit code < 126: FAIL
89 In tests that #include "macros.h" and use the ASSERT macro:
90 The main() function should, before it returns 0 (for PASS) or 77 (for SKIP)
91 test the value of test_exit_status and return that instead. So:
95 return test_exit_status;
97 return result; // where result can be 0 or 1
99 return (result ? result : test_exit_status);
101 fputs ("Skipping test: <reason>\n", stderr);
104 if (test_exit_status != EXIT_SUCCESS)
105 return test_exit_status;
106 fputs ("Skipping test: <reason>\n", stderr);
108 Only at the beginning of the main() function, when ASSERT has not yet been
109 invoked, we know that test_exit_status must be zero and can therefore write
110 fputs ("Skipping test: <reason>\n", stderr);
115 Maintaining high quality
116 ========================
118 It is a good idea to occasionally create a testdir of all of Gnulib:
119 $ rm -rf ../testdir-all; ./gnulib-tool --create-testdir --dir=../testdir-all --with-c++-tests --without-privileged-tests --single-configure `./all-modules`
120 and test this directory on various platforms:
121 - Linux/glibc systems,
122 - Linux/musl systems,
132 - and other platforms of your choice.
134 There is a continuous integration that regularly performs this testing
135 on a Linux/glibc system: https://gitlab.com/gnulib/gnulib-ci
136 But this will catch only the most blatant mistakes.
142 For packages that use Gnulib, we recommend to use the 'warnings' or
143 'manywarnings' module, as documented in
144 https://www.gnu.org/software/gnulib/manual/html_node/warnings.html
145 https://www.gnu.org/software/gnulib/manual/html_node/manywarnings.html
147 When building Gnulib testdirs, e.g. when preparing a Gnulib patch,
148 there are three possible approaches:
150 * The simplest approach, which warns about the most common mistakes, is to
151 use GCC's -Wall option, both for C and C++ compilation units. Just set
152 $ ./configure CPPFLAGS="-Wall"
154 You should generally fix all compiler warnings that you see from this
157 * If you are developing on a glibc system and have GCC version 13 binaries
158 available, here's a recipe that will find more mistakes, but is nearly
159 as easy to use. Here, different warning options are needed for C and
167 -Wdisabled-optimization
174 -Wmissing-include-dirs
180 -Wsuggest-final-methods
181 -Wsuggest-final-types
187 -Wunsafe-loop-optimizations
189 -Wvector-operation-performance
194 -Wformat-truncation=2
196 -Wunused-const-variable=2
197 -Wvla-larger-than=4031
199 -Wno-analyzer-allocation-size
200 -Wno-analyzer-fd-double-close
201 -Wno-analyzer-double-fclose
202 -Wno-analyzer-double-free
203 -Wno-analyzer-fd-leak
204 -Wno-analyzer-fd-use-after-close
205 -Wno-analyzer-fd-use-without-check
206 -Wno-analyzer-free-of-non-heap
207 -Wno-analyzer-malloc-leak
208 -Wno-analyzer-mismatching-deallocation
209 -Wno-analyzer-null-argument
210 -Wno-analyzer-null-dereference
211 -Wno-analyzer-out-of-bounds
212 -Wno-analyzer-possible-null-argument
213 -Wno-analyzer-possible-null-dereference
214 -Wno-analyzer-use-after-free
215 -Wno-analyzer-use-of-pointer-in-stale-stack-frame
216 -Wno-analyzer-use-of-uninitialized-value
217 -Wno-analyzer-va-arg-type-mismatch
218 -Wno-attribute-warning
221 -Wno-dangling-pointer
223 -Wno-implicit-fallthrough
224 -Wno-maybe-uninitialized
225 -Wno-missing-field-initializers
230 -Wno-unused-parameter
231 ' | tr -d '\n' | sed -e 's/ */ /g'`
232 $ WARN_CFLAGS_GCC13="$WARN_GCC13 -Wnested-externs -Wshadow=local -Wno-discarded-qualifiers"
233 $ WARN_CXXFLAGS_GCC13="$WARN_GCC13 -Wno-cpp"
234 $ ./configure CFLAGS="-O2 -g $WARN_CFLAGS_GCC13" CXXFLAGS="-O2 -g $WARN_CXXFLAGS_GCC13"
236 You should generally fix all compiler warnings that you see from this
237 approach, or report when this approach produced a pointless warning
238 (so that we can fix the value of WARN_GCC13 above).
240 * If you are developing on a glibc system and have GCC version 13 binaries
241 available: Here's a recipe that will find even more mistakes, but it
242 requires that you are willing to filter out and ignore pointless warnings.
249 -Wdisabled-optimization
256 -Wmissing-include-dirs
263 -Wsuggest-attribute=format
264 -Wsuggest-final-methods
265 -Wsuggest-final-types
271 -Wunsafe-loop-optimizations
273 -Wvector-operation-performance
279 -Wformat-truncation=2
280 -Wimplicit-fallthrough=5
282 -Wunused-const-variable=2
283 -Wvla-larger-than=4031
285 -Wno-analyzer-double-fclose
286 -Wno-analyzer-double-free
287 -Wno-analyzer-free-of-non-heap
288 -Wno-analyzer-malloc-leak
289 -Wno-analyzer-null-argument
290 -Wno-analyzer-null-dereference
291 -Wno-analyzer-use-after-free
292 -Wno-attribute-warning
295 -Wno-format-nonliteral
298 -Wno-unused-parameter
299 ' | tr -d '\n' | sed -e 's/ */ /g'`
300 $ WARN_CFLAGS_GCC13="$WARN_GCC13 -Wnested-externs -Wshadow=local"
301 $ WARN_CXXFLAGS_GCC13="$WARN_GCC13 -Wno-cpp"
302 $ ./configure CFLAGS="-O2 -g $WARN_CFLAGS_GCC13" CXXFLAGS="-O2 -g $WARN_CXXFLAGS_GCC13"
304 With this approach, use your own judgement whether to fix warnings
305 arising from your new code or not.
306 Do *not* submit patches to silence warnings from existing code:
307 - For these warnings, often the cure will be worse than the disease.
308 - Some of the warnings are false positives. Rather than silencing
309 these warnings, we prefer to report them in the GCC bug tracker
310 and wait until they are fixed in a future GCC release.
312 Similarly, for clang version 16 you can use the following recipe, that uses
313 selected warning options from
314 https://releases.llvm.org/16.0.0/tools/clang/docs/DiagnosticsReference.html :
315 $ WARN_CLANG16=`echo '
317 -Wanon-enum-enum-conversion
318 -Warc-repeated-use-of-weak
319 -Warray-bounds-pointer-arithmetic
324 -Wbitfield-enum-conversion
325 -Wbitwise-op-parentheses
333 -Wcalled-once-parameter
338 -Wcomplex-component-init
339 -Wcompound-token-split
342 -Wcstring-format-directive
345 -Wdelimited-escape-sequence-extension
347 -Wdeprecated-dynamic-exception-spec
348 -Wdeprecated-implementations
349 -Wdeprecated-this-capture
350 -Wdeprecated-writable-strings
353 -Wdocumentation-deprecated-sync
355 -Wdocumentation-pedantic
356 -Wdocumentation-unknown-command
357 -Wdollar-in-identifier-extension
358 -Wduplicate-decl-specifier
360 -Wduplicate-method-arg
361 -Wduplicate-method-match
362 -Wdynamic-exception-spec
365 -Wempty-translation-unit
366 -Wenum-compare-conditional
368 -Wenum-enum-conversion
369 -Wenum-float-conversion
370 -Wexit-time-destructors
371 -Wexpansion-to-defined
372 -Wexplicit-ownership-type
375 -Wfixed-enum-extension
376 -Wflexible-array-extensions
377 -Wfloat-overflow-conversion
378 -Wfloat-zero-conversion
382 -Wformat-type-confusion
384 -Wfour-char-constants
387 -Wfuture-attribute-extensions
390 -Wgnu-anonymous-struct
393 -Wgnu-complex-integer
394 -Wgnu-compound-literal-initializer
395 -Wgnu-conditional-omitted-operand
397 -Wgnu-empty-initializer
399 -Wgnu-flexible-array-initializer
400 -Wgnu-flexible-array-union-member
401 -Wgnu-folding-constant
402 -Wgnu-imaginary-constant
405 -Wgnu-null-pointer-arithmetic
406 -Wgnu-offsetof-extensions
408 -Wgnu-redeclared-enum
409 -Wgnu-statement-expression
410 -Wgnu-statement-expression-from-macro-expansion
412 -Wgnu-zero-line-directive
413 -Wgnu-zero-variadic-macro-arguments
415 -Widiomatic-parentheses
418 -Wimplicit-fallthrough
419 -Wimplicit-fallthrough-per-function
420 -Wimplicit-function-declaration
422 -Wimplicit-retain-self
423 -Wimport-preprocessor-directive-pedantic
425 -Winconsistent-missing-destructor-override
427 -Wint-in-bool-context
428 -Winvalid-or-nonexistent-directory
431 -Wlanguage-extension-token
432 -Wlocal-type-template-args
433 -Wlogical-op-parentheses
442 -Wmicrosoft-comment-paste
443 -Wmicrosoft-cpp-macro
444 -Wmicrosoft-end-of-file
445 -Wmicrosoft-enum-value
446 -Wmicrosoft-exception-spec
447 -Wmicrosoft-fixed-enum
448 -Wmicrosoft-flexible-array
449 -Wmicrosoft-redeclare-static
450 -Wmisleading-indentation
453 -Wmissing-method-return-type
459 -Wnon-modular-include-in-framework-module
460 -Wnon-modular-include-in-module
462 -Wnonportable-system-include-path
463 -Wnull-pointer-arithmetic
464 -Wnull-pointer-subtraction
465 -Wnullability-extension
466 -Wnullable-to-nonnull-conversion
471 -Woverriding-method-mismatch
476 -Wpedantic-core-features
479 -Wpoison-system-directories
481 -Wpragma-pack-suspicious-include
484 -Wpre-openmp-51-compat
485 -Wprofile-instr-missing
486 -Wquoted-include-in-framework-header
487 -Wrange-loop-analysis
488 -Wrange-loop-bind-reference
489 -Wrange-loop-construct
490 -Wreceiver-forward-class
495 -Wreserved-user-defined-literal
496 -Wretained-language-linkage
498 -Wselector-type-mismatch
500 -Wself-assign-overloaded
502 -Wsemicolon-before-method-body
505 -Wshadow-field-in-constructor
506 -Wshadow-field-in-constructor-modified
507 -Wshadow-uncaptured-local
508 -Wshift-sign-overflow
509 -Wsigned-enum-bitfield
510 -Wsometimes-uninitialized
514 -Wstrict-potentially-direct-selector
515 -Wstrict-selector-match
516 -Wstring-concatenation
518 -Wsuggest-destructor-override
520 -Wsuper-class-method-mismatch
521 -Wtautological-bitwise-compare
522 -Wtautological-compare
523 -Wtautological-constant-in-range-compare
524 -Wtautological-overlap-compare
525 -Wtautological-type-limit-compare
526 -Wtautological-unsigned-char-zero-compare
527 -Wtautological-unsigned-enum-zero-compare
528 -Wtautological-unsigned-zero-compare
529 -Wtautological-value-range-compare
531 -Wthread-safety-analysis
532 -Wthread-safety-attributes
534 -Wthread-safety-negative
535 -Wthread-safety-precise
536 -Wthread-safety-reference
537 -Wthread-safety-verbose
540 -Wundeclared-selector
542 -Wundefined-func-template
543 -Wundefined-internal-type
544 -Wundefined-reinterpret-cast
545 -Wunguarded-availability
547 -Wuninitialized-const-reference
549 -Wunnamed-type-template-args
550 -Wunneeded-internal-declaration
551 -Wunneeded-member-function
552 -Wunreachable-code-fallthrough
553 -Wunreachable-code-loop-increment
554 -Wunsupported-dll-base-class-template
556 -Wunused-but-set-parameter
557 -Wunused-but-set-variable
558 -Wunused-const-variable
559 -Wunused-exception-parameter
562 -Wunused-lambda-capture
563 -Wunused-local-typedef
564 -Wunused-member-function
565 -Wunused-private-field
566 -Wunused-property-ivar
571 -Wweak-template-vtables
574 -Wno-bitwise-instead-of-logical
576 -Wno-cast-function-type-strict
577 -Wno-float-conversion
578 -Wno-format-nonliteral
579 -Wno-gnu-include-next
580 -Wno-implicit-float-conversion
581 -Wno-implicit-int-conversion
582 -Wno-implicit-int-float-conversion
583 -Wno-include-next-absolute-path
584 -Wno-missing-field-initializers
585 -Wno-reserved-macro-identifier
587 -Wno-shorten-64-to-32
590 -Wno-strict-prototypes
592 -Wno-unused-parameter
593 -Wno-tautological-constant-out-of-range-compare
594 -Wno-tautological-type-limit-compare
595 -Wno-tautological-unsigned-zero-compare
596 -Wno-tautological-value-range-compare
597 -Wno-unused-command-line-argument
598 -Wno-user-defined-warnings
599 ' | tr -d '\n' | sed -e 's/ */ /g'`
600 $ ./configure CFLAGS="-O2 -g $WARN_CLANG16" CXXFLAGS="-O2 -g $WARN_CLANG16"
602 Again, use your own judgement to determine whether to fix or ignore a
606 Information for gnulib-tool maintenance
607 ***************************************
609 Running the unit tests
610 ======================
612 The unit tests of gnulib-tool reside in the maint-tools repository, that is a
613 satellite repository of the main gnulib repository. Instructions how to obtain
614 it are in https://savannah.gnu.org/git/?group=gnulib .
616 To run the unit tests of gnulib-tool.sh:
617 $ cd maint-tools/gnulib-tool-tests/
618 $ GNULIB_TOOL_IMPL=sh ./test-all.sh
620 To run the unit tests of gnulib-tool.py:
621 $ cd maint-tools/gnulib-tool-tests/
622 $ GNULIB_TOOL_IMPL=py ./test-all.sh
624 It is *mandatory* that you run the test suite before pushing any change to
625 gnulib-tool.sh or gnulib-tool.py! If you fail to do so, and your change contains
626 a bug, it will start to affect users immediately.
629 Debugging the Python implementation of gnulib-tool
630 ==================================================
632 With Eclipse and PyDev as IDE
633 -----------------------------
635 * Download and configuration:
636 - Eclipse IDE from https://www.eclipse.org/downloads/packages/
637 (either the build for Java or for C/C++ should work fine;
638 either use the Eclipse Installer program at the top of the page,
639 or one of the individual download links below).
640 - PyDev from https://www.pydev.org/download.html
641 section "Install as Plugin".
642 (Don't use LiClipse, since the license costs money.)
643 - Follow https://www.pydev.org/manual_101_install.html,
644 replacing http://www.pydev.org/updates
645 with https://www.pydev.org/updates
646 - Once installed, restart the IDE.
647 - Window > Preferences > PyDev > Interpreters > Python Interpreter:
648 New > path: /usr/bin/python3
649 - Window > Preferences > PyDev > Editor > Code Analysis:
650 Others > Redefinition of builtin symbols: Ignore
653 Let GNULIB_DIR be my gnulib checkout.
654 - File > New > Project... > PyDev > PyDev Project. Call it 'gnulib-tool'.
655 Note that this is a project inside the Eclipse workspace, so far
656 unrelated to the GNULIB_DIR.
657 - Popup menu > New > Link to Existing Source
661 * Create a run configuration:
662 - Run > Run Configurations... > Python Run
663 Popup menu > New configuration
665 Main > Project: gnulib-tool
666 Main > Main Module: ${workspace_loc:gnulib-tool/gnulib/.gnulib-tool.py}
667 Arguments > Program arguments: --help
668 - Test it: Run this configuration.
670 * Create a debug configuration:
671 - Run > Debug Configurations... > gnulib-tool.py
672 Popup menu > Duplicate
673 - In the duplicate, set
674 Arguments > Working directory: /tmp/oath-toolkit/lib
675 Arguments > Program arguments: --add-import
679 - On the left-hand border of this editor, do "Add breakpoint".
680 - Run > Debug Configurations... > pick the duplicate. Press Debug.
683 Maintaining high quality
684 ========================
686 There is a continuous integration of gnulib-tool.py that runs the unit tests,
687 at https://gitlab.com/gnulib/gnulib-tool-ci/ .