2017-09-19 22:54:40 +02:00
|
|
|
"""absl specific copts.
|
|
|
|
|
|
|
|
Flags specified here must not impact ABI. Code compiled with and without these
|
|
|
|
opts will be linked together, and in some cases headers compiled with and
|
|
|
|
without these options will be part of the same program.
|
|
|
|
"""
|
|
|
|
GCC_FLAGS = [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wcast-qual",
|
|
|
|
"-Wconversion-null",
|
|
|
|
"-Wmissing-declarations",
|
|
|
|
"-Woverlength-strings",
|
|
|
|
"-Wpointer-arith",
|
|
|
|
"-Wunused-local-typedefs",
|
|
|
|
"-Wunused-result",
|
|
|
|
"-Wvarargs",
|
|
|
|
"-Wvla", # variable-length array
|
|
|
|
"-Wwrite-strings",
|
2017-12-22 04:39:42 +01:00
|
|
|
# Google style does not use unsigned integers, though STL containers
|
|
|
|
# have unsigned types.
|
|
|
|
"-Wno-sign-compare",
|
2017-09-19 22:54:40 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
GCC_TEST_FLAGS = [
|
|
|
|
"-Wno-conversion-null",
|
|
|
|
"-Wno-missing-declarations",
|
|
|
|
"-Wno-sign-compare",
|
|
|
|
"-Wno-unused-function",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-unused-private-field",
|
|
|
|
]
|
|
|
|
|
2017-12-12 20:23:51 +01:00
|
|
|
# Docs on single flags is preceded by a comment.
|
|
|
|
# Docs on groups of flags is preceded by ###.
|
|
|
|
|
2017-09-19 22:54:40 +02:00
|
|
|
LLVM_FLAGS = [
|
|
|
|
"-Wall",
|
|
|
|
"-Wextra",
|
|
|
|
"-Weverything",
|
2017-12-12 20:23:51 +01:00
|
|
|
# Abseil does not support C++98
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-c++98-compat-pedantic",
|
2017-12-12 20:23:51 +01:00
|
|
|
# Turns off all implicit conversion warnings. Most are re-enabled below.
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-conversion",
|
2017-09-24 17:20:48 +02:00
|
|
|
"-Wno-covered-switch-default",
|
|
|
|
"-Wno-deprecated",
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-disabled-macro-expansion",
|
|
|
|
"-Wno-double-promotion",
|
2017-12-22 04:39:42 +01:00
|
|
|
###
|
|
|
|
# Turned off as they include valid C++ code.
|
|
|
|
"-Wno-comma",
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-extra-semi",
|
2017-12-22 04:39:42 +01:00
|
|
|
"-Wno-packed",
|
|
|
|
"-Wno-padded",
|
|
|
|
###
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-float-conversion",
|
|
|
|
"-Wno-float-equal",
|
|
|
|
"-Wno-format-nonliteral",
|
2017-12-22 04:39:42 +01:00
|
|
|
# Too aggressive: warns on Clang extensions enclosed in Clang-only
|
|
|
|
# compilation paths.
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-gcc-compat",
|
2017-12-22 04:39:42 +01:00
|
|
|
###
|
|
|
|
# Some internal globals are necessary. Don't do this at home.
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-global-constructors",
|
2017-12-22 04:39:42 +01:00
|
|
|
"-Wno-exit-time-destructors",
|
|
|
|
###
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-nested-anon-types",
|
|
|
|
"-Wno-non-modular-include-in-module",
|
|
|
|
"-Wno-old-style-cast",
|
2017-12-12 20:23:51 +01:00
|
|
|
# Warns on preferred usage of non-POD types such as string_view
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-range-loop-analysis",
|
|
|
|
"-Wno-reserved-id-macro",
|
|
|
|
"-Wno-shorten-64-to-32",
|
|
|
|
"-Wno-switch-enum",
|
|
|
|
"-Wno-thread-safety-negative",
|
|
|
|
"-Wno-undef",
|
2017-09-24 17:20:48 +02:00
|
|
|
"-Wno-unknown-warning-option",
|
|
|
|
"-Wno-unreachable-code",
|
2017-12-12 20:23:51 +01:00
|
|
|
# Causes warnings on include guards
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wno-unused-macros",
|
|
|
|
"-Wno-weak-vtables",
|
2017-12-12 20:23:51 +01:00
|
|
|
###
|
|
|
|
# Implicit conversion warnings turned off by -Wno-conversion
|
|
|
|
# which are re-enabled below.
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wbitfield-enum-conversion",
|
|
|
|
"-Wbool-conversion",
|
|
|
|
"-Wconstant-conversion",
|
|
|
|
"-Wenum-conversion",
|
|
|
|
"-Wint-conversion",
|
|
|
|
"-Wliteral-conversion",
|
|
|
|
"-Wnon-literal-null-conversion",
|
|
|
|
"-Wnull-conversion",
|
|
|
|
"-Wobjc-literal-conversion",
|
2017-12-22 04:39:42 +01:00
|
|
|
"-Wno-sign-conversion",
|
2017-09-19 22:54:40 +02:00
|
|
|
"-Wstring-conversion",
|
2017-12-12 20:23:51 +01:00
|
|
|
###
|
2017-09-19 22:54:40 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
LLVM_TEST_FLAGS = [
|
|
|
|
"-Wno-c99-extensions",
|
|
|
|
"-Wno-missing-noreturn",
|
|
|
|
"-Wno-missing-prototypes",
|
|
|
|
"-Wno-null-conversion",
|
|
|
|
"-Wno-shadow",
|
|
|
|
"-Wno-shift-sign-overflow",
|
|
|
|
"-Wno-sign-compare",
|
|
|
|
"-Wno-unused-function",
|
|
|
|
"-Wno-unused-member-function",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-unused-private-field",
|
|
|
|
"-Wno-unused-template",
|
|
|
|
"-Wno-used-but-marked-unused",
|
|
|
|
"-Wno-zero-as-null-pointer-constant",
|
|
|
|
]
|
|
|
|
|
|
|
|
MSVC_FLAGS = [
|
|
|
|
"/W3",
|
2017-12-22 04:39:42 +01:00
|
|
|
"/wd4005", # macro-redefinition
|
2017-09-19 22:54:40 +02:00
|
|
|
"/wd4068", # unknown pragma
|
2018-09-27 21:24:54 +02:00
|
|
|
"/wd4180", # qualifier applied to function type has no meaning; ignored
|
2017-09-19 22:54:40 +02:00
|
|
|
"/wd4244", # conversion from 'type1' to 'type2', possible loss of data
|
|
|
|
"/wd4267", # conversion from 'size_t' to 'type', possible loss of data
|
|
|
|
"/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
|
2017-11-28 06:36:16 +01:00
|
|
|
"/DNOMINMAX", # Don't define min and max macros (windows.h)
|
2017-09-19 22:54:40 +02:00
|
|
|
"/DWIN32_LEAN_AND_MEAN", # Don't bloat namespace with incompatible winsock versions.
|
2017-11-28 06:36:16 +01:00
|
|
|
"/D_CRT_SECURE_NO_WARNINGS", # Don't warn about usage of insecure C functions
|
2017-09-19 22:54:40 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
MSVC_TEST_FLAGS = [
|
|
|
|
"/wd4018", # signed/unsigned mismatch
|
|
|
|
"/wd4101", # unreferenced local variable
|
|
|
|
"/wd4503", # decorated name length exceeded, name was truncated
|
|
|
|
]
|
|
|
|
|
|
|
|
# /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
|
|
|
|
ABSL_DEFAULT_COPTS = select({
|
|
|
|
"//absl:windows": MSVC_FLAGS,
|
2017-09-24 17:20:48 +02:00
|
|
|
"//absl:llvm_compiler": LLVM_FLAGS,
|
2017-09-19 22:54:40 +02:00
|
|
|
"//conditions:default": GCC_FLAGS,
|
|
|
|
})
|
|
|
|
|
|
|
|
# in absence of modules (--compiler=gcc or -c opt), cc_tests leak their copts
|
|
|
|
# to their (included header) dependencies and fail to build outside absl
|
|
|
|
ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({
|
|
|
|
"//absl:windows": MSVC_TEST_FLAGS,
|
2017-09-24 17:20:48 +02:00
|
|
|
"//absl:llvm_compiler": LLVM_TEST_FLAGS,
|
2017-09-19 22:54:40 +02:00
|
|
|
"//conditions:default": GCC_TEST_FLAGS,
|
|
|
|
})
|
|
|
|
|
|
|
|
ABSL_EXCEPTIONS_FLAG = select({
|
|
|
|
"//absl:windows": ["/U_HAS_EXCEPTIONS", "/D_HAS_EXCEPTIONS=1", "/EHsc"],
|
|
|
|
"//conditions:default": ["-fexceptions"],
|
|
|
|
})
|
2018-08-09 20:32:15 +02:00
|
|
|
|
|
|
|
ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({
|
|
|
|
"//conditions:default": [],
|
|
|
|
})
|