copts.py
Go to the documentation of this file.
00001 """Abseil compiler options.
00002 
00003 This is the source of truth for Abseil compiler options.  To modify Abseil
00004 compilation options:
00005 
00006   (1) Edit the appropriate list in this file based on the platform the flag is
00007       needed on.
00008   (2) Run `<path_to_absl>/copts/generate_copts.py`.
00009 
00010 The generated copts are consumed by configure_copts.bzl and
00011 AbseilConfigureCopts.cmake.
00012 """
00013 
00014 # /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
00015 MSVC_BIG_WARNING_FLAGS = [
00016     "/W3",
00017 ]
00018 
00019 LLVM_BIG_WARNING_FLAGS = [
00020     "-Wall",
00021     "-Wextra",
00022     "-Weverything",
00023 ]
00024 
00025 # Docs on single flags is preceded by a comment.
00026 # Docs on groups of flags is preceded by ###.
00027 LLVM_DISABLE_WARNINGS_FLAGS = [
00028     # Abseil does not support C++98
00029     "-Wno-c++98-compat-pedantic",
00030     # Turns off all implicit conversion warnings. Most are re-enabled below.
00031     "-Wno-conversion",
00032     "-Wno-covered-switch-default",
00033     "-Wno-deprecated",
00034     "-Wno-disabled-macro-expansion",
00035     "-Wno-double-promotion",
00036     ###
00037     # Turned off as they include valid C++ code.
00038     "-Wno-comma",
00039     "-Wno-extra-semi",
00040     "-Wno-extra-semi-stmt",
00041     "-Wno-packed",
00042     "-Wno-padded",
00043     ###
00044     # Google style does not use unsigned integers, though STL containers
00045     # have unsigned types.
00046     "-Wno-sign-compare",
00047     ###
00048     "-Wno-float-conversion",
00049     "-Wno-float-equal",
00050     "-Wno-format-nonliteral",
00051     # Too aggressive: warns on Clang extensions enclosed in Clang-only
00052     # compilation paths.
00053     "-Wno-gcc-compat",
00054     ###
00055     # Some internal globals are necessary. Don't do this at home.
00056     "-Wno-global-constructors",
00057     "-Wno-exit-time-destructors",
00058     ###
00059     "-Wno-nested-anon-types",
00060     "-Wno-non-modular-include-in-module",
00061     "-Wno-old-style-cast",
00062     # Warns on preferred usage of non-POD types such as string_view
00063     "-Wno-range-loop-analysis",
00064     "-Wno-reserved-id-macro",
00065     "-Wno-shorten-64-to-32",
00066     "-Wno-switch-enum",
00067     "-Wno-thread-safety-negative",
00068     "-Wno-unknown-warning-option",
00069     "-Wno-unreachable-code",
00070     # Causes warnings on include guards
00071     "-Wno-unused-macros",
00072     "-Wno-weak-vtables",
00073     # Causes warnings on usage of types/compare.h comparison operators.
00074     "-Wno-zero-as-null-pointer-constant",
00075     ###
00076     # Implicit conversion warnings turned off by -Wno-conversion
00077     # which are re-enabled below.
00078     "-Wbitfield-enum-conversion",
00079     "-Wbool-conversion",
00080     "-Wconstant-conversion",
00081     "-Wenum-conversion",
00082     "-Wint-conversion",
00083     "-Wliteral-conversion",
00084     "-Wnon-literal-null-conversion",
00085     "-Wnull-conversion",
00086     "-Wobjc-literal-conversion",
00087     "-Wno-sign-conversion",
00088     "-Wstring-conversion",
00089 ]
00090 
00091 LLVM_TEST_DISABLE_WARNINGS_FLAGS = [
00092     "-Wno-c99-extensions",
00093     "-Wno-deprecated-declarations",
00094     "-Wno-missing-noreturn",
00095     "-Wno-missing-prototypes",
00096     "-Wno-missing-variable-declarations",
00097     "-Wno-null-conversion",
00098     "-Wno-shadow",
00099     "-Wno-shift-sign-overflow",
00100     "-Wno-sign-compare",
00101     "-Wno-unused-function",
00102     "-Wno-unused-member-function",
00103     "-Wno-unused-parameter",
00104     "-Wno-unused-private-field",
00105     "-Wno-unused-template",
00106     "-Wno-used-but-marked-unused",
00107     "-Wno-zero-as-null-pointer-constant",
00108     # For a libc++ bug fixed in r357267
00109     "-Wno-gnu-include-next",
00110     # gtest depends on this GNU extension being offered.
00111     "-Wno-gnu-zero-variadic-macro-arguments",
00112 ]
00113 
00114 MSVC_STYLE_EXCEPTIONS_FLAGS = [
00115     "/U_HAS_EXCEPTIONS",
00116     "/D_HAS_EXCEPTIONS=1",
00117     "/EHsc"
00118 ]
00119 
00120 MSVC_DEFINES = [
00121     "/DNOMINMAX",  # Don't define min and max macros (windows.h)
00122     # Don't bloat namespace with incompatible winsock versions.
00123     "/DWIN32_LEAN_AND_MEAN",
00124     # Don't warn about usage of insecure C functions.
00125     "/D_CRT_SECURE_NO_WARNINGS",
00126     "/D_SCL_SECURE_NO_WARNINGS",
00127     # Introduced in VS 2017 15.8, allow overaligned types in aligned_storage
00128     "/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
00129 ]
00130 
00131 COPT_VARS = {
00132     "ABSL_GCC_FLAGS": [
00133         "-Wall",
00134         "-Wextra",
00135         "-Wcast-qual",
00136         "-Wconversion-null",
00137         "-Wmissing-declarations",
00138         "-Woverlength-strings",
00139         "-Wpointer-arith",
00140         "-Wunused-local-typedefs",
00141         "-Wunused-result",
00142         "-Wvarargs",
00143         "-Wvla",  # variable-length array
00144         "-Wwrite-strings",
00145         # gcc-4.x has spurious missing field initializer warnings.
00146         # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
00147         # Remove when gcc-4.x is no longer supported.
00148         "-Wno-missing-field-initializers",
00149         # Google style does not use unsigned integers, though STL containers
00150         # have unsigned types.
00151         "-Wno-sign-compare",
00152     ],
00153     "ABSL_GCC_TEST_FLAGS": [
00154         "-Wno-conversion-null",
00155         "-Wno-deprecated-declarations",
00156         "-Wno-missing-declarations",
00157         "-Wno-sign-compare",
00158         "-Wno-unused-function",
00159         "-Wno-unused-parameter",
00160         "-Wno-unused-private-field",
00161     ],
00162     "ABSL_GCC_EXCEPTIONS_FLAGS": ["-fexceptions"],
00163     "ABSL_LLVM_FLAGS":
00164         LLVM_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS,
00165     "ABSL_LLVM_TEST_FLAGS":
00166         LLVM_TEST_DISABLE_WARNINGS_FLAGS,
00167     "ABSL_LLVM_EXCEPTIONS_FLAGS": ["-fexceptions"],
00168     "ABSL_CLANG_CL_FLAGS":
00169         (MSVC_BIG_WARNING_FLAGS + LLVM_DISABLE_WARNINGS_FLAGS + MSVC_DEFINES),
00170     "ABSL_CLANG_CL_TEST_FLAGS":
00171         LLVM_TEST_DISABLE_WARNINGS_FLAGS,
00172     "ABSL_CLANG_CL_EXCEPTIONS_FLAGS":
00173         MSVC_STYLE_EXCEPTIONS_FLAGS,
00174     "ABSL_MSVC_FLAGS":
00175         MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + [
00176             "/wd4005",  # macro-redefinition
00177             "/wd4068",  # unknown pragma
00178             # qualifier applied to function type has no meaning; ignored
00179             "/wd4180",
00180             # conversion from 'type1' to 'type2', possible loss of data
00181             "/wd4244",
00182             # conversion from 'size_t' to 'type', possible loss of data
00183             "/wd4267",
00184             # The decorated name was longer than the compiler limit
00185             "/wd4503",
00186             # forcing value to bool 'true' or 'false' (performance warning)
00187             "/wd4800",
00188         ],
00189     "ABSL_MSVC_TEST_FLAGS": [
00190         "/wd4018",  # signed/unsigned mismatch
00191         "/wd4101",  # unreferenced local variable
00192         "/wd4503",  # decorated name length exceeded, name was truncated
00193         "/wd4996",  # use of deprecated symbol
00194         "/DNOMINMAX",  # disable the min() and max() macros from <windows.h>
00195     ],
00196     "ABSL_MSVC_EXCEPTIONS_FLAGS":
00197         MSVC_STYLE_EXCEPTIONS_FLAGS,
00198     "ABSL_MSVC_LINKOPTS": [
00199         # Object file doesn't export any previously undefined symbols
00200         "-ignore:4221",
00201     ],
00202 }


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