summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2018-08-14 15:24:54 -0400
committerAndrew Morrow <acm@mongodb.com>2018-09-20 14:36:08 -0400
commit499f7c0f7dab2d3ed31cad84d3c96b5884436f5f (patch)
tree2bba9da77ddf283f74dae8ce10ad69a93e412887
parentca7ee87306f3333a9ef1f89d7a272f36282ff963 (diff)
downloadmongo-499f7c0f7dab2d3ed31cad84d3c96b5884436f5f.tar.gz
SERVER-33912 Make warnings fatal for embedded builders
Also includes necessary feature flag and new clang warning suppressions (cherry picked from commit a81a923c2c44d69a39a81ade66572fafedfa4f03)
-rw-r--r--SConstruct28
-rw-r--r--etc/evergreen.yml1
-rw-r--r--src/mongo/util/net/sockaddr.cpp4
3 files changed, 30 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct
index 1d634b159bf..8c03735f32e 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1723,6 +1723,29 @@ if env.ToolchainIs('msvc'):
if env.TargetOSIs('posix'):
+ # On linux, C code compiled with gcc/clang -std=c11 causes
+ # __STRICT_ANSI__ to be set, and that drops out all of the feature
+ # test definitions, resulting in confusing errors when we run C
+ # language configure checks and expect to be able to find newer
+ # POSIX things. Explicitly enabling _XOPEN_SOURCE fixes that, and
+ # should be mostly harmless as on Linux, these macros are
+ # cumulative. The C++ compiler already sets _XOPEN_SOURCE, and,
+ # notably, setting it again does not disable any other feature
+ # test macros, so this is safe to do. Other platforms like macOS
+ # and BSD have crazy rules, so don't try this there.
+ #
+ # Furthermore, as both C++ compilers appears to unconditioanlly
+ # define _GNU_SOURCE (because libstdc++ requires it), it seems
+ # prudent to explicitly add that too, so that C language checks
+ # see a consistent set of definitions.
+ if env.TargetOSIs('linux'):
+ env.AppendUnique(
+ CPPDEFINES=[
+ ('_XOPEN_SOURCE', 700),
+ '_GNU_SOURCE',
+ ],
+ )
+
# Everything on OS X is position independent by default. Solaris doesn't support PIE.
if not env.TargetOSIs('darwin', 'solaris'):
if get_option('runtime-hardening') == "on":
@@ -2108,6 +2131,11 @@ def doConfigure(myenv):
# As of clang-3.4, this warning appears in v8, and gets escalated to an error.
AddToCCFLAGSIfSupported(myenv, "-Wno-tautological-constant-out-of-range-compare")
+ # As of clang in Android NDK 17, these warnings appears in boost and/or ICU, and get escalated to errors
+ AddToCCFLAGSIfSupported(myenv, "-Wno-tautological-constant-compare")
+ AddToCCFLAGSIfSupported(myenv, "-Wno-tautological-unsigned-zero-compare")
+ AddToCCFLAGSIfSupported(myenv, "-Wno-tautological-unsigned-enum-zero-compare")
+
# New in clang-3.4, trips up things mostly in third_party, but in a few places in the
# primary mongo sources as well.
AddToCCFLAGSIfSupported(myenv, "-Wno-unused-const-variable")
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 35b2f883a02..f902379a43b 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -3421,7 +3421,6 @@ tasks:
vars:
targets: install-embedded-dev
task_compile_flags: &embedded_sdk_compile_flags >-
- --disable-warnings-as-errors
--install-mode=hygienic
--js-engine=none
--prefix='$BUILD_ROOT/mongo-embedded-sdk-$MONGO_VERSION'
diff --git a/src/mongo/util/net/sockaddr.cpp b/src/mongo/util/net/sockaddr.cpp
index 0cf024b6f44..b3ea963ff5a 100644
--- a/src/mongo/util/net/sockaddr.cpp
+++ b/src/mongo/util/net/sockaddr.cpp
@@ -156,7 +156,7 @@ SockAddr::SockAddr(StringData target, int port, sa_family_t familyHint)
// This throws away all but the first address.
// Use SockAddr::createAll() to get all addresses.
const auto* addrs = addrErr.second.get();
- fassert(16501, addrs->ai_addrlen <= sizeof(sa));
+ fassert(16501, static_cast<size_t>(addrs->ai_addrlen) <= sizeof(sa));
memcpy(&sa, addrs->ai_addr, addrs->ai_addrlen);
addressSize = addrs->ai_addrlen;
_isValid = true;
@@ -183,7 +183,7 @@ std::vector<SockAddr> SockAddr::createAll(StringData target, int port, sa_family
struct sockaddr_storage storage;
memset(&storage, 0, sizeof(storage));
for (const auto* addrs = addrErr.second.get(); addrs; addrs = addrs->ai_next) {
- fassert(40594, addrs->ai_addrlen <= sizeof(struct sockaddr_storage));
+ fassert(40594, static_cast<size_t>(addrs->ai_addrlen) <= sizeof(struct sockaddr_storage));
// Make a temp copy in a local sockaddr_storage so that the
// SockAddr constructor below can copy the entire buffer
// without over-running addrinfo's storage