git
/
config.mak.dev
103 строки · 3.4 Кб
1ifndef COMPILER_FEATURES
2COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
3endif
4
5ifeq ($(filter no-error,$(DEVOPTS)),)
6DEVELOPER_CFLAGS += -Werror
7SPARSE_FLAGS += -Wsparse-error
8endif
9
10DEVELOPER_CFLAGS += -Wall
11ifeq ($(filter no-pedantic,$(DEVOPTS)),)
12DEVELOPER_CFLAGS += -pedantic
13ifneq ($(or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
14DEVELOPER_CFLAGS += -Wpedantic
15ifneq ($(filter gcc10,$(COMPILER_FEATURES)),)
16ifeq ($(uname_S),MINGW)
17DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
18endif
19endif
20endif
21endif
22
23ifneq ($(uname_S),FreeBSD)
24ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang7,$(COMPILER_FEATURES))),)
25DEVELOPER_CFLAGS += -std=gnu99
26endif
27else
28# FreeBSD cannot limit to C99 because its system headers unconditionally
29# rely on C11 features.
30endif
31
32DEVELOPER_CFLAGS += -Wdeclaration-after-statement
33DEVELOPER_CFLAGS += -Wformat-security
34DEVELOPER_CFLAGS += -Wold-style-definition
35DEVELOPER_CFLAGS += -Woverflow
36DEVELOPER_CFLAGS += -Wpointer-arith
37DEVELOPER_CFLAGS += -Wstrict-prototypes
38DEVELOPER_CFLAGS += -Wunused
39DEVELOPER_CFLAGS += -Wvla
40DEVELOPER_CFLAGS += -Wwrite-strings
41DEVELOPER_CFLAGS += -fno-common
42
43ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
44DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
45endif
46
47ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
48DEVELOPER_CFLAGS += -Wextra
49# if a function is public, there should be a prototype and the right
50# header file should be included. If not, it should be static.
51DEVELOPER_CFLAGS += -Wmissing-prototypes
52ifeq ($(filter extra-all,$(DEVOPTS)),)
53# These are disabled because we have these all over the place.
54DEVELOPER_CFLAGS += -Wno-empty-body
55DEVELOPER_CFLAGS += -Wno-missing-field-initializers
56DEVELOPER_CFLAGS += -Wno-sign-compare
57DEVELOPER_CFLAGS += -Wno-unused-parameter
58endif
59endif
60
61# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
62# not worth fixing since newer compilers correctly stop complaining
63#
64# Likewise, gcc older than 4.9 complains about initializing a
65# struct-within-a-struct using just "{ 0 }"
66ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
67ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
68DEVELOPER_CFLAGS += -Wno-uninitialized
69DEVELOPER_CFLAGS += -Wno-missing-braces
70endif
71endif
72
73# Old versions of clang complain about initializaing a
74# struct-within-a-struct using just "{0}" rather than "{{0}}". This
75# error is considered a false-positive and not worth fixing, because
76# new clang versions do not, so just disable it.
77#
78# The "bug" was fixed in upstream clang 9.
79#
80# Complicating this is that versions of clang released by Apple have
81# their own version numbers (associated with the corresponding version
82# of XCode) unrelated to the official clang version numbers.
83#
84# The bug was fixed in Apple clang 12.
85#
86ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang
87ifeq ($(uname_S),Darwin) # if we are on darwin
88ifeq ($(filter clang12,$(COMPILER_FEATURES)),) # if version < 12
89DEVELOPER_CFLAGS += -Wno-missing-braces
90endif
91else # not darwin
92ifeq ($(filter clang9,$(COMPILER_FEATURES)),) # if version < 9
93DEVELOPER_CFLAGS += -Wno-missing-braces
94endif
95endif
96endif
97
98# https://bugzilla.redhat.com/show_bug.cgi?id=2075786
99ifneq ($(filter gcc12,$(COMPILER_FEATURES)),)
100DEVELOPER_CFLAGS += -Wno-error=stringop-overread
101endif
102
103GIT_TEST_PERL_FATAL_WARNINGS = YesPlease
104