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 update the ChangeLog by hand. The commit message is usually identical
18 to the ChangeLog entry, with the date and author line removed, with
19 the leading tabs removed, and with a blank line after the commit's
22 * When you commit a contributor's patch, please
23 - add a reasonable ChangeLog entry in the usual style (meaningful
24 summary line and detailed change list),
25 - if the contribution is so small that it does not require a
26 copyright assignment (cf.
27 https://www.gnu.org/prep/maintain/html_node/Legally-Significant.html )
29 Copyright-paperwork-exempt: Yes
30 - use the 'git commit' option --author="Contributor Name <email@address>"
35 In *.m4 files, use a notice like this:
36 dnl Copyright (C) YEARS Free Software Foundation, Inc.
37 dnl This file is free software; the Free Software Foundation
38 dnl gives unlimited permission to copy and/or distribute it,
39 dnl with or without modifications, as long as this notice is preserved.
41 In lib/, tests/, build-aux/ files, except those that are shared with glibc,
42 use the license notices from etc/license-notices/ . This avoids gratuitous
43 differences in wording, as well misunderstandings when a license notice
44 would say "This program ...".
49 When adding a module, add a unit test module as well. This is our best
50 chance to catch portability problems.
55 For packages that use Gnulib, we recommend to use the 'warnings' or
56 'manywarnings' module, as documented in
57 https://www.gnu.org/software/gnulib/manual/html_node/warnings.html
58 https://www.gnu.org/software/gnulib/manual/html_node/manywarnings.html
60 When building Gnulib testdirs, e.g. when preparing a Gnulib patch,
61 there are three possible approaches:
63 * The simplest approach, which warns about the most common mistakes, is to
64 use GCC's -Wall option, both for C and C++ compilation units. Just set
65 $ ./configure CPPFLAGS="-Wall"
67 You should generally fix all compiler warnings that you see from this
70 * If you are developing on a glibc system and have GCC version 13 binaries
71 available, here's a recipe that will find more mistakes, but is nearly
72 as easy to use. Here, different warning options are needed for C and
80 -Wdisabled-optimization
87 -Wmissing-include-dirs
93 -Wsuggest-final-methods
100 -Wunsafe-loop-optimizations
102 -Wvector-operation-performance
107 -Wformat-truncation=2
109 -Wunused-const-variable=2
110 -Wvla-larger-than=4031
112 -Wno-analyzer-allocation-size
113 -Wno-analyzer-fd-double-close
114 -Wno-analyzer-double-fclose
115 -Wno-analyzer-double-free
116 -Wno-analyzer-fd-leak
117 -Wno-analyzer-fd-use-after-close
118 -Wno-analyzer-fd-use-without-check
119 -Wno-analyzer-free-of-non-heap
120 -Wno-analyzer-malloc-leak
121 -Wno-analyzer-mismatching-deallocation
122 -Wno-analyzer-null-argument
123 -Wno-analyzer-null-dereference
124 -Wno-analyzer-out-of-bounds
125 -Wno-analyzer-possible-null-argument
126 -Wno-analyzer-possible-null-dereference
127 -Wno-analyzer-use-after-free
128 -Wno-analyzer-use-of-pointer-in-stale-stack-frame
129 -Wno-analyzer-use-of-uninitialized-value
130 -Wno-analyzer-va-arg-type-mismatch
131 -Wno-attribute-warning
134 -Wno-dangling-pointer
136 -Wno-implicit-fallthrough
137 -Wno-maybe-uninitialized
138 -Wno-missing-field-initializers
143 -Wno-unused-parameter
144 ' | tr -d '\n' | sed -e 's/ */ /g'`
145 $ WARN_CFLAGS_GCC13="$WARN_GCC13 -Wnested-externs -Wshadow=local -Wno-discarded-qualifiers"
146 $ WARN_CXXFLAGS_GCC13="$WARN_GCC13 -Wno-cpp"
147 $ ./configure CFLAGS="-O2 -g $WARN_CFLAGS_GCC13" CXXFLAGS="-O2 -g $WARN_CXXFLAGS_GCC13"
149 You should generally fix all compiler warnings that you see from this
150 approach, or report when this approach produced a pointless warning
151 (so that we can fix the value of WARN_GCC13 above).
153 * If you are developing on a glibc system and have GCC version 13 binaries
154 available: Here's a recipe that will find even more mistakes, but it
155 requires that you are willing to filter out and ignore pointless warnings.
162 -Wdisabled-optimization
169 -Wmissing-include-dirs
176 -Wsuggest-attribute=format
177 -Wsuggest-final-methods
178 -Wsuggest-final-types
184 -Wunsafe-loop-optimizations
186 -Wvector-operation-performance
192 -Wformat-truncation=2
193 -Wimplicit-fallthrough=5
195 -Wunused-const-variable=2
196 -Wvla-larger-than=4031
198 -Wno-analyzer-double-fclose
199 -Wno-analyzer-double-free
200 -Wno-analyzer-free-of-non-heap
201 -Wno-analyzer-malloc-leak
202 -Wno-analyzer-null-argument
203 -Wno-analyzer-null-dereference
204 -Wno-analyzer-use-after-free
205 -Wno-attribute-warning
208 -Wno-format-nonliteral
211 -Wno-unused-parameter
212 ' | tr -d '\n' | sed -e 's/ */ /g'`
213 $ WARN_CFLAGS_GCC13="$WARN_GCC13 -Wnested-externs -Wshadow=local"
214 $ WARN_CXXFLAGS_GCC13="$WARN_GCC13 -Wno-cpp"
215 $ ./configure CFLAGS="-O2 -g $WARN_CFLAGS_GCC13" CXXFLAGS="-O2 -g $WARN_CXXFLAGS_GCC13"
217 With this approach, use your own judgement whether to fix warnings
218 arising from your new code or not.
219 Do *not* submit patches to silence warnings from existing code:
220 - For these warnings, often the cure will be worse than the disease.
221 - Some of the warnings are false positives. Rather than silencing
222 these warnings, we prefer to report them in the GCC bug tracker
223 and wait until they are fixed in a future GCC release.
225 Similarly, for clang version 16 you can use the following recipe, that uses
226 selected warning options from
227 https://releases.llvm.org/16.0.0/tools/clang/docs/DiagnosticsReference.html :
228 $ WARN_CLANG16=`echo '
230 -Wanon-enum-enum-conversion
231 -Warc-repeated-use-of-weak
232 -Warray-bounds-pointer-arithmetic
237 -Wbitfield-enum-conversion
238 -Wbitwise-op-parentheses
246 -Wcalled-once-parameter
251 -Wcomplex-component-init
252 -Wcompound-token-split
255 -Wcstring-format-directive
258 -Wdelimited-escape-sequence-extension
260 -Wdeprecated-dynamic-exception-spec
261 -Wdeprecated-implementations
262 -Wdeprecated-this-capture
263 -Wdeprecated-writable-strings
266 -Wdocumentation-deprecated-sync
268 -Wdocumentation-pedantic
269 -Wdocumentation-unknown-command
270 -Wdollar-in-identifier-extension
271 -Wduplicate-decl-specifier
273 -Wduplicate-method-arg
274 -Wduplicate-method-match
275 -Wdynamic-exception-spec
278 -Wempty-translation-unit
279 -Wenum-compare-conditional
281 -Wenum-enum-conversion
282 -Wenum-float-conversion
283 -Wexit-time-destructors
284 -Wexpansion-to-defined
285 -Wexplicit-ownership-type
288 -Wfixed-enum-extension
289 -Wflexible-array-extensions
290 -Wfloat-overflow-conversion
291 -Wfloat-zero-conversion
295 -Wformat-type-confusion
297 -Wfour-char-constants
300 -Wfuture-attribute-extensions
303 -Wgnu-anonymous-struct
306 -Wgnu-complex-integer
307 -Wgnu-compound-literal-initializer
308 -Wgnu-conditional-omitted-operand
310 -Wgnu-empty-initializer
312 -Wgnu-flexible-array-initializer
313 -Wgnu-flexible-array-union-member
314 -Wgnu-folding-constant
315 -Wgnu-imaginary-constant
318 -Wgnu-null-pointer-arithmetic
319 -Wgnu-offsetof-extensions
321 -Wgnu-redeclared-enum
322 -Wgnu-statement-expression
323 -Wgnu-statement-expression-from-macro-expansion
325 -Wgnu-zero-line-directive
326 -Wgnu-zero-variadic-macro-arguments
328 -Widiomatic-parentheses
331 -Wimplicit-fallthrough
332 -Wimplicit-fallthrough-per-function
333 -Wimplicit-function-declaration
335 -Wimplicit-retain-self
336 -Wimport-preprocessor-directive-pedantic
338 -Winconsistent-missing-destructor-override
340 -Wint-in-bool-context
341 -Winvalid-or-nonexistent-directory
344 -Wlanguage-extension-token
345 -Wlocal-type-template-args
346 -Wlogical-op-parentheses
355 -Wmicrosoft-comment-paste
356 -Wmicrosoft-cpp-macro
357 -Wmicrosoft-end-of-file
358 -Wmicrosoft-enum-value
359 -Wmicrosoft-exception-spec
360 -Wmicrosoft-fixed-enum
361 -Wmicrosoft-flexible-array
362 -Wmicrosoft-redeclare-static
363 -Wmisleading-indentation
366 -Wmissing-method-return-type
372 -Wnon-modular-include-in-framework-module
373 -Wnon-modular-include-in-module
375 -Wnonportable-system-include-path
376 -Wnull-pointer-arithmetic
377 -Wnull-pointer-subtraction
378 -Wnullability-extension
379 -Wnullable-to-nonnull-conversion
384 -Woverriding-method-mismatch
389 -Wpedantic-core-features
392 -Wpoison-system-directories
394 -Wpragma-pack-suspicious-include
397 -Wpre-openmp-51-compat
398 -Wprofile-instr-missing
399 -Wquoted-include-in-framework-header
400 -Wrange-loop-analysis
401 -Wrange-loop-bind-reference
402 -Wrange-loop-construct
403 -Wreceiver-forward-class
408 -Wreserved-user-defined-literal
409 -Wretained-language-linkage
411 -Wselector-type-mismatch
413 -Wself-assign-overloaded
415 -Wsemicolon-before-method-body
418 -Wshadow-field-in-constructor
419 -Wshadow-field-in-constructor-modified
420 -Wshadow-uncaptured-local
421 -Wshift-sign-overflow
422 -Wsigned-enum-bitfield
423 -Wsometimes-uninitialized
427 -Wstrict-potentially-direct-selector
428 -Wstrict-selector-match
429 -Wstring-concatenation
431 -Wsuggest-destructor-override
433 -Wsuper-class-method-mismatch
434 -Wtautological-bitwise-compare
435 -Wtautological-compare
436 -Wtautological-constant-in-range-compare
437 -Wtautological-overlap-compare
438 -Wtautological-type-limit-compare
439 -Wtautological-unsigned-char-zero-compare
440 -Wtautological-unsigned-enum-zero-compare
441 -Wtautological-unsigned-zero-compare
442 -Wtautological-value-range-compare
444 -Wthread-safety-analysis
445 -Wthread-safety-attributes
447 -Wthread-safety-negative
448 -Wthread-safety-precise
449 -Wthread-safety-reference
450 -Wthread-safety-verbose
453 -Wundeclared-selector
455 -Wundefined-func-template
456 -Wundefined-internal-type
457 -Wundefined-reinterpret-cast
458 -Wunguarded-availability
460 -Wuninitialized-const-reference
462 -Wunnamed-type-template-args
463 -Wunneeded-internal-declaration
464 -Wunneeded-member-function
465 -Wunreachable-code-fallthrough
466 -Wunreachable-code-loop-increment
467 -Wunsupported-dll-base-class-template
469 -Wunused-but-set-parameter
470 -Wunused-but-set-variable
471 -Wunused-const-variable
472 -Wunused-exception-parameter
475 -Wunused-lambda-capture
476 -Wunused-local-typedef
477 -Wunused-member-function
478 -Wunused-private-field
479 -Wunused-property-ivar
484 -Wweak-template-vtables
487 -Wno-bitwise-instead-of-logical
489 -Wno-cast-function-type-strict
490 -Wno-float-conversion
491 -Wno-format-nonliteral
492 -Wno-gnu-include-next
493 -Wno-implicit-float-conversion
494 -Wno-implicit-int-conversion
495 -Wno-implicit-int-float-conversion
496 -Wno-include-next-absolute-path
497 -Wno-missing-field-initializers
498 -Wno-reserved-macro-identifier
500 -Wno-shorten-64-to-32
503 -Wno-strict-prototypes
505 -Wno-unused-parameter
506 -Wno-tautological-constant-out-of-range-compare
507 -Wno-tautological-type-limit-compare
508 -Wno-tautological-unsigned-zero-compare
509 -Wno-tautological-value-range-compare
510 -Wno-unused-command-line-argument
511 -Wno-user-defined-warnings
512 ' | tr -d '\n' | sed -e 's/ */ /g'`
513 $ ./configure CFLAGS="-O2 -g $WARN_CLANG16" CXXFLAGS="-O2 -g $WARN_CLANG16"
515 Again, use your own judgement to determine whether to fix or ignore a