arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1615 Added BUILD_WARNING_LEVEL and BUILD_WARNING_FLAGS to Setup…
Date Fri, 29 Sep 2017 20:29:43 GMT
Repository: arrow
Updated Branches:
  refs/heads/master f8cf91d25 -> d4e09c765


ARROW-1615 Added BUILD_WARNING_LEVEL and BUILD_WARNING_FLAGS to Setup…

…CxxFlags.cmake

Author: Rene Sugar <rene.sugar@gmail.com>

Closes #1145 from renesugar/ARROW-1615 and squashes the following commits:

71a615e3 [Rene Sugar] ARROW-1615 Add -Wno-vla-extension and change non-checkin builds back
to -Wall
18958430 [Rene Sugar] ARROW-1615 Add -Wno-cast-align
5fe4e8e8 [Rene Sugar] ARROW-1615 Move -Wno-shorten-64-to-32 after -Wconversion
9d3c7ec3 [Rene Sugar] ARROW-1615 Identify compiler version for clang-802 plus more warning
entries
5ebaf86e [Rene Sugar] ARROW-1615 Moved version specific warning entry
971e61aa [Rene Sugar] ARROW-1615 Fixed version specific warning entry
6cf24977 [Rene Sugar] ARROW-1615 Added more version specific Clang warning entries
50def439 [Rene Sugar] ARROW-1615 Updated build warning level terminology
ea906eb4 [Rene Sugar] ARROW-1615 Check compiler version before disabling some warnings
159e1897 [Rene Sugar] ARROW-1615 Include CompilerInfo before SetupCxxFlags in arrow/python
8359c966 [Rene Sugar] ARROW-1615 Added BUILD_WARNING_LEVEL and BUILD_WARNING_FLAGS to SetupCxxFlags.cmake


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/d4e09c76
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/d4e09c76
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/d4e09c76

Branch: refs/heads/master
Commit: d4e09c7654030f459f57d330bec639699eadcef6
Parents: f8cf91d
Author: Rene Sugar <rene.sugar@gmail.com>
Authored: Fri Sep 29 15:29:38 2017 -0500
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Fri Sep 29 15:29:38 2017 -0500

----------------------------------------------------------------------
 cpp/CMakeLists.txt                    |   6 +-
 cpp/cmake_modules/CompilerInfo.cmake  |   5 ++
 cpp/cmake_modules/SetupCxxFlags.cmake | 105 ++++++++++++++++++++++++++++-
 python/CMakeLists.txt                 |   2 +-
 4 files changed, 113 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/d4e09c76/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 972132f..ad99970 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -229,6 +229,9 @@ include(BuildUtils)
 # Compiler flags
 ############################################################
 
+# Determine compiler version
+include(CompilerInfo)
+
 if (ARROW_NO_DEPRECATED_API)
   add_definitions(-DARROW_NO_DEPRECATED_API)
 endif()
@@ -253,9 +256,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}")
 
 message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
 
-# Determine compiler version
-include(CompilerInfo)
-
 if ("${COMPILER_FAMILY}" STREQUAL "clang")
   # Using Clang with ccache causes a bunch of spurious warnings that are
   # purportedly fixed in the next version of ccache. See the following for details:

http://git-wip-us.apache.org/repos/asf/arrow/blob/d4e09c76/cpp/cmake_modules/CompilerInfo.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/CompilerInfo.cmake b/cpp/cmake_modules/CompilerInfo.cmake
index a1b4701..5ff1d86 100644
--- a/cpp/cmake_modules/CompilerInfo.cmake
+++ b/cpp/cmake_modules/CompilerInfo.cmake
@@ -64,6 +64,11 @@ elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang-7")
   set(COMPILER_VERSION "3.7.0svn")
 
 # clang on Mac OS X, XCode 8.
+elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang-802")
+  set(COMPILER_FAMILY "clang")
+  set(COMPILER_VERSION "3.9.0svn")
+
+# clang on Mac OS X, XCode 8.
 elseif("${COMPILER_VERSION_FULL}" MATCHES ".*clang-8")
   set(COMPILER_FAMILY "clang")
   set(COMPILER_VERSION "3.8.0svn")

http://git-wip-us.apache.org/repos/asf/arrow/blob/d4e09c76/cpp/cmake_modules/SetupCxxFlags.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index 6e92c4b..1f4c898 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -48,7 +48,110 @@ if (MSVC)
     set(CXX_COMMON_FLAGS "/W3")
   endif()
 else()
-  set(CXX_COMMON_FLAGS "-Wall -std=c++11")
+  # Common flags set below with warning level
+  set(CXX_COMMON_FLAGS "")
+endif()
+
+# Build warning level (CHECKIN, EVERYTHING, etc.)
+
+# if no build warning level is specified, default to development warning level
+if (NOT BUILD_WARNING_LEVEL)
+  set(BUILD_WARNING_LEVEL Production)
+endif(NOT BUILD_WARNING_LEVEL)
+
+string(TOUPPER ${BUILD_WARNING_LEVEL} UPPERCASE_BUILD_WARNING_LEVEL)
+
+if ("${UPPERCASE_BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
+  # Pre-checkin builds
+  if ("${COMPILER_FAMILY}" STREQUAL "msvc")
+    string(REPLACE "/W3" "" CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS}")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /W3")
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /WX")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "clang")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Weverything -Wno-c++98-compat \
+    -Wno-c++98-compat-pedantic -Wno-deprecated -Wno-weak-vtables -Wno-padded \
+    -Wno-unused-parameter -Wno-undef -Wno-documentation-deprecated-sync \
+    -Wno-shadow -Wno-switch-enum -Wno-documentation -Wno-exit-time-destructors \
+    -Wno-global-constructors -Wno-weak-template-vtables -Wno-undefined-reinterpret-cast \
+    -Wno-implicit-fallthrough -Wno-old-style-cast -Wno-unreachable-code-return \
+    -Wno-float-equal -Wno-missing-prototypes -Wno-non-virtual-dtor \
+    -Wno-unused-macros -Wno-covered-switch-default -Wno-unreachable-code-break \
+    -Wno-extra-semi -Wno-cast-align -Wno-vla-extension -Wno-shift-sign-overflow \
+    -Wno-used-but-marked-unused -Wno-missing-variable-declarations \
+    -Wno-gnu-zero-variadic-macro-arguments -Wconversion -Wno-sign-conversion \
+    -Wno-disabled-macro-expansion -Wc++11-narrowing -Wnarrowing -Wno-shorten-64-to-32")
+
+    # Version numbers where warnings are introduced
+    if ("${COMPILER_VERSION}" VERSION_GREATER "3.3")
+      set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-gnu-folding-constant")
+    endif()
+    if ("${COMPILER_VERSION}" VERSION_GREATER "3.6")
+      set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-reserved-id-macro")
+      set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-range-loop-analysis")
+    endif()
+    if ("${COMPILER_VERSION}" VERSION_GREATER "3.7")
+      set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-double-promotion")
+    endif()
+    if ("${COMPILER_VERSION}" VERSION_GREATER "3.8")
+      set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-undefined-func-template")
+    endif()
+
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wunknown-warning-option -Werror")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "gcc")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wconversion -Wno-sign-conversion")
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wunknown-warning-option -Werror")
+  else()
+    message(FATAL_ERROR "Unknown compiler. Version info:\n${COMPILER_VERSION_FULL}")
+  endif()
+elseif ("${UPPERCASE_BUILD_WARNING_LEVEL}" STREQUAL "EVERYTHING")
+  # Pedantic builds for fixing warnings
+  if ("${COMPILER_FAMILY}" STREQUAL "msvc")
+    string(REPLACE "/W3" "" CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS}")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /Wall")
+    # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
+    # /wdnnnn disables a warning where "nnnn" is a warning number
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS}  /WX")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "clang")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic")
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Werror")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "gcc")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wpedantic -Wextra -Wno-unused-parameter")
+    # Treat all compiler warnings as errors
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Werror")
+  else()
+    message(FATAL_ERROR "Unknown compiler. Version info:\n${COMPILER_VERSION_FULL}")
+  endif()
+else()
+  # Production builds (warning are not treated as errors)
+  if ("${COMPILER_FAMILY}" STREQUAL "msvc")
+    # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
+    # TODO: Enable /Wall and disable individual warnings until build compiles without errors
+    # /wdnnnn disables a warning where "nnnn" is a warning number
+    string(REPLACE "/W3" "" CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS}")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /W3")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "clang")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall")
+  elseif ("${COMPILER_FAMILY}" STREQUAL "gcc")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall")
+  else()
+    message(FATAL_ERROR "Unknown compiler. Version info:\n${COMPILER_VERSION_FULL}")
+  endif()
+endif()
+
+# if build warning flags is set, add to CXX_COMMON_FLAGS
+if (BUILD_WARNING_FLAGS)
+  # Use BUILD_WARNING_FLAGS with BUILD_WARNING_LEVEL=everything to disable
+  # warnings (use with Clang's -Weverything flag to find potential errors)
+  set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} ${BUILD_WARNING_FLAGS}")
+endif(BUILD_WARNING_FLAGS)
+
+if (NOT ("${COMPILER_FAMILY}" STREQUAL "msvc"))
+set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=c++11")
 endif()
 
 # Only enable additional instruction sets if they are supported

http://git-wip-us.apache.org/repos/asf/arrow/blob/d4e09c76/python/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index a636d51..d148d11 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -72,8 +72,8 @@ endif(CCACHE_FOUND)
 ############################################################
 
 include(BuildUtils)
-include(SetupCxxFlags)
 include(CompilerInfo)
+include(SetupCxxFlags)
 
 # Add common flags
 set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")


Mime
View raw message