diff --git a/SConstruct b/SConstruct index 872316ab8c4..b5faf993cf3 100644 --- a/SConstruct +++ b/SConstruct @@ -80,6 +80,7 @@ else: nix = not windows # --- options ---- +use_clang = False options = {} @@ -1049,6 +1050,9 @@ def doConfigure(myenv): myenv = conf.Finish() + global use_clang + use_clang = using_clang() + # Figure out what our minimum windows version is. If the user has specified, then use # that. Otherwise, if they have explicitly selected between 32 bit or 64 bit, choose XP or # Vista respectively. Finally, if they haven't done either of these, try invoking the @@ -1125,7 +1129,7 @@ def doConfigure(myenv): test_mutation = mutation if using_gcc(): test_mutation = copy.deepcopy(mutation) - # GCC helpfully doesn't issue a diagnostic on unkown flags of the form -Wno-xxx + # GCC helpfully doesn't issue a diagnostic on unknown flags of the form -Wno-xxx # unless other diagnostics are triggered. That makes it tough to check for support # for -Wno-xxx. To work around, if we see that we are testing for a flag of the # form -Wno-xxx (but not -Wno-error=xxx), we also add -Wxxx to the flags. GCC does @@ -1180,12 +1184,6 @@ def doConfigure(myenv): # libraries have such things. AddToCCFLAGSIfSupported(myenv, '-Wno-unused-private-field') - # Clang warns about struct/class tag mismatch, but most people think that that is not - # really an issue, see - # http://stackoverflow.com/questions/4866425/mixing-class-and-struct. We disable the - # warning so it doesn't become an error. - AddToCCFLAGSIfSupported(myenv, '-Wno-mismatched-tags') - # Prevents warning about using deprecated features (such as auto_ptr in c++11) # Using -Wno-error=deprecated-declarations does not seem to work on some compilers, # including at least g++-4.6. @@ -1691,6 +1689,7 @@ Export('module_sconscripts') Export("debugBuild optBuild") Export("enforce_glibc") Export("s3push") +Export("use_clang") env.SConscript('src/SConscript', variant_dir='$BUILD_DIR', duplicate=False) env.SConscript('src/SConscript.client', variant_dir='$BUILD_DIR/client_build', duplicate=False) diff --git a/src/mongo/db/geo/s2.h b/src/mongo/db/geo/s2.h new file mode 100644 index 00000000000..426e9f0e5b5 --- /dev/null +++ b/src/mongo/db/geo/s2.h @@ -0,0 +1,45 @@ +/** +* Copyright (C) 2008-2012 10gen Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +* As a special exception, the copyright holders give permission to link the +* code of portions of this program with the OpenSSL library under certain +* conditions as described in each individual source file and distribute +* linked combinations including the program with the OpenSSL library. You +* must comply with the GNU Affero General Public License in all respects for +* all of the code used other than as permitted herein. If you modify file(s) +* with this exception, you may extend this exception to your version of the +* file(s), but you are not obligated to do so. If you do not wish to do so, +* delete this exception statement from your version. If you delete this +* exception statement from all source files in the program, then also delete +* it in the license file. +*/ + +#pragma once + +/* + * This file's purpose is to confine the suppression of the Clang warning for mismatched-tags (struct vs class) + * in only the s2.h file + */ + +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wmismatched-tags" +#endif + +#include "third_party/s2/s2.h" + +#ifdef __clang__ +#pragma GCC diagnostic pop +#endif + diff --git a/src/mongo/db/geo/s2common.cpp b/src/mongo/db/geo/s2common.cpp index 2695c16f629..cfb6bd0b4ba 100644 --- a/src/mongo/db/geo/s2common.cpp +++ b/src/mongo/db/geo/s2common.cpp @@ -31,7 +31,7 @@ #include "mongo/db/geo/geoconstants.h" #include "mongo/db/geo/geoparser.h" #include "mongo/db/geo/geoquery.h" -#include "third_party/s2/s2.h" +#include "mongo/db/geo/s2.h" #include "third_party/s2/s2cell.h" #include "third_party/s2/s2regioncoverer.h" diff --git a/src/mongo/db/geo/s2common.h b/src/mongo/db/geo/s2common.h index 15440514978..7a23887fa81 100644 --- a/src/mongo/db/geo/s2common.h +++ b/src/mongo/db/geo/s2common.h @@ -28,7 +28,7 @@ #include "mongo/db/geo/geoparser.h" #include "mongo/db/geo/geoconstants.h" -#include "third_party/s2/s2.h" +#include "mongo/db/geo/s2.h" #include "third_party/s2/s2regioncoverer.h" #include "third_party/s2/s2cell.h" #include "third_party/s2/s2polyline.h" diff --git a/src/mongo/db/geo/shapes.h b/src/mongo/db/geo/shapes.h index 41b1de47605..2f18f6731c2 100644 --- a/src/mongo/db/geo/shapes.h +++ b/src/mongo/db/geo/shapes.h @@ -33,7 +33,7 @@ #include "mongo/base/owned_pointer_vector.h" #include "mongo/db/jsobj.h" -#include "third_party/s2/s2.h" +#include "mongo/db/geo/s2.h" #include "third_party/s2/s2cap.h" #include "third_party/s2/s2cell.h" #include "third_party/s2/s2latlng.h" diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp index 7bff41b60e3..23c5e524743 100644 --- a/src/mongo/db/query/index_bounds_builder.cpp +++ b/src/mongo/db/query/index_bounds_builder.cpp @@ -36,7 +36,7 @@ #include "mongo/db/query/indexability.h" #include "mongo/db/query/qlog.h" #include "mongo/util/mongoutils/str.h" -#include "third_party/s2/s2.h" +#include "mongo/db/geo/s2.h" #include "third_party/s2/s2cell.h" #include "third_party/s2/s2regioncoverer.h" diff --git a/src/third_party/s2/SConscript b/src/third_party/s2/SConscript index 764a5be76ce..9179fe6d272 100644 --- a/src/third_party/s2/SConscript +++ b/src/third_party/s2/SConscript @@ -1,6 +1,6 @@ # -*- mode: python -*- -Import("env windows linux darwin solaris") +Import("env windows linux darwin solaris use_clang") env = env.Clone() @@ -14,6 +14,13 @@ env.SConscript( [ env.Append(CCFLAGS=['-Isrc/third_party/s2']) env.Append(CCFLAGS=['-DDEBUG_MODE=false']) +# Clang warns about struct/class tag mismatch, but as long as this is +# not a problem on Windows, these mismatches can be ignored +# http://stackoverflow.com/questions/4866425/mixing-class-and-struct. W +# warning so it doesn't become an error. +if use_clang: + env.Append(CCFLAGS=['-Wno-mismatched-tags']) + env.StaticLibrary( "s2", [ "s1angle.cc",