copts.py
Go to the documentation of this file.
1 """Abseil compiler options.
2 
3 This is the source of truth for Abseil compiler options. To modify Abseil
4 compilation options:
5 
6  (1) Edit the appropriate list in this file based on the platform the flag is
7  needed on.
8  (2) Run `<path_to_absl>/copts/generate_copts.py`.
9 
10 The generated copts are consumed by configure_copts.bzl and
11 AbseilConfigureCopts.cmake.
12 """
13 
14 # /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
15 MSVC_BIG_WARNING_FLAGS = [
16  "/W3",
17 ]
18 
19 LLVM_BIG_WARNING_FLAGS = [
20  "-Wall",
21  "-Wextra",
22  "-Weverything",
23 ]
24 
25 # Docs on single flags is preceded by a comment.
26 # Docs on groups of flags is preceded by ###.
27 LLVM_DISABLE_WARNINGS_FLAGS = [
28  # Abseil does not support C++98
29  "-Wno-c++98-compat-pedantic",
30  # Turns off all implicit conversion warnings. Most are re-enabled below.
31  "-Wno-conversion",
32  "-Wno-covered-switch-default",
33  "-Wno-deprecated",
34  "-Wno-disabled-macro-expansion",
35  "-Wno-double-promotion",
36  ###
37  # Turned off as they include valid C++ code.
38  "-Wno-comma",
39  "-Wno-extra-semi",
40  "-Wno-extra-semi-stmt",
41  "-Wno-packed",
42  "-Wno-padded",
43  ###
44  # Google style does not use unsigned integers, though STL containers
45  # have unsigned types.
46  "-Wno-sign-compare",
47  ###
48  "-Wno-float-conversion",
49  "-Wno-float-equal",
50  "-Wno-format-nonliteral",
51  # Too aggressive: warns on Clang extensions enclosed in Clang-only
52  # compilation paths.
53  "-Wno-gcc-compat",
54  ###
55  # Some internal globals are necessary. Don't do this at home.
56  "-Wno-global-constructors",
57  "-Wno-exit-time-destructors",
58  ###
59  "-Wno-nested-anon-types",
60  "-Wno-non-modular-include-in-module",
61  "-Wno-old-style-cast",
62  # Warns on preferred usage of non-POD types such as string_view
63  "-Wno-range-loop-analysis",
64  "-Wno-reserved-id-macro",
65  "-Wno-shorten-64-to-32",
66  "-Wno-switch-enum",
67  "-Wno-thread-safety-negative",
68  "-Wno-unknown-warning-option",
69  "-Wno-unreachable-code",
70  # Causes warnings on include guards
71  "-Wno-unused-macros",
72  "-Wno-weak-vtables",
73  # Causes warnings on usage of types/compare.h comparison operators.
74  "-Wno-zero-as-null-pointer-constant",
75  ###
76  # Implicit conversion warnings turned off by -Wno-conversion
77  # which are re-enabled below.
78  "-Wbitfield-enum-conversion",
79  "-Wbool-conversion",
80  "-Wconstant-conversion",
81  "-Wenum-conversion",
82  "-Wint-conversion",
83  "-Wliteral-conversion",
84  "-Wnon-literal-null-conversion",
85  "-Wnull-conversion",
86  "-Wobjc-literal-conversion",
87  "-Wno-sign-conversion",
88  "-Wstring-conversion",
89 ]
90 
91 LLVM_TEST_DISABLE_WARNINGS_FLAGS = [
92  "-Wno-c99-extensions",
93  "-Wno-deprecated-declarations",
94  "-Wno-missing-noreturn",
95  "-Wno-missing-prototypes",
96  "-Wno-missing-variable-declarations",
97  "-Wno-null-conversion",
98  "-Wno-shadow",
99  "-Wno-shift-sign-overflow",
100  "-Wno-sign-compare",
101  "-Wno-unused-function",
102  "-Wno-unused-member-function",
103  "-Wno-unused-parameter",
104  "-Wno-unused-private-field",
105  "-Wno-unused-template",
106  "-Wno-used-but-marked-unused",
107  "-Wno-zero-as-null-pointer-constant",
108  # For a libc++ bug fixed in r357267
109  "-Wno-gnu-include-next",
110  # gtest depends on this GNU extension being offered.
111  "-Wno-gnu-zero-variadic-macro-arguments",
112 ]
113 
114 MSVC_STYLE_EXCEPTIONS_FLAGS = [
115  "/U_HAS_EXCEPTIONS",
116  "/D_HAS_EXCEPTIONS=1",
117  "/EHsc"
118 ]
119 
120 MSVC_DEFINES = [
121  "/DNOMINMAX", # Don't define min and max macros (windows.h)
122  # Don't bloat namespace with incompatible winsock versions.
123  "/DWIN32_LEAN_AND_MEAN",
124  # Don't warn about usage of insecure C functions.
125  "/D_CRT_SECURE_NO_WARNINGS",
126  "/D_SCL_SECURE_NO_WARNINGS",
127  # Introduced in VS 2017 15.8, allow overaligned types in aligned_storage
128  "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
129 ]
130 
131 COPT_VARS = {
132  "ABSL_GCC_FLAGS": [
133  "-Wall",
134  "-Wextra",
135  "-Wcast-qual",
136  "-Wconversion-null",
137  "-Wmissing-declarations",
138  "-Woverlength-strings",
139  "-Wpointer-arith",
140  "-Wunused-local-typedefs",
141  "-Wunused-result",
142  "-Wvarargs",
143  "-Wvla", # variable-length array
144  "-Wwrite-strings",
145  # gcc-4.x has spurious missing field initializer warnings.
146  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
147  # Remove when gcc-4.x is no longer supported.
148  "-Wno-missing-field-initializers",
149  # Google style does not use unsigned integers, though STL containers
150  # have unsigned types.
151  "-Wno-sign-compare",
152  ],
153  "ABSL_GCC_TEST_FLAGS": [
154  "-Wno-conversion-null",
155  "-Wno-deprecated-declarations",
156  "-Wno-missing-declarations",
157  "-Wno-sign-compare",
158  "-Wno-unused-function",
159  "-Wno-unused-parameter",
160  "-Wno-unused-private-field",
161  ],
162  "ABSL_GCC_EXCEPTIONS_FLAGS": ["-fexceptions"],
163  "ABSL_LLVM_FLAGS":
164  LLVM_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS,
165  "ABSL_LLVM_TEST_FLAGS":
166  LLVM_TEST_DISABLE_WARNINGS_FLAGS,
167  "ABSL_LLVM_EXCEPTIONS_FLAGS": ["-fexceptions"],
168  "ABSL_CLANG_CL_FLAGS":
169  (MSVC_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS + MSVC_DEFINES),
170  "ABSL_CLANG_CL_TEST_FLAGS":
171  LLVM_TEST_DISABLE_WARNINGS_FLAGS,
172  "ABSL_CLANG_CL_EXCEPTIONS_FLAGS":
173  MSVC_STYLE_EXCEPTIONS_FLAGS,
174  "ABSL_MSVC_FLAGS":
175  MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [
176  "/wd4005", # macro-redefinition
177  "/wd4068", # unknown pragma
178  # qualifier applied to function type has no meaning; ignored
179  "/wd4180",
180  # conversion from 'type1' to 'type2', possible loss of data
181  "/wd4244",
182  # conversion from 'size_t' to 'type', possible loss of data
183  "/wd4267",
184  # The decorated name was longer than the compiler limit
185  "/wd4503",
186  # forcing value to bool 'true' or 'false' (performance warning)
187  "/wd4800",
188  ],
189  "ABSL_MSVC_TEST_FLAGS": [
190  "/wd4018", # signed/unsigned mismatch
191  "/wd4101", # unreferenced local variable
192  "/wd4503", # decorated name length exceeded, name was truncated
193  "/wd4996", # use of deprecated symbol
194  "/DNOMINMAX", # disable the min() and max() macros from <windows.h>
195  ],
196  "ABSL_MSVC_EXCEPTIONS_FLAGS":
197  MSVC_STYLE_EXCEPTIONS_FLAGS,
198  "ABSL_MSVC_LINKOPTS": [
199  # Object file doesn't export any previously undefined symbols
200  "-ignore:4221",
201  ],
202 }


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:19:56