Skip to content

Commit ebd2e4a

Browse files
carenasgitster
authored andcommitted
Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better
6a8cbc4 (developer: enable pedantic by default, 2021-09-03) enables pedantic mode in as many compilers as possible to help gather feedback on future tightening, so lets do so. -Wpedantic is missing in some really old gcc 4 versions so lets restrict it to gcc5 and clang4 (it does work in clang3 AFAIK, but it will be unlikely that a developer will use such an old compiler anyway). MinGW gcc is the only one which has -Wno-pedantic-ms-format, and while that is available also in older compilers, the Windows SDK provides gcc10 so lets aim for that. Note that in order to target the flag to only Windows, additional changes were needed in config.mak.uname to propagate the OS detection which also did some minor refactoring, but which is functionaly equivalent. Helped-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d84c4e commit ebd2e4a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

config.mak.dev

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ ifeq ($(filter no-error,$(DEVOPTS)),)
66
DEVELOPER_CFLAGS += -Werror
77
SPARSE_FLAGS += -Wsparse-error
88
endif
9+
910
DEVELOPER_CFLAGS += -Wall
1011
ifeq ($(filter no-pedantic,$(DEVOPTS)),)
1112
DEVELOPER_CFLAGS += -pedantic
13+
ifneq (($or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
1214
DEVELOPER_CFLAGS += -Wpedantic
13-
ifneq ($(filter gcc5,$(COMPILER_FEATURES)),)
15+
ifneq ($(filter gcc10,$(COMPILER_FEATURES)),)
16+
ifeq ($(uname_S),MINGW)
1417
DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
1518
endif
1619
endif
20+
endif
21+
endif
1722
DEVELOPER_CFLAGS += -Wdeclaration-after-statement
1823
DEVELOPER_CFLAGS += -Wformat-security
1924
DEVELOPER_CFLAGS += -Wold-style-definition

config.mak.uname

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
1111
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
1212
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
1313

14+
ifneq ($(findstring MINGW,$(uname_S)),)
15+
uname_S := MINGW
16+
endif
17+
1418
ifdef MSVC
1519
# avoid the MingW and Cygwin configuration sections
1620
uname_S := Windows
@@ -588,7 +592,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
588592
SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
589593
SHELL_PATH = /usr/coreutils/bin/bash
590594
endif
591-
ifneq (,$(findstring MINGW,$(uname_S)))
595+
ifeq ($(uname_S),MINGW)
592596
pathsep = ;
593597
HAVE_ALLOCA_H = YesPlease
594598
NO_PREAD = YesPlease

0 commit comments

Comments
 (0)