From fc27ed9f180179c68cff081241a2ba212dad5623 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 11 Apr 2024 15:08:14 +0200 Subject: [PATCH] BUILD: makefile: add FAILFAST to select the -Wfatal-errors behavior -Wfatal-errors is set by default and is not supported on older compilers. Since it's part of all the automatically detected flags, it's painful to remove when needed. Also it's a matter of taste, some developers might prefer to get a long list of all errors at once, others prefer that the build stops immediately after the root cause. The default is now back to no -Wfatal-errors, and when FAILFAST is set to any non-empty non-zero value, -Wfatal-errors is added: $ make TARGET=linux-glibc USE_OPENSSL=0 USE_QUIC=1 FAILFAST=0 2>&1 | wc 132 536 6111 $ make TARGET=linux-glibc USE_OPENSSL=0 USE_QUIC=1 FAILFAST=1 2>&1 | wc 8 39 362 --- INSTALL | 5 ++++- Makefile | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/INSTALL b/INSTALL index e10822d23..1a1da4d15 100644 --- a/INSTALL +++ b/INSTALL @@ -665,7 +665,10 @@ way to get a usable core when you need one. Otherwise, you can set DEBUG to If the ERR variable is set to any non-empty value other than "0", then -Werror will be added to the compiler so that any build warning will trigger an error. This is the recommended way to build when developing, and it is expected that -contributed patches were tested with ERR=1. +contributed patches were tested with ERR=1. Similarly, for developers, another +variable, FAILFAST enables -Wfatal-errors when set to non-empty except 0, and +makes the compiler stop at the first error instead of scrolling pages. It's +essentially a matter of taste. The DEBUG variable is used to extend the CFLAGS and is preset to a list of build-time options that are known for providing significant reliability diff --git a/Makefile b/Makefile index 8fe5c8e1b..4c3d3c51d 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,7 @@ # DEP may be cleared to ignore changes to include files during development # DEBUG may be used to set some internal debugging options. # ERR may be set to non-empty to pass -Werror to the compiler +# FAILFAST may be set to non-empty to pass -Wfatal-errors to the compiler # ADDINC may be used to complete the include path in the form -Ipath. # ADDLIB may be used to complete the library list in the form -Lpath -llib. # DEFINE may be used to specify any additional define, which will be reported @@ -205,7 +206,7 @@ STD_CFLAGS := $(call cc-opt-alt,-fwrapv,-fno-strict-overflow) #### Compiler-specific flags to enable/disable certain classes of warnings. WARN_CFLAGS := -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 \ -Wduplicated-cond -Wnull-dereference -SPEC_CFLAGS := -Wall -Wextra -Wundef -Wdeclaration-after-statement -Wfatal-errors +SPEC_CFLAGS := -Wall -Wextra -Wundef -Wdeclaration-after-statement SPEC_CFLAGS += $(call cc-all-fast,$(WARN_CFLAGS)) SPEC_CFLAGS += $(cc-wnouwo) @@ -223,6 +224,10 @@ ifneq ($(ERR:0=),) SPEC_CFLAGS += -Werror endif +ifneq ($(FAILFAST:0=),) + SPEC_CFLAGS += -Wfatal-errors +endif + #### No longer used SMALL_OPTS = ifneq ($(SMALL_OPTS),)