git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/3] Makefile: untangle DEVELOPER and -Werror

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 31, 2018, 16:40 UTC
Message-ID
<20180331164009.2264-1-avarab@gmail.com>
In-Reply-To
<20180329150322.10722-1-pclouds@gmail.com>

Change the DEVELOPER flag, and the newly added EAGER_DEVELOPER flag which (approximately) enables -Wextra so that any combination of them and -Werror can be set.

I've long wanted to use DEVELOPER=1 in my production builds, but on some old systems I still get warnings, and thus the build would fail. However if the build/tests fail for some other reason, it would still be useful to scroll up and see what the relevant code is warning about.

This change allows for that. Now setting DEVELOPER will set -Werror as before, but if DEVELOPER_NONFATAL is set you'll get the same warnings, but without -Werror.

I've renamed the newly added EAGER_DEVELOPER flag to DEVELOPER_EXTRA. The reason is that it approximately turns on -Wextra, and it'll be more consistent to add e.g. DEVELOPER_PEDANTIC later than inventing some new name of our own (VERY_EAGER_DEVELOPER?).

The DEVELOPER_EXTRA flag implicitly means DEVELOPER_NONFATAL, but just so that this change doesn't introduce yet another arbitrary limitation it's possible to combine it with DEVELOPER_FATAL, which will turn on -Werror for it as well.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

I really like where this is going, but as noted I think this on top would be even better.

 Makefile       | 17 +++++++++++------
 config.mak.dev | 10 ++++++++--
 2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index e4f04ce1cb..641461a569 100644
--- a/Makefile
+++ b/Makefile
@@ -432,11 +432,16 @@ all::
 # When cross-compiling, define HOST_CPU as the canonical name of the CPU on
 # which the built Git will run (for instance "x86_64").
 #
-# Define DEVELOPER to enable more compiler warnings. Compiler version
-# and faimily are auto detected, but could be overridden by defining
-# COMPILER_FEATURES (see config.mak.dev).
-# Define EAGER_DEVELOPER keeps compiler warnings non-fatal, but no warning
-# class is suppressed anymore.
+# Define DEVELOPER to enable more compiler warnings. We'll also enable
+# -Werror unless DEVELOPER_NONFATAL is defined. To enable even more
+# pedantic warnings that'll flag some potential existing issues in the
+# codebase turn on DEVELOPER_EXTRA, which implicitly sets DEVELOPER as
+# well, This is -Wextra with a whitelist of disabled warnings. Unless
+# DEVELOPER_NONFATAL is set DEVELOPER_EXTRA will turn it on
+# implicitly, so if you for some reason want both DEVELOPER and
+# DEVELOPER_EXTRA with fatal warnings, you need to set
+# DEVELOPER_FATAL=1 to force -Werror. See config.mak.dev for how this
+# all works.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1043,7 +1048,7 @@ include config.mak.uname
 -include config.mak.autogen
 -include config.mak
 
-ifdef EAGER_DEVELOPER
+ifdef DEVELOPER_EXTRA
 DEVELOPER = Yes
 endif
 ifdef DEVELOPER
diff --git a/config.mak.dev b/config.mak.dev
index 13883410b3..40f3365729 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -1,6 +1,12 @@
-ifndef EAGER_DEVELOPER
+ifndef DEVELOPER_NONFATAL
+ifndef DEVELOPER_EXTRA
 CFLAGS += -Werror
 endif
+endif
+ifdef DEVELOPER_FATAL
+CFLAGS += -Werror
+endif
+
 CFLAGS += -Wdeclaration-after-statement
 CFLAGS += -Wno-format-zero-length
 CFLAGS += -Wold-style-definition
@@ -23,7 +29,7 @@ CFLAGS += -Wextra
 # if a function is public, there should be a prototype and the right
 # header file should be included. If not, it should be static.
 CFLAGS += -Wmissing-prototypes
-ifndef EAGER_DEVELOPER
+ifndef DEVELOPER_EXTRA
 # These are disabled because we have these all over the place.
 CFLAGS += -Wno-empty-body
 CFLAGS += -Wno-missing-field-initializers
-- 
2.17.0.rc1.321.gba9d0f2565
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 32 of 47 in “travis-ci: enable more warnings on travis linux-gcc job”
  1. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 3, 2018
  2. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 16, 2018
  3. Jeff KingMar 16, 2018
  4. Duy NguyenMar 17, 2018
  5. Lars SchneiderMar 17, 2018
  6. Duy NguyenMar 17, 2018
  7. Jeff KingMar 17, 2018
  8. Jeff KingMar 17, 2018
  9. Junio C HamanoMar 17, 2018
  10. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 18, 2018
  11. Eric SunshineMar 18, 2018
  12. Duy NguyenMar 18, 2018
  13. Jeff KingMar 18, 2018
  14. Eric SunshineMar 18, 2018
  15. Jeff KingMar 18, 2018
  16. Eric SunshineMar 18, 2018
  17. Jeff KingMar 18, 2018
  18. Duy NguyenMar 18, 2018
  19. Duy NguyenMar 18, 2018
  20. Ramsay JonesMar 18, 2018
  21. Duy NguyenMar 19, 2018
  22. Jeff KingMar 20, 2018
  23. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 24, 2018
  24. Eric SunshineMar 25, 2018
  25. Junio C HamanoMar 26, 2018
  26. Duy NguyenMar 27, 2018
  27. Junio C HamanoMar 27, 2018
  28. 0/3 Enable more compiler warnings for devsNguyễn Thái Ngọc Duy, Mar 29, 2018
  29. 3/3 Makefile: add EAGER_DEVELOPER modeNguyễn Thái Ngọc Duy, Mar 29, 2018
  30. 2/3 Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 29, 2018
  31. 1/3 connect.c: mark die_initial_contact() NORETURNNguyễn Thái Ngọc Duy, Mar 29, 2018
  32. 4/3 Makefile: untangle DEVELOPER and -WerrorÆvar Arnfjörð Bjarmason, Mar 31, 2018
  33. Duy NguyenMar 31, 2018
  34. Ævar Arnfjörð BjarmasonApr 3, 2018
  35. Duy NguyenApr 3, 2018
  36. Jeff KingApr 6, 2018
  37. Duy NguyenApr 7, 2018
  38. Ævar Arnfjörð BjarmasonApr 7, 2018
  39. Duy NguyenApr 7, 2018
  40. Ævar Arnfjörð BjarmasonApr 7, 2018
  41. 0/4 Make DEVELOPER more more flexible with DEVOPTSÆvar Arnfjörð Bjarmason, Apr 14, 2018
  42. 1/4 connect.c: mark die_initial_contact() NORETURNÆvar Arnfjörð Bjarmason, Apr 14, 2018
  43. 2/4 Makefile: detect compiler and enable more warnings in DEVELOPER=1Ævar Arnfjörð Bjarmason, Apr 14, 2018
  44. 3/4 Makefile: add a DEVOPTS to suppress -Werror under DEVELOPERÆvar Arnfjörð Bjarmason, Apr 14, 2018
  45. 4/4 Makefile: add a DEVOPTS to get all of -WextraÆvar Arnfjörð Bjarmason, Apr 14, 2018
  46. Junio C HamanoApr 16, 2018
  47. Jeff KingMar 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.