From eb772b800151f6bab6854fff929b31b55620937e Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 8 May 2018 22:44:54 +0300 Subject: [PATCH] gcc8 fixes (memset, uncaught_exception) --- cmake/arch.cmake | 4 ++++ cmake/find_llvm.cmake | 2 +- contrib/libsparsehash/sparsehash/sparsetable | 4 ++-- dbms/src/Common/HashTable/HashTable.h | 6 +++--- dbms/src/Common/StringSearcher.h | 4 ++-- .../DataStreams/CollapsingFinalBlockInputStream.h | 2 +- .../MergeTree/MergeTreeBaseBlockInputStream.cpp | 4 ++++ dbms/src/Storages/MergeTree/checkDataPart.cpp | 4 ++-- dbms/tests/server-test.xml | 1 + debian/.pbuilderrc | 5 ++++- docker/builder/build.sh | 2 +- libs/libcommon/include/ext/bit_cast.h | 2 +- release | 12 ++++++------ utils/travis/pbuilder.sh | 2 +- 14 files changed, 33 insertions(+), 21 deletions(-) diff --git a/cmake/arch.cmake b/cmake/arch.cmake index f61bac96ab0..ba446d95676 100644 --- a/cmake/arch.cmake +++ b/cmake/arch.cmake @@ -22,6 +22,10 @@ if (NOT MSVC) set (NOT_MSVC 1) endif () +if (NOT APPLE) + set (NOT_APPLE 1) +endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (COMPILER_GCC 1) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/cmake/find_llvm.cmake b/cmake/find_llvm.cmake index 618eaadf41a..8a8ad33a38c 100644 --- a/cmake/find_llvm.cmake +++ b/cmake/find_llvm.cmake @@ -1,4 +1,4 @@ -option (ENABLE_EMBEDDED_COMPILER "Set to TRUE to enable support for 'compile' option for query execution" 1) +option (ENABLE_EMBEDDED_COMPILER "Set to TRUE to enable support for 'compile' option for query execution" ${NOT_APPLE}) if (ENABLE_EMBEDDED_COMPILER) # Based on source code of YT. diff --git a/contrib/libsparsehash/sparsehash/sparsetable b/contrib/libsparsehash/sparsehash/sparsetable index efbeaac0a69..d162623a5f5 100644 --- a/contrib/libsparsehash/sparsehash/sparsetable +++ b/contrib/libsparsehash/sparsehash/sparsetable @@ -1088,7 +1088,7 @@ class sparsegroup { // This is equivalent to memmove(), but faster on my Intel P4, // at least with gcc4.1 -O2 / glibc 2.3.6. for (size_type i = settings.num_buckets; i > offset; --i) - memcpy(group + i, group + i-1, sizeof(*group)); + memcpy(static_cast(group + i), group + i-1, sizeof(*group)); } // Create space at group[offset], without special assumptions about value_type @@ -1154,7 +1154,7 @@ class sparsegroup { // at lesat with gcc4.1 -O2 / glibc 2.3.6. assert(settings.num_buckets > 0); for (size_type i = offset; i < settings.num_buckets-1; ++i) - memcpy(group + i, group + i+1, sizeof(*group)); // hopefully inlined! + memcpy(static_cast(group + i), group + i+1, sizeof(*group)); // hopefully inlined! group = settings.realloc_or_die(group, settings.num_buckets-1); } diff --git a/dbms/src/Common/HashTable/HashTable.h b/dbms/src/Common/HashTable/HashTable.h index b04d3444f93..9fe446ccb8f 100644 --- a/dbms/src/Common/HashTable/HashTable.h +++ b/dbms/src/Common/HashTable/HashTable.h @@ -408,7 +408,7 @@ protected: /// Copy to a new location and zero the old one. x.setHash(hash_value); - memcpy(&buf[place_value], &x, sizeof(x)); + memcpy(static_cast(&buf[place_value]), &x, sizeof(x)); x.setZero(); /// Then the elements that previously were in collision with this can move to the old place. @@ -726,7 +726,7 @@ public: { size_t place_value = findEmptyCell(grower.place(hash_value)); - memcpy(&buf[place_value], cell, sizeof(*cell)); + memcpy(static_cast(&buf[place_value]), cell, sizeof(*cell)); ++m_size; if (unlikely(grower.overflow(m_size))) @@ -897,7 +897,7 @@ public: this->clearHasZero(); m_size = 0; - memset(buf, 0, grower.bufSize() * sizeof(*buf)); + memset(static_cast(buf), 0, grower.bufSize() * sizeof(*buf)); } /// After executing this function, the table can only be destroyed, diff --git a/dbms/src/Common/StringSearcher.h b/dbms/src/Common/StringSearcher.h index f43fe6c717c..7392e08ea25 100644 --- a/dbms/src/Common/StringSearcher.h +++ b/dbms/src/Common/StringSearcher.h @@ -86,8 +86,8 @@ public: if (*needle < 0x80u) { first_needle_symbol_is_ascii = true; - l = static_cast(std::tolower(*needle)); - u = static_cast(std::toupper(*needle)); + l = std::tolower(*needle); + u = std::toupper(*needle); } else { diff --git a/dbms/src/DataStreams/CollapsingFinalBlockInputStream.h b/dbms/src/DataStreams/CollapsingFinalBlockInputStream.h index db06a2aa9d3..607149bbcd2 100644 --- a/dbms/src/DataStreams/CollapsingFinalBlockInputStream.h +++ b/dbms/src/DataStreams/CollapsingFinalBlockInputStream.h @@ -150,7 +150,7 @@ private: --ptr->refcount; if (!ptr->refcount) { - if (std::uncaught_exception()) + if (std::uncaught_exceptions()) delete ptr; else ptr->output_blocks->push_back(ptr); diff --git a/dbms/src/Storages/MergeTree/MergeTreeBaseBlockInputStream.cpp b/dbms/src/Storages/MergeTree/MergeTreeBaseBlockInputStream.cpp index 9f8525d2092..a405620e7d8 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeBaseBlockInputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeBaseBlockInputStream.cpp @@ -147,8 +147,12 @@ Block MergeTreeBaseBlockInputStream::readFromPart() } size_t recommended_rows = estimateNumRows(*task, task->range_reader); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-qualifiers" size_t rows_to_read = std::max(static_cast(1), std::min(max_block_size_rows, recommended_rows)); +#pragma GCC diagnostic pop auto read_result = task->range_reader.read(rows_to_read, task->mark_ranges); diff --git a/dbms/src/Storages/MergeTree/checkDataPart.cpp b/dbms/src/Storages/MergeTree/checkDataPart.cpp index 1c25112ca39..ff36619756b 100644 --- a/dbms/src/Storages/MergeTree/checkDataPart.cpp +++ b/dbms/src/Storages/MergeTree/checkDataPart.cpp @@ -69,8 +69,8 @@ public: readIntBinary(mrk_mark.offset_in_decompressed_block, mrk_hashing_buf); bool has_alternative_mark = false; - MarkInCompressedFile alternative_data_mark; - MarkInCompressedFile data_mark; + MarkInCompressedFile alternative_data_mark = {}; + MarkInCompressedFile data_mark = {}; /// If the mark should be exactly at the border of blocks, we can also use a mark pointing to the end of previous block, /// and the beginning of next. diff --git a/dbms/tests/server-test.xml b/dbms/tests/server-test.xml index 9e4480cb0d3..9c392d0e518 100644 --- a/dbms/tests/server-test.xml +++ b/dbms/tests/server-test.xml @@ -71,6 +71,7 @@ + 3600 diff --git a/debian/.pbuilderrc b/debian/.pbuilderrc index 82c88b6bece..9edf5f91239 100644 --- a/debian/.pbuilderrc +++ b/debian/.pbuilderrc @@ -173,9 +173,12 @@ else export CMAKE_FLAGS="-DENABLE_EMBEDDED_COMPILER=0 $CMAKE_FLAGS" fi -# will test symbols +# Will test symbols #EXTRAPACKAGES+=" gdb " +# For killall in pbuilder-hooks: +EXTRAPACKAGES+=" psmisc " + [[ $CCACHE_PREFIX == 'distcc' ]] && EXTRAPACKAGES+=" $CCACHE_PREFIX " export DEB_BUILD_OPTIONS=parallel=`nproc` diff --git a/docker/builder/build.sh b/docker/builder/build.sh index a392638a319..f63dbb65558 100644 --- a/docker/builder/build.sh +++ b/docker/builder/build.sh @@ -2,6 +2,6 @@ mkdir -p /server/build_docker cd /server/build_docker -cmake /server -DENABLE_EMBEDDED_COMPILER=1 -DENABLE_TESTS=0 +cmake /server -DENABLE_TESTS=0 make -j $(nproc || grep -c ^processor /proc/cpuinfo) #ctest -V -j $(nproc || grep -c ^processor /proc/cpuinfo) diff --git a/libs/libcommon/include/ext/bit_cast.h b/libs/libcommon/include/ext/bit_cast.h index 49c48493d68..7bc70edcfe0 100644 --- a/libs/libcommon/include/ext/bit_cast.h +++ b/libs/libcommon/include/ext/bit_cast.h @@ -14,7 +14,7 @@ namespace ext std::decay_t bit_cast(const From & from) { To res {}; - memcpy(&res, &from, std::min(sizeof(res), sizeof(from))); + memcpy(static_cast(&res), &from, std::min(sizeof(res), sizeof(from))); return res; }; diff --git a/release b/release index 831c38daff7..cfc81791657 100755 --- a/release +++ b/release @@ -6,7 +6,7 @@ # Clang6 build: # env DIST=bionic EXTRAPACKAGES="clang-6.0 libstdc++-8-dev lld-6.0 liblld-6.0-dev libclang-6.0-dev liblld-6.0" DEB_CC=clang-6.0 DEB_CXX=clang++-6.0 CMAKE_FLAGS=" -DLLVM_VERSION_POSTFIX=-6.0 -DNO_WERROR=1 " ./release # Clang7 build: -# env DIST=unstable EXTRAPACKAGES="clang-7 libstdc++-8-dev lld-7 liblld-7-dev libclang-7-dev llvm-7-dev liblld-7" DEB_CC=clang-7 DEB_CXX=clang++-7 CMAKE_FLAGS=" -DLLVM_VERSION_POSTFIX=-7 -DNO_WERROR=1 " ./release +# env DIST=unstable EXTRAPACKAGES="clang-7 libstdc++-8-dev lld-7 liblld-7-dev libclang-7-dev liblld-7" DEB_CC=clang-7 DEB_CXX=clang++-7 CMAKE_FLAGS=" -DLLVM_VERSION_POSTFIX=-7 -DNO_WERROR=1 " ./release # Clang6 without internal compiler (for low memory arm64): # env DIST=bionic DISABLE_PARALLEL=1 EXTRAPACKAGES="clang-6.0 libstdc++-8-dev" DEB_CC=clang-6.0 DEB_CXX=clang++-6.0 CMAKE_FLAGS=" -DNO_WERROR=1 " ./release @@ -33,7 +33,7 @@ while [[ $1 == --* ]] do if [[ $1 == '--test' ]]; then TEST='yes' - VERSION_POSTFIX+=-test + VERSION_POSTFIX+=+test shift elif [[ $1 == '--check-build-dependencies' ]]; then DEBUILD_NODEPS_OPTIONS="" @@ -66,7 +66,7 @@ done if [ -n "$SANITIZER" ] then CMAKE_BUILD_TYPE=$SANITIZER - VERSION_POSTFIX+=-${SANITIZER,,} + VERSION_POSTFIX+=+${SANITIZER,,} # todo: нужно ли отключить libtcmalloc? LIBTCMALLOC_OPTS="-DENABLE_TCMALLOC=0" # GLIBC_COMPATIBILITY отключен по умолчанию @@ -75,14 +75,14 @@ then EXTRAPACKAGES="$EXTRAPACKAGES clang-5.0 lld-5.0" elif [[ $BUILD_TYPE == 'valgrind' ]]; then LIBTCMALLOC_OPTS="-DENABLE_TCMALLOC=0" - VERSION_POSTFIX+=-$BUILD_TYPE + VERSION_POSTFIX+=+$BUILD_TYPE elif [[ $BUILD_TYPE == 'debug' ]]; then CMAKE_BUILD_TYPE=Debug LIBTCMALLOC_OPTS="-DDEBUG_TCMALLOC=1" - VERSION_POSTFIX+=-$BUILD_TYPE + VERSION_POSTFIX+=+$BUILD_TYPE fi -CMAKE_FLAGS=" $LIBTCMALLOC_OPTS -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DENABLE_EMBEDDED_COMPILER=1 $CMAKE_FLAGS" +CMAKE_FLAGS=" $LIBTCMALLOC_OPTS -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE $CMAKE_FLAGS" export CMAKE_FLAGS export EXTRAPACKAGES diff --git a/utils/travis/pbuilder.sh b/utils/travis/pbuilder.sh index 613ecd61e0a..f5a3ee6c14a 100755 --- a/utils/travis/pbuilder.sh +++ b/utils/travis/pbuilder.sh @@ -24,7 +24,7 @@ env TEST_RUN=${TEST_RUN=1} \ DEB_CC=${DEB_CC=$CC} DEB_CXX=${DEB_CXX=$CXX} \ CCACHE_SIZE=${CCACHE_SIZE:=4G} \ `# Disable all features` \ - CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Debug -DUNBUNDLED=1 -DENABLE_UNWIND=0 -DENABLE_MYSQL=0 -DENABLE_CAPNP=0 -DENABLE_RDKAFKA=0 -DENABLE_EMBEDDED_COMPILER=1 -DCMAKE_C_FLAGS_ADD='-O0 -g0' -DCMAKE_CXX_FLAGS_ADD='-O0 -g0' $CMAKE_FLAGS" \ + CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Debug -DUNBUNDLED=1 -DENABLE_UNWIND=0 -DENABLE_MYSQL=0 -DENABLE_CAPNP=0 -DENABLE_RDKAFKA=0 -DCMAKE_C_FLAGS_ADD='-O0 -g0' -DCMAKE_CXX_FLAGS_ADD='-O0 -g0' $CMAKE_FLAGS" \ `# Use all possible contrib libs from system` \ `# psmisc - killall` \ EXTRAPACKAGES="psmisc clang-5.0 lld-5.0 liblld-5.0-dev libclang-5.0-dev liblld-5.0 libc++abi-dev libc++-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev zlib1g-dev liblz4-dev libdouble-conversion-dev libsparsehash-dev librdkafka-dev libpoco-dev libsparsehash-dev libgoogle-perftools-dev libzstd-dev libre2-dev $EXTRAPACKAGES" \