abseil-cpp/absl/copts/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_TEST_DISABLE_WARNINGS_FLAGS = [
20  "-Wno-c99-extensions",
21  "-Wno-deprecated-declarations",
22  "-Wno-missing-noreturn",
23  "-Wno-missing-prototypes",
24  "-Wno-missing-variable-declarations",
25  "-Wno-null-conversion",
26  "-Wno-shadow",
27  "-Wno-shift-sign-overflow",
28  "-Wno-sign-compare",
29  "-Wno-unused-function",
30  "-Wno-unused-member-function",
31  "-Wno-unused-parameter",
32  "-Wno-unused-private-field",
33  "-Wno-unused-template",
34  "-Wno-used-but-marked-unused",
35  "-Wno-zero-as-null-pointer-constant",
36  # gtest depends on this GNU extension being offered.
37  "-Wno-gnu-zero-variadic-macro-arguments",
38 ]
39 
40 MSVC_DEFINES = [
41  "/DNOMINMAX", # Don't define min and max macros (windows.h)
42  # Don't bloat namespace with incompatible winsock versions.
43  "/DWIN32_LEAN_AND_MEAN",
44  # Don't warn about usage of insecure C functions.
45  "/D_CRT_SECURE_NO_WARNINGS",
46  "/D_SCL_SECURE_NO_WARNINGS",
47  # Introduced in VS 2017 15.8, allow overaligned types in aligned_storage
48  "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
49 ]
50 
51 COPT_VARS = {
52  "ABSL_GCC_FLAGS": [
53  "-Wall",
54  "-Wextra",
55  "-Wcast-qual",
56  "-Wconversion-null",
57  "-Wformat-security",
58  "-Wmissing-declarations",
59  "-Woverlength-strings",
60  "-Wpointer-arith",
61  "-Wundef",
62  "-Wunused-local-typedefs",
63  "-Wunused-result",
64  "-Wvarargs",
65  "-Wvla", # variable-length array
66  "-Wwrite-strings",
67  # Don't define min and max macros (Build on Windows using gcc)
68  "-DNOMINMAX",
69  ],
70  "ABSL_GCC_TEST_FLAGS": [
71  "-Wno-conversion-null",
72  "-Wno-deprecated-declarations",
73  "-Wno-missing-declarations",
74  "-Wno-sign-compare",
75  "-Wno-unused-function",
76  "-Wno-unused-parameter",
77  "-Wno-unused-private-field",
78  ],
79  "ABSL_LLVM_FLAGS": [
80  "-Wall",
81  "-Wextra",
82  "-Wcast-qual",
83  "-Wconversion",
84  "-Wfloat-overflow-conversion",
85  "-Wfloat-zero-conversion",
86  "-Wfor-loop-analysis",
87  "-Wformat-security",
88  "-Wgnu-redeclared-enum",
89  "-Winfinite-recursion",
90  "-Winvalid-constexpr",
91  "-Wliteral-conversion",
92  "-Wmissing-declarations",
93  "-Woverlength-strings",
94  "-Wpointer-arith",
95  "-Wself-assign",
96  "-Wshadow-all",
97  "-Wstring-conversion",
98  "-Wtautological-overlap-compare",
99  "-Wundef",
100  "-Wuninitialized",
101  "-Wunreachable-code",
102  "-Wunused-comparison",
103  "-Wunused-local-typedefs",
104  "-Wunused-result",
105  "-Wvla",
106  "-Wwrite-strings",
107  # Warnings that are enabled by group warning flags like -Wall that we
108  # explicitly disable.
109  "-Wno-float-conversion",
110  "-Wno-implicit-float-conversion",
111  "-Wno-implicit-int-float-conversion",
112  "-Wno-implicit-int-conversion",
113  "-Wno-shorten-64-to-32",
114  "-Wno-sign-conversion",
115  # Disable warnings on unknown warning flags (when warning flags are
116  # unknown on older compiler versions)
117  "-Wno-unknown-warning-option",
118  # Don't define min and max macros (Build on Windows using clang)
119  "-DNOMINMAX",
120  ],
121  "ABSL_LLVM_TEST_FLAGS":
122  LLVM_TEST_DISABLE_WARNINGS_FLAGS,
123  "ABSL_CLANG_CL_FLAGS":
124  (MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES),
125  "ABSL_CLANG_CL_TEST_FLAGS":
126  LLVM_TEST_DISABLE_WARNINGS_FLAGS,
127  "ABSL_MSVC_FLAGS":
128  MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [
129  # Increase the number of sections available in object files
130  "/bigobj",
131  "/wd4005", # macro-redefinition
132  "/wd4068", # unknown pragma
133  # qualifier applied to function type has no meaning; ignored
134  "/wd4180",
135  # conversion from 'type1' to 'type2', possible loss of data
136  "/wd4244",
137  # conversion from 'size_t' to 'type', possible loss of data
138  "/wd4267",
139  # The decorated name was longer than the compiler limit
140  "/wd4503",
141  # forcing value to bool 'true' or 'false' (performance warning)
142  "/wd4800",
143  ],
144  "ABSL_MSVC_TEST_FLAGS": [
145  "/wd4018", # signed/unsigned mismatch
146  "/wd4101", # unreferenced local variable
147  "/wd4503", # decorated name length exceeded, name was truncated
148  "/wd4996", # use of deprecated symbol
149  "/DNOMINMAX", # disable the min() and max() macros from <windows.h>
150  ],
151  "ABSL_MSVC_LINKOPTS": [
152  # Object file doesn't export any previously undefined symbols
153  "-ignore:4221",
154  ],
155  # "HWAES" is an abbreviation for "hardware AES" (AES - Advanced Encryption
156  # Standard). These flags are used for detecting whether or not the target
157  # architecture has hardware support for AES instructions which can be used
158  # to improve performance of some random bit generators.
159  "ABSL_RANDOM_HWAES_ARM64_FLAGS": ["-march=armv8-a+crypto"],
160  "ABSL_RANDOM_HWAES_ARM32_FLAGS": ["-mfpu=neon"],
161  "ABSL_RANDOM_HWAES_X64_FLAGS": [
162  "-maes",
163  "-msse4.1",
164  ],
165  "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS": [],
166 }


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:02