Skip to content

Commit

Permalink
*: Fix compile error under clang 17 (#8503)
Browse files Browse the repository at this point in the history
ref #7193
  • Loading branch information
JaySon-Huang authored Dec 12, 2023
1 parent cf1082f commit 384a449
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion contrib/poco
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/tests/gtest_dm_ingest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ try
auto pool = std::make_shared<ThreadPool>(4);
for (const auto & op : ops)
{
pool->scheduleOrThrowOnError([=, &log] {
pool->scheduleOrThrowOnError([=, this, &log] {
try
{
LOG_INFO(log, "{} to [{}, {})", op.use_write ? "write" : "ingest", op.start_key, op.end_key);
Expand Down
9 changes: 6 additions & 3 deletions dbms/src/Storages/KVStore/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ class MutexLockWrap
public:
using Mutex = std::mutex;

std::lock_guard<Mutex> genLockGuard() const { return std::lock_guard(*mutex); }
std::lock_guard<Mutex> genLockGuard() const NO_THREAD_SAFETY_ANALYSIS { return std::lock_guard(*mutex); }

std::unique_lock<Mutex> tryToLock() const { return std::unique_lock(*mutex, std::try_to_lock); }
std::unique_lock<Mutex> tryToLock() const NO_THREAD_SAFETY_ANALYSIS
{
return std::unique_lock(*mutex, std::try_to_lock);
}

std::unique_lock<Mutex> genUniqueLock() const { return std::unique_lock(*mutex); }
std::unique_lock<Mutex> genUniqueLock() const NO_THREAD_SAFETY_ANALYSIS { return std::unique_lock(*mutex); }

private:
mutable AlignedStruct<Mutex, CPU_CACHE_LINE_SIZE> mutex;
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Page/V3/Blob/BlobStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void BlobStats::restore()
}
}

std::lock_guard<std::mutex> BlobStats::lock() const
std::lock_guard<std::mutex> BlobStats::lock() const NO_THREAD_SAFETY_ANALYSIS
{
return std::lock_guard(lock_stats);
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Page/V3/PageDirectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class VersionedPageEntries

bool isExternalPage() const { return type == EditRecordType::VAR_EXTERNAL; }

[[nodiscard]] PageLock acquireLock() const { return std::lock_guard(m); } // NOLINT
[[nodiscard]] PageLock acquireLock() const NO_THREAD_SAFETY_ANALYSIS { return std::lock_guard(m); }

void createNewEntry(const PageVersion & ver, const PageEntryV3 & entry);

Expand Down
34 changes: 18 additions & 16 deletions release-centos7-llvm/env/prepare-sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

set -ueox pipefail

CMAKE_VERSION=3.22.1
CMAKE_VERSION="3.22.1"
GO_VERSION="1.20"
ARCH=$(uname -m)
GO_ARCH=$([[ "$ARCH" == "aarch64" ]] && echo "arm64" || echo "amd64")
GO_ARCH=$([[ "${ARCH}" == "aarch64" ]] && echo "arm64" || echo "amd64")
LLVM_VERSION="13.0.0"
CCACHE_VERSION="4.5.1"
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
SYSROOT="$SCRIPTPATH/sysroot"
SYSROOT="${SCRIPTPATH}/sysroot"
OPENSSL_VERSION="1_1_1l"

function install_cmake() {
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-$ARCH.sh
sh cmake-$CMAKE_VERSION-linux-$ARCH.sh --prefix="$SYSROOT" --skip-license --exclude-subdir
rm -rf cmake-$CMAKE_VERSION-linux-$ARCH.sh
wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
sh cmake-${CMAKE_VERSION}-linux-${ARCH}.sh --prefix="${SYSROOT}" --skip-license --exclude-subdir
rm -rf cmake-${CMAKE_VERSION}-linux-${ARCH}.sh
}

function install_llvm() {
git clone https://github.com/llvm/llvm-project --depth=1 -b llvmorg-$LLVM_VERSION
git clone https://github.com/llvm/llvm-project --depth=1 -b "llvmorg-${LLVM_VERSION}"

mkdir -p llvm-project/build
cd llvm-project/build
Expand All @@ -53,7 +53,7 @@ function install_llvm() {
-DLLVM_ENABLE_LIBCXX=ON \
-DLLVM_ENABLE_LLD=ON \
-DLIBOMP_LIBFLAGS="-lm" \
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
-DCMAKE_INSTALL_PREFIX="${SYSROOT}" \
-DCMAKE_INSTALL_RPATH="\$ORIGIN/../lib/;\$ORIGIN/../lib/$(uname -m)-unknown-linux-gnu/" \
../llvm

Expand All @@ -64,16 +64,16 @@ function install_llvm() {
}

function install_openssl() {
wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_${OPENSSL_VERSION}.tar.gz
wget "https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_${OPENSSL_VERSION}.tar.gz"
tar xvf OpenSSL_${OPENSSL_VERSION}.tar.gz
cd openssl-OpenSSL_${OPENSSL_VERSION}

./config \
-fPIC \
no-shared \
no-afalgeng \
--prefix="$SYSROOT" \
--openssldir="$SYSROOT" \
--prefix="${SYSROOT}" \
--openssldir="${SYSROOT}" \
-static

NPROC=${NPROC:-$(nproc || grep -c ^processor /proc/cpuinfo)}
Expand All @@ -86,8 +86,10 @@ function install_openssl() {
}

function install_go() {
wget https://dl.google.com/go/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
tar -C "$SYSROOT" -xzvf go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
wget "https://dl.google.com/go/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
tar -C "${SYSROOT}" -xzvf go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
mv "${SYSROOT}/go" "${SYSROOT}/go${GO_VERSION}" && \
pushd "${SYSROOT}" && ln -sv "go${GO_VERSION}" "go" && popd
rm -rf go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
}

Expand All @@ -101,14 +103,14 @@ function install_ccache() {
-DHIREDIS_FROM_INTERNET=ON \
-DENABLE_TESTING=OFF \
-DCMAKE_INSTALL_RPATH="\$ORIGIN/../lib/;\$ORIGIN/../lib/$(uname -m)-unknown-linux-gnu/" \
-DCMAKE_INSTALL_PREFIX="$SYSROOT" \
-DCMAKE_INSTALL_PREFIX="${SYSROOT}" \
-GNinja
ninja && ninja install
cd ../..
rm -rf "ccache-$CCACHE_VERSION"
}

mkdir -p $SYSROOT
mkdir -p ${SYSROOT}

install_cmake
install_llvm
Expand All @@ -118,5 +120,5 @@ install_ccache

# some extra steps
if [[ -e /usr/lib64/libtinfo.so.5 ]]; then
cp /usr/lib64/libtinfo.so.5 "$SYSROOT/lib"
cp /usr/lib64/libtinfo.so.5 "${SYSROOT}/lib"
fi

0 comments on commit 384a449

Please sign in to comment.