This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new e432e63  [build] Support and require C++17
e432e63 is described below

commit e432e637e282ba87d41c02088a801f0838571edc
Author: Grant Henke <[email protected]>
AuthorDate: Mon Nov 23 09:58:01 2020 -0600

    [build] Support and require C++17
    
    This patch adjust the build to start supporting and requiring C++17
    (therefore GCC 7+). It adjusts the documentation and supported
    OS matrix to match the new requirements as well.
    
    I needed to replace std::random_shuffle with std::shuffle.
    In C++14 `std::random_shuffle` is deprectated and in C++17 it is
    removed all together. This patch replaces `std::random_shuffle` with
    `std::shuffle` passing in a generator.
    
    Additionally I needed to patch libev due to a small C++17 incompatibility:
    https://github.com/enki/libev/pull/8
    
    Change-Id: I15312473bda8c743eac228cd23c337fae5acf99d
    Reviewed-on: http://gerrit.cloudera.org:8080/16776
    Reviewed-by: Attila Bukor <[email protected]>
    Tested-by: Grant Henke <[email protected]>
---
 CMakeLists.txt                                     | 20 +++---------
 README.adoc                                        |  4 +--
 .../c++                                            |  4 +--
 .../cc                                             |  4 +--
 build-support/enable_devtoolset.sh                 |  5 ++-
 build-support/enable_devtoolset_inner.sh           |  6 ++--
 build-support/ubsan-blacklist.txt                  |  6 ++++
 docker/Dockerfile                                  |  2 +-
 docker/bootstrap-dev-env.sh                        | 12 +++----
 docs/installation.adoc                             | 36 ++++++++++-----------
 src/kudu/benchmarks/wal_hiccup.cc                  |  5 ++-
 src/kudu/client/client-test.cc                     |  4 ++-
 src/kudu/client/predicate-test.cc                  | 16 +++++++---
 src/kudu/client/symbols.map                        |  4 +--
 src/kudu/common/wire_protocol-test.cc              |  4 ++-
 src/kudu/fs/log_block_manager-test.cc              |  4 ++-
 src/kudu/integration-tests/all_types-itest.cc      |  4 ++-
 src/kudu/integration-tests/ts_itest-base.cc        |  4 ++-
 src/kudu/master/catalog_manager.cc                 |  1 -
 src/kudu/tablet/compaction-test.cc                 | 12 ++++---
 src/kudu/tablet/tablet.cc                          |  6 ++--
 src/kudu/transactions/txn_status_manager-test.cc   |  4 ++-
 src/kudu/tserver/tablet_server-test.cc             |  7 ++--
 thirdparty/build-definitions.sh                    |  2 +-
 thirdparty/build-thirdparty.sh                     |  2 +-
 thirdparty/download-thirdparty.sh                  |  5 +--
 thirdparty/patches/libev-c17.patch                 | 37 ++++++++++++++++++++++
 thirdparty/preflight.py                            | 18 +++++------
 28 files changed, 145 insertions(+), 93 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index aeccb9a..7d75ea8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -311,22 +311,12 @@ if ("${COMPILER_FAMILY}" STREQUAL "clang")
     message("Running without a controlling terminal or in a dumb terminal")
   endif()
 elseif("${COMPILER_FAMILY}" STREQUAL "gcc")
-  # Disallow GCC < 4.8, since it doesn't support the C++11 standard
-  # well enough for us.
-  if ("${COMPILER_VERSION}" VERSION_LESS "4.8")
-    message(FATAL_ERROR "GCC <4.8 not supported. Consider using "
+  # Disallow GCC < 7.0, since it doesn't support the C++17 standard
+  # well enough for us. https://en.cppreference.com/w/cpp/compiler_support
+  if ("${COMPILER_VERSION}" VERSION_LESS "7.0")
+    message(FATAL_ERROR "GCC <7.0 not supported. Consider using "
         "thirdparty/clang-toolchain/ to build on older hosts.")
   endif()
-
-  # GCC 4.8's tree vectorizer has a bug which causes hard-to-debug incorrect
-  # code. Disable this option on release builds, where it would otherwise
-  # be enabled by -O3.
-  if ("${COMPILER_VERSION}" MATCHES "^4.8" AND
-      "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
-    message("Running release build on gcc 4.8. The tree-vectorize optimization 
"
-      "in this version of gcc is known to be buggy. Disabling it.")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vectorize")
-  endif()
 endif()
 
 # Sanity check linking option.
@@ -370,7 +360,7 @@ endif()
 
 # For any C code, use the same flags.
 set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
 
 # Enable the Clang undefined behavior (UB) sanitizer.
 if (${KUDU_USE_UBSAN})
diff --git a/README.adoc b/README.adoc
index 4603a9f..ac6962b 100644
--- a/README.adoc
+++ b/README.adoc
@@ -418,7 +418,7 @@ Eclipse can be used as an IDE for Kudu. To generate Eclipse 
project files, run:
 $ mkdir -p <sibling directory to source tree>
 $ cd <sibling directory to source tree>
 $ rm -rf CMakeCache.txt CMakeFiles/
-$ cmake -G "Eclipse CDT4 - Unix Makefiles" 
-DCMAKE_CXX_COMPILER_ARG1=-std=c++11 <source tree>
+$ cmake -G "Eclipse CDT4 - Unix Makefiles" 
-DCMAKE_CXX_COMPILER_ARG1=-std=c++17 <source tree>
 ----
 
 When the Eclipse generator is run in a subdirectory of the source tree, the
@@ -429,7 +429,7 @@ It's critical that _CMakeCache.txt_ be removed prior to 
running the generator,
 otherwise the extra Eclipse generator logic (the CMakeFindEclipseCDT4.make 
module)
 won't run and standard system includes will be missing from the generated 
project.
 
-Thanks to [2], the Eclipse generator ignores the `-std=c++11` definition and 
we must
+Thanks to [2], the Eclipse generator ignores the `-std=c++17` definition and 
we must
 add it manually on the command line via `CMAKE_CXX_COMPILER_ARG1`.
 
 By default, the Eclipse CDT indexer will index everything under the _kudu/_
diff --git a/build-support/ccache-devtoolset-3/c++ 
b/build-support/ccache-devtoolset-8/c++
similarity index 87%
rename from build-support/ccache-devtoolset-3/c++
rename to build-support/ccache-devtoolset-8/c++
index 522ab6a..9a59cd4 100755
--- a/build-support/ccache-devtoolset-3/c++
+++ b/build-support/ccache-devtoolset-8/c++
@@ -16,6 +16,6 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Helper script that invokes devtoolset-3's c++ via ccache.
+# Helper script that invokes devtoolset-8's c++ via ccache.
 
-exec ccache /opt/rh/devtoolset-3/root/usr/bin/c++ "$@"
+exec ccache /opt/rh/devtoolset-8/root/usr/bin/c++ "$@"
diff --git a/build-support/ccache-devtoolset-3/cc 
b/build-support/ccache-devtoolset-8/cc
similarity index 87%
rename from build-support/ccache-devtoolset-3/cc
rename to build-support/ccache-devtoolset-8/cc
index b93ab8e..c0a618e 100755
--- a/build-support/ccache-devtoolset-3/cc
+++ b/build-support/ccache-devtoolset-8/cc
@@ -16,6 +16,6 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Helper script that invokes devtoolset-3's c++ via ccache.
+# Helper script that invokes devtoolset-8's c++ via ccache.
 
-exec ccache /opt/rh/devtoolset-3/root/usr/bin/cc "$@"
+exec ccache /opt/rh/devtoolset-8/root/usr/bin/cc "$@"
diff --git a/build-support/enable_devtoolset.sh 
b/build-support/enable_devtoolset.sh
index a331c33..6e1b6bd 100755
--- a/build-support/enable_devtoolset.sh
+++ b/build-support/enable_devtoolset.sh
@@ -23,13 +23,12 @@
 # USAGE: ./enable_devtoolset.sh <command> <args>...
 
 set -e
-
 if [[ "$OSTYPE" =~ ^linux ]] && \
-   [[ "$(lsb_release -irs)" =~ 
(CentOS|RedHatEnterpriseServer)[[:space:]]+6\.[[:digit:]]+ ]]; then
+   [[ "$(lsb_release -irs)" =~ 
(CentOS|RedHatEnterpriseServer)[[:space:]]+7\.[[:digit:]]+ ]]; then
   # Invoke the inner script, which may do some additional customization within
   # the devtoolset.
   ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd)
-  scl enable devtoolset-3 "$ROOT/enable_devtoolset_inner.sh $*"
+  scl enable devtoolset-8 "$ROOT/enable_devtoolset_inner.sh $*"
 else
   $@
 fi
diff --git a/build-support/enable_devtoolset_inner.sh 
b/build-support/enable_devtoolset_inner.sh
index 0b0ba91..eb8a42d 100755
--- a/build-support/enable_devtoolset_inner.sh
+++ b/build-support/enable_devtoolset_inner.sh
@@ -24,11 +24,11 @@
 set -e
 
 # If ccache was on the PATH and CC/CXX have not already been set, set them to
-# devtoolset-3 specific ccache helper scripts (thus enabling ccache).
+# devtoolset-8 specific ccache helper scripts (thus enabling ccache).
 if which ccache > /dev/null 2>&1 && [ ! "$CC" -a ! "$CXX" ]; then
   ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd)
-  export CC="$ROOT/ccache-devtoolset-3/cc"
-  export CXX="$ROOT/ccache-devtoolset-3/c++"
+  export CC="$ROOT/ccache-devtoolset-8/cc"
+  export CXX="$ROOT/ccache-devtoolset-8/c++"
 fi
 
 # Execute the arguments.
diff --git a/build-support/ubsan-blacklist.txt 
b/build-support/ubsan-blacklist.txt
index 4140431..6e4697c 100644
--- a/build-support/ubsan-blacklist.txt
+++ b/build-support/ubsan-blacklist.txt
@@ -54,3 +54,9 @@ src:*/google/protobuf/parse_context.h
 # Sparsepp has an unsigned-integer negation overflow:
 # /include/sparsepp/spp.h:1196:20: runtime error: negation of 8192 cannot be 
represented in type 'group_bm_type' (aka 'unsigned int')
 src:*/sparsepp/spp.h
+
+# libstdc++'s basic_string implementation has unsigned-integer overflows
+# bits/basic_string.h:392:51: runtime error: unsigned integer overflow: 4 - 17 
cannot be represented in type 'unsigned long'
+# bits/basic_string.tcc:1271:25: runtime error: unsigned integer overflow: 0 - 
1 cannot be represented in type 'unsigned long'
+src:*/bits/basic_string.h
+src:*/bits/basic_string.tcc
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 1bc1bd1..b9eecc4 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -128,7 +128,7 @@ COPY --chown=kudu:kudu ./build-support/enable_devtoolset.sh 
\
   ./build-support/enable_devtoolset_inner.sh \
   build-support/
 COPY --chown=kudu:kudu ./build-support/ccache-clang build-support/ccache-clang
-COPY --chown=kudu:kudu ./build-support/ccache-devtoolset-3 
build-support/ccache-devtoolset-3
+COPY --chown=kudu:kudu ./build-support/ccache-devtoolset-8 
build-support/ccache-devtoolset-8
 # We explicitly set UID/GID due to https://github.com/moby/buildkit/issues/1237
 # Hard coded UID/GID are required due to 
https://github.com/moby/buildkit/issues/815
 RUN --mount=type=cache,id=ccache,uid=1000,gid=1000,target=/home/kudu/.ccache \
diff --git a/docker/bootstrap-dev-env.sh b/docker/bootstrap-dev-env.sh
index 14c1a06..aa725af 100755
--- a/docker/bootstrap-dev-env.sh
+++ b/docker/bootstrap-dev-env.sh
@@ -97,13 +97,11 @@ if [[ -f "/usr/bin/yum" ]]; then
   #  ruby-devel \
   #  zlib-devel
 
-  # To build on a version older than 7.0, the Red Hat Developer Toolset
-  # must be installed (in order to have access to a C++11 capable compiler).
-  if [[ "$OS_MAJOR_VERSION" -lt "7" ]]; then
-    
DTLS_REPO_URL=https://copr.fedorainfracloud.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo
-    yum install -y scl-utils yum-utils
-    yum-config-manager --add-repo=${DTLS_REPO_URL}
-    yum install -y devtoolset-3-toolchain
+  # To build on a version older than 8.0, the Red Hat Developer Toolset
+  # must be installed (in order to have access to a C++17 capable compiler).
+  if [[ "$OS_MAJOR_VERSION" -lt "8" ]]; then
+    yum install -y centos-release-scl-rh
+    yum install -y devtoolset-8
   fi
 
   # Reduce the image size by cleaning up after the install.
diff --git a/docs/installation.adoc b/docs/installation.adoc
index 5f6c48e..0cf233d 100644
--- a/docs/installation.adoc
+++ b/docs/installation.adoc
@@ -45,21 +45,20 @@ only tolerate a single failure; two-master deployments 
cannot tolerate any failu
 
 .Operating System Requirements
 Linux::
-    - RHEL 6, RHEL 7, RHEL 8, CentOS 6, CentOS 7, CentOS 8,
-      Ubuntu 14.04 (trusty), Ubuntu 16.04 (xenial), Ubuntu 18.04 (bionic),
-      Debian 8 (Jessie), or SLES 12.
+    - RHEL 7, RHEL 8, CentOS 7, CentOS 8,
+      Ubuntu 18.04 (bionic), Ubuntu 20.04 (focal)
     - A kernel and filesystem that support _hole punching_. Hole punching is 
the use of the
       `fallocate(2)` system call with the `FALLOC_FL_PUNCH_HOLE` option set. 
See
       link:troubleshooting.html#req_hole_punching[troubleshooting hole 
punching] for more
       information.
-    - ntp.
+    - ntp or chrony.
     - xfs or ext4 formatted drives.
     - Although not a strict requirement, it's highly recommended to use `nscd`
       to cache both DNS name resolution and static name resolution. See
       link:troubleshooting.html#slow_dns_nscd[troubleshooting slow DNS lookups]
       for more information.
 macOS::
-    - OS X 10.10 Yosemite, OS X 10.11 El Capitan, macOS Sierra, or macOS High 
Sierra.
+    - macOS 10.13 (High Sierra), macOS 10.14 (Mojave), macOS 10.15 (Catalina)
 Windows::
     - Microsoft Windows is unsupported.
 
@@ -81,14 +80,14 @@ Below are the steps for each supported operating system to 
build Kudu from  sour
 .Known Build Issues
 ====
 * It is not possible to build Kudu on Microsoft Windows.
-* A C++11 capable compiler (GCC 4.8+) is required.
+* A C++17 capable compiler (GCC 7.0+) is required.
 ====
 
 [[rhel_from_source]]
 === RHEL or CentOS
-RHEL or CentOS 6.6 or later is required to build Kudu from source. To build
-on a version older than 7.0, the Red Hat Developer Toolset must be installed
-(in order to have access to a C++11 capable compiler).
+RHEL or CentOS 7.6 or later is required to build Kudu from source. To build
+on a version older than 8.0, the Red Hat Developer Toolset must be installed
+(in order to have access to a C++17 capable compiler).
 
 . Install the prerequisite libraries, if they are not installed.
 +
@@ -99,14 +98,13 @@ $ sudo yum install autoconf automake cyrus-sasl-devel 
cyrus-sasl-gssapi \
   pkgconfig redhat-lsb-core rsync unzip vim-common which
 ----
 
-. If building on RHEL or CentOS older than 7.0, install the Red Hat Developer
-Toolset.
+. If building on RHEL or CentOS older than 8.0, install the Red Hat Developer 
Toolset.
+. Below are the steps required for CentOS. If you are on RHEL, follow their 
documentation
+. [here:https://developers.redhat.com/products/developertoolset/hello-world].
 +
 ----
-$ 
DTLS_REPO_URL=https://copr.fedorainfracloud.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo
-$ sudo yum install -y scl-utils yum-utils
-$ sudo yum-config-manager --add-repo=${DTLS_REPO_URL}
-$ sudo yum install -y devtoolset-3-toolchain
+$ sudo yum install centos-release-scl-rh
+$ sudo yum install devtoolset-8
 ----
 
 . Optional: If support for Kudu's NVM (non-volatile memory) block cache is
@@ -160,7 +158,7 @@ $ build-support/enable_devtoolset.sh 
thirdparty/build-if-necessary.sh
 . Build Kudu, using the utilities installed in the previous step. Choose a 
build
 directory for the intermediate output, which can be anywhere in your filesystem
 except for the `kudu` directory itself. Notice that the devtoolset must still 
be specified,
-else you'll get `cc1plus: error: unrecognized command line option 
"-std=c++11"`.
+else you'll get `cc1plus: error: unrecognized command line option 
"-std=c++17"`.
 +
 [source,bash]
 ----
@@ -234,10 +232,8 @@ sudo yum -y install autoconf automake curl 
cyrus-sasl-devel cyrus-sasl-gssapi \
   cyrus-sasl-plain flex gcc gcc-c++ gdb git java-1.8.0-openjdk-devel \
   krb5-server krb5-workstation libtool make openssl-devel patch pkgconfig \
   redhat-lsb-core rsync unzip vim-common which
-DTLS_REPO_URL=https://copr.fedorainfracloud.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo
-sudo yum install -y scl-utils yum-utils
-sudo yum-config-manager --add-repo=${DTLS_REPO_URL}
-sudo yum install -y devtoolset-3-toolchain
+sudo yum -y install centos-release-scl-rh
+sudo yum -y install devtoolset-8
 git clone https://github.com/apache/kudu
 cd kudu
 build-support/enable_devtoolset.sh thirdparty/build-if-necessary.sh
diff --git a/src/kudu/benchmarks/wal_hiccup.cc 
b/src/kudu/benchmarks/wal_hiccup.cc
index 03d9d6a..347d4fe 100644
--- a/src/kudu/benchmarks/wal_hiccup.cc
+++ b/src/kudu/benchmarks/wal_hiccup.cc
@@ -22,6 +22,7 @@
 #include <cstdint>
 #include <cstring>
 #include <ostream>
+#include <random>
 #include <string>
 #include <thread>
 #include <vector>
@@ -172,9 +173,11 @@ void WalHiccupBenchmarker::Run() {
     setups.push_back(setup);
   }
 
+  std::random_device rdev;
+  std::mt19937 gen(rdev());
   for (int round = 0; round < FLAGS_num_rounds; round++) {
     // Randomize the order of setups in each round.
-    std::random_shuffle(setups.begin(), setups.end());
+    std::shuffle(setups.begin(), setups.end(), gen);
 
     for (uint32_t setup : setups) {
       SetFlags(setup);
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index cb9114e..64bb791 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -29,6 +29,7 @@
 #include <memory>
 #include <mutex>
 #include <ostream>
+#include <random>
 #include <set>
 #include <string>
 #include <thread>
@@ -7296,7 +7297,8 @@ TEST_F(ClientTest, TestProjectionPredicatesFuzz) {
   Random rng(SeedRandom());
   vector<string> projected_col_names =
       SelectRandomSubset<vector<string>, string, Random>(all_col_names, 0, 
&rng);
-  std::random_shuffle(projected_col_names.begin(), projected_col_names.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(projected_col_names.begin(), projected_col_names.end(), gen);
   ASSERT_OK(scanner->SetProjectedColumnNames(projected_col_names));
 
   // Insert some rows with randomized keys, flushing the tablet periodically.
diff --git a/src/kudu/client/predicate-test.cc 
b/src/kudu/client/predicate-test.cc
index af59474..b91c363 100644
--- a/src/kudu/client/predicate-test.cc
+++ b/src/kudu/client/predicate-test.cc
@@ -25,6 +25,7 @@
 #include <limits>
 #include <memory>
 #include <ostream>
+#include <random>
 #include <string>
 #include <type_traits>
 #include <unordered_set>
@@ -473,7 +474,8 @@ class PredicateTest : public KuduTest {
     }
 
     // IN list and IN Bloom filter predicates
-    std::random_shuffle(test_values.begin(), test_values.end());
+    std::mt19937 gen(SeedRandom());
+    std::shuffle(test_values.begin(), test_values.end(), gen);
 
     for (auto end = test_values.begin(); end <= test_values.end(); end++) {
       vector<KuduValue*> vals;
@@ -592,7 +594,8 @@ class PredicateTest : public KuduTest {
     }
 
     // IN list and IN Bloom filter predicates
-    std::random_shuffle(test_values.begin(), test_values.end());
+    std::mt19937 gen(SeedRandom());
+    std::shuffle(test_values.begin(), test_values.end(), gen);
 
     for (auto end = test_values.begin(); end <= test_values.end(); end++) {
       vector<KuduValue*> vals;
@@ -1027,7 +1030,8 @@ TEST_F(PredicateTest, TestFloatPredicates) {
   }
 
   // IN list and IN Bloom filter predicates
-  std::random_shuffle(test_values.begin(), test_values.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(test_values.begin(), test_values.end(), gen);
 
   for (auto end = test_values.begin(); end <= test_values.end(); end++) {
     vector<KuduValue*> vals;
@@ -1157,7 +1161,8 @@ TEST_F(PredicateTest, TestDoublePredicates) {
   }
 
   // IN list and IN Bloom filter predicates
-  std::random_shuffle(test_values.begin(), test_values.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(test_values.begin(), test_values.end(), gen);
 
   for (auto end = test_values.begin(); end <= test_values.end(); end++) {
     vector<KuduValue*> vals;
@@ -1305,7 +1310,8 @@ TEST_F(PredicateTest, TestDecimalPredicates) {
   }
 
   // IN list and IN Bloom filter predicates
-  std::random_shuffle(test_values.begin(), test_values.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(test_values.begin(), test_values.end(), gen);
 
   for (auto end = test_values.begin(); end <= test_values.end(); end++) {
     vector<KuduValue*> vals;
diff --git a/src/kudu/client/symbols.map b/src/kudu/client/symbols.map
index b3af391..9c25d64 100644
--- a/src/kudu/client/symbols.map
+++ b/src/kudu/client/symbols.map
@@ -43,9 +43,9 @@
       crcutil::*;
       crcutil_interface::*;
 
-      # devtoolset - the Red Hat devtoolset statically links c++11 symbols
+      # devtoolset - the Red Hat devtoolset statically links c++17 symbols
       # into binaries so that the result may be executed on a system with an
-      # older libstdc++ which doesn't include the necessary c++11 symbols.
+      # older libstdc++ which doesn't include the necessary c++17 symbols.
       std::*;
     };
 };
diff --git a/src/kudu/common/wire_protocol-test.cc 
b/src/kudu/common/wire_protocol-test.cc
index ba391a8..ca53b0e 100644
--- a/src/kudu/common/wire_protocol-test.cc
+++ b/src/kudu/common/wire_protocol-test.cc
@@ -23,6 +23,7 @@
 #include <list>
 #include <numeric>
 #include <ostream>
+#include <random>
 #include <string>
 #include <vector>
 
@@ -557,7 +558,8 @@ class WireProtocolBenchmark :
     } else {
       vector<int> indexes(block->nrows());
       std::iota(indexes.begin(), indexes.end(), 0);
-      std::random_shuffle(indexes.begin(), indexes.end());
+      std::mt19937 gen(SeedRandom());
+      std::shuffle(indexes.begin(), indexes.end(), gen);
       indexes.resize(select_count);
       select_vector->SetAllFalse();
       for (auto index : indexes) {
diff --git a/src/kudu/fs/log_block_manager-test.cc 
b/src/kudu/fs/log_block_manager-test.cc
index 0bf9cd3..28fee93 100644
--- a/src/kudu/fs/log_block_manager-test.cc
+++ b/src/kudu/fs/log_block_manager-test.cc
@@ -26,6 +26,7 @@
 #include <initializer_list>
 #include <memory>
 #include <ostream>
+#include <random>
 #include <set>
 #include <string>
 #include <unordered_map>
@@ -1649,7 +1650,8 @@ TEST_F(LogBlockManagerTest, 
TestDeleteFromContainerAfterMetadataCompaction) {
   // files which have just been compacted. Since we have more metadata files 
than
   // we have file_cache capacity, this will also generate a mix of cache hits,
   // misses, and re-insertions.
-  std::random_shuffle(block_ids.begin(), block_ids.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(block_ids.begin(), block_ids.end(), gen);
   {
     shared_ptr<BlockDeletionTransaction> deletion_transaction =
         this->bm_->NewDeletionTransaction();
diff --git a/src/kudu/integration-tests/all_types-itest.cc 
b/src/kudu/integration-tests/all_types-itest.cc
index 3b0b9d5..40831b1 100644
--- a/src/kudu/integration-tests/all_types-itest.cc
+++ b/src/kudu/integration-tests/all_types-itest.cc
@@ -20,6 +20,7 @@
 #include <functional>
 #include <memory>
 #include <ostream>
+#include <random>
 #include <string>
 #include <utility>
 #include <vector>
@@ -681,7 +682,8 @@ TYPED_TEST(AllTypesItest, TestTimestampPadding) {
     // Each time this function is called we shuffle the projection to get the 
chance
     // of having timestamps in different places of the projection and 
before/after
     // different types.
-    std::random_shuffle(projection.begin(), projection.end());
+    std::mt19937 gen(SeedRandom());
+    std::shuffle(projection.begin(), projection.end(), gen);
     RETURN_NOT_OK(scanner->SetProjectedColumnNames(projection));
     int row_format_flags = KuduScanner::NO_FLAGS;
     row_format_flags |= KuduScanner::PAD_UNIXTIME_MICROS_TO_16_BYTES;
diff --git a/src/kudu/integration-tests/ts_itest-base.cc 
b/src/kudu/integration-tests/ts_itest-base.cc
index 4386f5d..2e6f742 100644
--- a/src/kudu/integration-tests/ts_itest-base.cc
+++ b/src/kudu/integration-tests/ts_itest-base.cc
@@ -20,6 +20,7 @@
 #include <algorithm>
 #include <memory>
 #include <ostream>
+#include <random>
 #include <set>
 #include <string>
 #include <unordered_map>
@@ -267,7 +268,8 @@ TServerDetails* 
TabletServerIntegrationTestBase::GetLeaderReplicaOrNull(
     replicas_copy.push_back((*range.first).second);
   }
 
-  std::random_shuffle(replicas_copy.begin(), replicas_copy.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(replicas_copy.begin(), replicas_copy.end(), gen);
   for (TServerDetails* replica : replicas_copy) {
     if (itest::GetReplicaStatusAndCheckIfLeader(
           replica, tablet_id, MonoDelta::FromMilliseconds(100)).ok()) {
diff --git a/src/kudu/master/catalog_manager.cc 
b/src/kudu/master/catalog_manager.cc
index e7211fb..5bad51c 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -60,7 +60,6 @@
 
 #include <boost/optional/optional.hpp>
 #include <boost/optional/optional_io.hpp> // IWYU pragma: keep
-#include <boost/type_traits/decay.hpp>
 #include <gflags/gflags.h>
 #include <glog/logging.h>
 #include <google/protobuf/arena.h>
diff --git a/src/kudu/tablet/compaction-test.cc 
b/src/kudu/tablet/compaction-test.cc
index 5e5cf44..4788ee2 100644
--- a/src/kudu/tablet/compaction-test.cc
+++ b/src/kudu/tablet/compaction-test.cc
@@ -24,6 +24,7 @@
 #include <memory>
 #include <numeric>
 #include <ostream>
+#include <random>
 #include <string>
 #include <thread>
 #include <vector>
@@ -660,9 +661,9 @@ TEST_F(TestCompaction, TestDuplicatedGhostRowsMerging) {
   all_rss.push_back(rs1);
   all_rss.push_back(rs2);
 
-  SeedRandom();
   // Shuffle the row sets to make sure we test different orderings
-  std::random_shuffle(all_rss.begin(), all_rss.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(all_rss.begin(), all_rss.end(), gen);
 
   // Now compact all the drs and make sure we don't get duplicated keys on the 
output
   CompactAndReopenNoRoll(all_rss, schema_, &result);
@@ -844,7 +845,8 @@ TEST_F(TestCompaction, TestDuplicatedRowsRandomCompaction) {
 
   // Compact the row sets by picking a few at random until we're left with 
just one.
   while (row_sets.size() > 1) {
-    std::random_shuffle(row_sets.begin(), row_sets.end());
+    std::mt19937 gen(SeedRandom());
+    std::shuffle(row_sets.begin(), row_sets.end(), gen);
     // Merge between 2 and 4 row sets.
     int num_rowsets_to_merge = std::min(rand() % 3 + 2, 
static_cast<int>(row_sets.size()));
     vector<shared_ptr<DiskRowSet>> to_merge;
@@ -1314,8 +1316,8 @@ TEST_F(TestCompaction, 
TestCountLiveRowsOfDiskRowSetsCompact) {
   all_rss.emplace_back(std::move(rs1));
   all_rss.emplace_back(std::move(rs2));
 
-  SeedRandom();
-  std::random_shuffle(all_rss.begin(), all_rss.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(all_rss.begin(), all_rss.end(), gen);
   NO_FATALS(CompactAndReopenNoRoll(all_rss, schema_, &result));
 
   uint64_t count = 0;
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 3ee5d89..b2a79ef 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -23,7 +23,7 @@
 #include <memory>
 #include <mutex>
 #include <ostream>
-#include <type_traits>
+#include <random>
 #include <unordered_map>
 #include <unordered_set>
 #include <utility>
@@ -882,7 +882,9 @@ vector<RowSet*> Tablet::FindRowSetsToCheck(const RowOp* op,
     // relevance. We've had bugs in the past (eg KUDU-1341) which were 
obscured by
     // relying on the order of rowsets here. So, in debug builds, we shuffle 
the
     // order to encourage finding such bugs more easily.
-    std::random_shuffle(to_check.begin(), to_check.end());
+    std::random_device rdev;
+    std::mt19937 gen(rdev());
+    std::shuffle(to_check.begin(), to_check.end(), gen);
 #endif
     return to_check;
   }
diff --git a/src/kudu/transactions/txn_status_manager-test.cc 
b/src/kudu/transactions/txn_status_manager-test.cc
index feba083..99c7160 100644
--- a/src/kudu/transactions/txn_status_manager-test.cc
+++ b/src/kudu/transactions/txn_status_manager-test.cc
@@ -24,6 +24,7 @@
 #include <memory>
 #include <mutex>
 #include <numeric>
+#include <random>
 #include <set>
 #include <string>
 #include <thread>
@@ -224,7 +225,8 @@ TEST_F(TxnStatusManagerTest, 
TestStartTransactionsConcurrently) {
   for (int i = 0; i < kBatchesToStart; i++) {
     vector<int64_t> txns_in_batch(kParallelTxnsPerBatch);
     std::iota(txns_in_batch.begin(), txns_in_batch.end(), i * 
kParallelTxnsPerBatch);
-    std::random_shuffle(txns_in_batch.begin(), txns_in_batch.end());
+    std::mt19937 gen(SeedRandom());
+    std::shuffle(txns_in_batch.begin(), txns_in_batch.end(), gen);
     txns_to_insert.emplace_back(std::move(txns_in_batch));
   }
 
diff --git a/src/kudu/tserver/tablet_server-test.cc 
b/src/kudu/tserver/tablet_server-test.cc
index 514ab7f..572edd3 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -27,11 +27,11 @@
 #include <initializer_list>
 #include <map>
 #include <memory>
+#include <random>
 #include <set>
 #include <sstream>
 #include <string>
 #include <thread>
-#include <type_traits>
 #include <unordered_set>
 #include <utility>
 #include <vector>
@@ -2992,7 +2992,8 @@ TEST_F(TabletServerTest, TestDiffScan) {
 
   // Update some random rows.
   LocalTabletWriter writer(tablet_replica_->tablet(), &schema_);
-  std::random_shuffle(keys.begin(), keys.end());
+  std::mt19937 gen(SeedRandom());
+  std::shuffle(keys.begin(), keys.end(), gen);
   for (int i = 0; i < kNumToUpdate; i++) {
     KuduPartialRow row(&schema_);
     int32_t key = keys[i];
@@ -3004,7 +3005,7 @@ TEST_F(TabletServerTest, TestDiffScan) {
   }
 
   // Delete some random rows.
-  std::random_shuffle(keys.begin(), keys.end());
+  std::shuffle(keys.begin(), keys.end(), gen);
   for (int i = 0; i < kNumToDelete; i++) {
     KuduPartialRow row(&schema_);
     int32_t key = keys[i];
diff --git a/thirdparty/build-definitions.sh b/thirdparty/build-definitions.sh
index fced6d4..70e7af3 100644
--- a/thirdparty/build-definitions.sh
+++ b/thirdparty/build-definitions.sh
@@ -667,7 +667,7 @@ build_mustache() {
   mkdir -p $MUSTACHE_BDIR
   pushd $MUSTACHE_BDIR
   # We add $PREFIX/include for boost and $PREFIX_COMMON/include for rapidjson.
-  ${CXX:-g++} -std=c++11 $EXTRA_CXXFLAGS -I$PREFIX/include 
-I$PREFIX_COMMON/include -O3 -DNDEBUG -fPIC -c "$MUSTACHE_SOURCE/mustache.cc"
+  ${CXX:-g++} -std=c++17 $EXTRA_CXXFLAGS -I$PREFIX/include 
-I$PREFIX_COMMON/include -O3 -DNDEBUG -fPIC -c "$MUSTACHE_SOURCE/mustache.cc"
   ar rs libmustache.a mustache.o
   cp libmustache.a $PREFIX/lib/
   cp $MUSTACHE_SOURCE/mustache.h $PREFIX/include/
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 6caf62a..3487550 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -168,7 +168,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
   DYLIB_SUFFIX="dylib"
   PARALLEL=${PARALLEL:-$(sysctl -n hw.ncpu)}
 
-  # Kudu builds with C++11, which on OS X requires using libc++ as the standard
+  # Kudu builds with C++17, which on OS X requires using libc++ as the standard
   # library implementation. Some of the dependencies do not compile against
   # libc++ by default, so we specify it explicitly.
   EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -stdlib=libc++"
diff --git a/thirdparty/download-thirdparty.sh 
b/thirdparty/download-thirdparty.sh
index 86be27d..c361f36 100755
--- a/thirdparty/download-thirdparty.sh
+++ b/thirdparty/download-thirdparty.sh
@@ -255,11 +255,12 @@ fetch_and_patch \
  $ZLIB_SOURCE \
  $ZLIB_PATCHLEVEL
 
-LIBEV_PATCHLEVEL=0
+LIBEV_PATCHLEVEL=1
 fetch_and_patch \
  libev-${LIBEV_VERSION}.tar.gz \
  $LIBEV_SOURCE \
- $LIBEV_PATCHLEVEL
+ $LIBEV_PATCHLEVEL \
+ "patch -p1 < $TP_DIR/patches/libev-c17.patch"
 
 RAPIDJSON_PATCHLEVEL=1
 fetch_and_patch \
diff --git a/thirdparty/patches/libev-c17.patch 
b/thirdparty/patches/libev-c17.patch
new file mode 100644
index 0000000..bf9a562
--- /dev/null
+++ b/thirdparty/patches/libev-c17.patch
@@ -0,0 +1,37 @@
+From ef89859726b03245ff49e48999fc5f2e4b447b42 Mon Sep 17 00:00:00 2001
+From: Grant Henke <[email protected]>
+Date: Mon, 23 Nov 2020 17:06:38 -0600
+Subject: [PATCH] Fix usage with C++17
+
+When using with C++17 I got the following error:
+ev++.h:355:46: error: ISO C++1z does not allow dynamic exception specifications
+      dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
+
+This patch fixes the error by replacing `throw (bad_loop)`
+with `noexcept(false)`.
+---
+ ev++.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/ev++.h b/ev++.h
+index 4f0a36a..361bf5a 100644
+--- a/ev++.h
++++ b/ev++.h
+@@ -352,7 +352,7 @@ namespace ev {
+   struct dynamic_loop : loop_ref
+   {
+ 
+-    dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
++    dynamic_loop (unsigned int flags = AUTO) noexcept(false)
+     : loop_ref (ev_loop_new (flags))
+     {
+       if (!EV_AX)
+@@ -376,7 +376,7 @@ namespace ev {
+ 
+   struct default_loop : loop_ref
+   {
+-    default_loop (unsigned int flags = AUTO) throw (bad_loop)
++    default_loop (unsigned int flags = AUTO) noexcept(false)
+ #if EV_MULTIPLICITY
+     : loop_ref (ev_default_loop (flags))
+ #endif
\ No newline at end of file
diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py
index 29b5775..a1bc433 100755
--- a/thirdparty/preflight.py
+++ b/thirdparty/preflight.py
@@ -103,21 +103,21 @@ def check_tools():
       "\n".join("  " + tool for tool in missing))
 
 
-def check_cxx11():
+def check_cxx17():
   # Check that the compiler is new enough.
   try_do(
-    "Checking for C++11 compiler support",
-    ("Unable to compile a simple c++11 program. " +
-     "Please use g++ 4.8 or higher. On CentOS 6 or RHEL 6 " +
+    "Checking for C++17 compiler support",
+    ("Unable to compile a simple c++17 program. " +
+     "Please use g++ 7.0 or higher. On CentOS 7 or RHEL 7 " +
      "you must use the devtoolset. See docs/installation.adoc " +
      "for more info."),
     lambda: compile("""
-      #include <atomic>
+      #include <optional>
       int f() {
-        std::atomic<int> i;
-        return i.load();
+        std::optional<int> oi = 0;
+        return oi.value();
       }""",
-      flags=['--std=c++11']))
+      flags=['--std=c++17']))
 
 
 def check_sasl():
@@ -160,7 +160,7 @@ def main():
   print("  (Set $CC and $CXX to change compiler)")
   print("-------------------------")
   check_tools()
-  check_cxx11()
+  check_cxx17()
   check_sasl()
   check_openssl()
   print("-------------")

Reply via email to