You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/06/04 01:20:03 UTC
[arrow] branch master updated: ARROW-2655: [C++] Fix compiler
warnings with gcc 7
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 5eaa3ab ARROW-2655: [C++] Fix compiler warnings with gcc 7
5eaa3ab is described below
commit 5eaa3abb19c3618de62ade9da9fd063d0eca3c78
Author: Wes McKinney <we...@apache.org>
AuthorDate: Sun Jun 3 21:19:52 2018 -0400
ARROW-2655: [C++] Fix compiler warnings with gcc 7
I experienced a couple warnings causing build failures with `-Wconversion -Werror` with gcc 7.3.0
Also fixes ARROW-2669
Author: Wes McKinney <we...@apache.org>
Closes #2095 from wesm/ARROW-2655 and squashes the following commits:
7a88c87a <Wes McKinney> Fix compiler warnings with gcc 7. Pass EP_CXX_FLAGS when building gbenchmark per ARROW-2669
---
cpp/CMakeLists.txt | 20 +++++---------------
cpp/cmake_modules/SetupCxxFlags.cmake | 29 ++++++++++++++++++++++-------
cpp/cmake_modules/ThirdpartyToolchain.cmake | 12 +++++++-----
cpp/src/arrow/util/bit-util-benchmark.cc | 2 +-
cpp/src/arrow/util/variant.h | 2 +-
python/CMakeLists.txt | 10 +++-------
6 files changed, 39 insertions(+), 36 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 0fd1007..d7bebf6 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -340,15 +340,11 @@ include(ThirdpartyToolchain)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}")
-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://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
- # http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CLANG_OPTIONS}")
-endif()
+# For any C code, use the same flags.
+set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
+
+# Add C++-only flags, like -std=c++11
+set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
# ASAN / TSAN / UBSAN
if(ARROW_FUZZING)
@@ -356,12 +352,6 @@ if(ARROW_FUZZING)
endif()
include(san-config)
-# For any C code, use the same flags.
-set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
-
-# Remove --std=c++11 to avoid errors from C compilers
-string(REPLACE "-std=c++11" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-
# Code coverage
if ("${ARROW_GENERATE_COVERAGE}")
if("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*")
diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index 6803127..41d2668 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -81,6 +81,10 @@ endif(NOT BUILD_WARNING_LEVEL)
string(TOUPPER ${BUILD_WARNING_LEVEL} UPPERCASE_BUILD_WARNING_LEVEL)
+if (NOT ("${COMPILER_FAMILY}" STREQUAL "msvc"))
+ set(CXX_ONLY_FLAGS "${CXX_ONLY_FLAGS} -std=c++11")
+endif()
+
if ("${UPPERCASE_BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
# Pre-checkin builds
if ("${COMPILER_FAMILY}" STREQUAL "msvc")
@@ -124,9 +128,11 @@ if ("${UPPERCASE_BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
# Treat all compiler warnings as errors
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unknown-warning-option -Werror")
elseif ("${COMPILER_FAMILY}" STREQUAL "gcc")
- set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wconversion -Wno-sign-conversion")
+ 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} -Wno-unknown-warning-option -Werror")
+ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Werror")
else()
message(FATAL_ERROR "Unknown compiler. Version info:\n${COMPILER_VERSION_FULL}")
endif()
@@ -172,8 +178,21 @@ if ("${COMPILER_FAMILY}" STREQUAL "msvc")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /wd4800")
endif()
-# Avoid clang error when an unknown warning flag is passed
+if ("${COMPILER_FAMILY}" STREQUAL "gcc")
+ # Without this, gcc >= 7 warns related to changes in C++17
+ set(CXX_ONLY_FLAGS "${CXX_ONLY_FLAGS} -Wno-noexcept-type")
+endif()
+
+# Clang options for all builds
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://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
+ # http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
+
+ # Avoid clang error when an unknown warning flag is passed
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unknown-warning-option")
endif()
@@ -184,10 +203,6 @@ if (BUILD_WARNING_FLAGS)
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
if (CXX_SUPPORTS_SSE3 AND ARROW_SSE3)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -msse3")
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 26ffd07..b3d3e70 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -22,7 +22,7 @@
set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty")
set(GFLAGS_VERSION "2.2.0")
set(GTEST_VERSION "1.8.0")
-set(GBENCHMARK_VERSION "1.1.0")
+set(GBENCHMARK_VERSION "1.4.1")
set(FLATBUFFERS_VERSION "1.9.0")
set(JEMALLOC_VERSION "17c897976c60b0e6e4f4a365c751027244dada7a")
set(SNAPPY_VERSION "1.1.3")
@@ -365,10 +365,12 @@ if(ARROW_BUILD_BENCHMARKS)
add_custom_target(runbenchmark ctest -L benchmark)
if("$ENV{GBENCHMARK_HOME}" STREQUAL "")
+ if(NOT MSVC)
+ set(GBENCHMARK_CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${EP_CXX_FLAGS}")
+ endif()
+
if(APPLE)
- set(GBENCHMARK_CMAKE_CXX_FLAGS "-fPIC -std=c++11 -stdlib=libc++")
- elseif(NOT MSVC)
- set(GBENCHMARK_CMAKE_CXX_FLAGS "-fPIC --std=c++11")
+ set(GBENCHMARK_CMAKE_CXX_FLAGS "${GBENCHMARK_CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
set(GBENCHMARK_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gbenchmark_ep/src/gbenchmark_ep-install")
@@ -477,7 +479,7 @@ endif()
if (ARROW_JEMALLOC)
# We only use a vendored jemalloc as we want to control its version.
- # Also our build of jemalloc is specially prefixed so that it will not
+ # Also our build of jemalloc is specially prefixed so that it will not
# conflict with the default allocator as well as other jemalloc
# installations.
# find_package(jemalloc)
diff --git a/cpp/src/arrow/util/bit-util-benchmark.cc b/cpp/src/arrow/util/bit-util-benchmark.cc
index 43f461c..ace19e9 100644
--- a/cpp/src/arrow/util/bit-util-benchmark.cc
+++ b/cpp/src/arrow/util/bit-util-benchmark.cc
@@ -171,7 +171,7 @@ static void BM_FirstTimeBitmapWriter(benchmark::State& state) {
}
static void BM_CopyBitmap(benchmark::State& state) { // NOLINT non-const reference
- const int kBufferSize = state.range(0);
+ const int kBufferSize = static_cast<int>(state.range(0));
std::shared_ptr<Buffer> buffer = CreateRandomBuffer(kBufferSize);
const int num_bits = kBufferSize * 8;
diff --git a/cpp/src/arrow/util/variant.h b/cpp/src/arrow/util/variant.h
index 33dedb6..3fcd18b 100644
--- a/cpp/src/arrow/util/variant.h
+++ b/cpp/src/arrow/util/variant.h
@@ -89,7 +89,7 @@ public:
}; // class bad_variant_access
#if !defined(ARROW_VARIANT_MINIMIZE_SIZE)
-using type_index_t = unsigned int;
+using type_index_t = std::size_t;
#else
#if defined(ARROW_VARIANT_OPTIMIZE_FOR_SPEED)
using type_index_t = std::uint_fast8_t;
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 01b7b54..2f6938b 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -124,13 +124,6 @@ else()
endif()
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://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
- # http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
-
# Cython warnings in clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses-equality")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constant-logical-operand")
@@ -144,6 +137,9 @@ endif()
# For any C code, use the same flags.
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
+# Add C++-only flags, like -std=c++11
+set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
+
if (MSVC)
# MSVC makes its own output directories based on the build configuration
set(BUILD_SUBDIR_NAME "")
--
To stop receiving notification emails like this one, please contact
wesm@apache.org.