This is an automated email from the ASF dual-hosted git repository.
HappenLee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new c7f355922c1 [Fix](thirdparty) Unify arrow cpp standard with be (#64390)
c7f355922c1 is described below
commit c7f355922c13697dc8b624e4dad080f7ccc7ddf3
Author: linrrarity <[email protected]>
AuthorDate: Thu Jun 25 09:56:44 2026 +0800
[Fix](thirdparty) Unify arrow cpp standard with be (#64390)
Related PR: https://github.com/apache/doris/pull/63191
Problem Summary:
Arrow 17 defaults to `C++17` when CMAKE_CXX_STANDARD is not specified,
while Doris BE is built with `C++20`. This can make header-defined
inline/template code from Arrow Flight and its dependencies be compiled
under different C++ standard modes in the same final binary.
In particular, Arrow Status-related inline paths may generate different
implementations across C++17 and C++20, such as different initialization
strategies for function-local static std::string objects:
code:
```cpp
const std::string& get_empty_string() {
static const std::string s = "";
return s;
}
```
cpp17 lazy initialization:
```asm
get_empty_string[abi:cxx11]():
push rbp
mov rbp, rsp
sub rsp, 64
cmp byte ptr [rip + guard variable for
get_empty_string[abi:cxx11]()::s[abi:cxx11]], 0
jne .LBB0_4
lea rdi, [rip + guard variable for
get_empty_string[abi:cxx11]()::s[abi:cxx11]]
call __cxa_guard_acquire@PLT
cmp eax, 0
je .LBB0_4
lea rdx, [rbp - 33]
mov qword ptr [rbp - 32], rdx
mov rax, qword ptr [rbp - 32]
mov qword ptr [rbp - 8], rax
lea rdi, [rip + get_empty_string[abi:cxx11]()::s[abi:cxx11]]
lea rsi, [rip + .L.str]
call std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char>>::basic_string<std::allocator<char>>(char const*,
std::allocator<char> const&)
jmp .LBB0_3
.LBB0_3:
lea rax, [rbp - 33]
mov qword ptr [rbp - 24], rax
mov rdi, qword ptr [rbp - 24]
call std::__new_allocator<char>::~__new_allocator() [base object
destructor]
lea rdi, [rip + std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char>>::~basic_string() [base object
destructor]]
lea rsi, [rip + get_empty_string[abi:cxx11]()::s[abi:cxx11]]
lea rdx, [rip + __dso_handle]
call __cxa_atexit@PLT
lea rdi, [rip + guard variable for
get_empty_string[abi:cxx11]()::s[abi:cxx11]]
call __cxa_guard_release@PLT
```
cpp20 constant initialization:
```asm
get_empty_string[abi:cxx11]():
push rbp
mov rbp, rsp
lea rax, [rip + get_empty_string[abi:cxx11]()::s[abi:cxx11]]
pop rbp
ret
get_empty_string[abi:cxx11]()::s[abi:cxx11]:
.quad get_empty_string[abi:cxx11]()::s[abi:cxx11]+16
.quad 0
.zero 16
```
Mixing those definitions through `weak/COMDAT` symbols is not a
supported build model and can surface as runtime crashes in Flight
error/status handling paths.
---
thirdparty/build-thirdparty.sh | 7 ++-
thirdparty/download-thirdparty.sh | 7 ---
...che-arrow-17.0.0-status-inline-static-fix.patch | 58 ----------------------
.../paimon-cpp-buildutils-static-deps.patch | 14 ++++++
4 files changed, 20 insertions(+), 66 deletions(-)
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 0da907b3882..7ce9416f1e3 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -33,6 +33,8 @@ set -eo pipefail
curdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+TP_CXX_STANDARD=20
+
export DORIS_HOME="${curdir}/.."
export TP_DIR="${curdir}"
@@ -723,7 +725,8 @@ build_re2() {
cd "${TP_SOURCE_DIR}/${RE2_SOURCE}"
"${CMAKE_CMD}" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
- -DCMAKE_BUILD_TYPE=Release -G "${GENERATOR}" -DBUILD_SHARED_LIBS=0
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+ -DCMAKE_BUILD_TYPE=Release \
+ -G "${GENERATOR}" -DBUILD_SHARED_LIBS=0
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_PREFIX_PATH="${TP_INSTALL_DIR}"
-DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}"
"${BUILD_SYSTEM}" -j "${PARALLEL}" install
strip_lib libre2.a
@@ -1086,6 +1089,7 @@ build_arrow() {
LDFLAGS="${ldflags}" \
"${CMAKE_CMD}" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
+ -DCMAKE_CXX_STANDARD="${TP_CXX_STANDARD}" \
-G "${GENERATOR}" -DARROW_PARQUET=ON -DARROW_IPC=ON
-DARROW_BUILD_SHARED=OFF \
-DARROW_BUILD_STATIC=ON -DARROW_WITH_BROTLI=ON -DARROW_WITH_LZ4=ON
-DARROW_USE_GLOG=ON \
-DARROW_WITH_SNAPPY=ON -DARROW_WITH_ZLIB=ON -DARROW_WITH_ZSTD=ON
-DARROW_JSON=ON \
@@ -2024,6 +2028,7 @@ build_paimon_cpp() {
"${CMAKE_CMD}" -C "${TP_DIR}/paimon-cpp-cache.cmake" \
-G "${GENERATOR}" \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
+ -DCMAKE_CXX_STANDARD="${TP_CXX_STANDARD}" \
-DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}" \
-DPAIMON_BUILD_SHARED=OFF \
-DPAIMON_BUILD_STATIC=ON \
diff --git a/thirdparty/download-thirdparty.sh
b/thirdparty/download-thirdparty.sh
index ab2849e373c..1c965b65c41 100755
--- a/thirdparty/download-thirdparty.sh
+++ b/thirdparty/download-thirdparty.sh
@@ -448,13 +448,6 @@ if [[ " ${TP_ARCHIVES[*]} " =~ " ARROW " ]]; then
# apache-arrow-17.0.0-force-write-int96-timestamps.patch :
# Introducing the parameter that forces writing int96 timestampes
for compatibility with Paimon cpp.
patch -p1
<"${TP_PATCH_DIR}/apache-arrow-17.0.0-force-write-int96-timestamps.patch"
-
- # apache-arrow-17.0.0-status-inline-static-fix.patch :
- # Move Status::message()/detail() empty sentinels out of header
- # inline function-local statics. Clang can place those weak inline
- # std::string objects in RELRO, then crash while initializing them.
- patch -p1
<"${TP_PATCH_DIR}/apache-arrow-17.0.0-status-inline-static-fix.patch"
-
touch "${PATCHED_MARK}"
fi
cd -
diff --git
a/thirdparty/patches/apache-arrow-17.0.0-status-inline-static-fix.patch
b/thirdparty/patches/apache-arrow-17.0.0-status-inline-static-fix.patch
deleted file mode 100644
index 2a1ed534077..00000000000
--- a/thirdparty/patches/apache-arrow-17.0.0-status-inline-static-fix.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc
-index a9581cadc9..1b7ee7df62 100644
---- a/cpp/src/arrow/status.cc
-+++ b/cpp/src/arrow/status.cc
-@@ -17,6 +17,17 @@
-
- namespace arrow {
-
-+const std::string& Status::NoMessage() {
-+ static const std::string* no_message = new std::string();
-+ return *no_message;
-+}
-+
-+const std::shared_ptr<StatusDetail>& Status::NoDetail() {
-+ static const std::shared_ptr<StatusDetail>* no_detail =
-+ new std::shared_ptr<StatusDetail>();
-+ return *no_detail;
-+}
-+
- Status::Status(StatusCode code, const std::string& msg)
- : Status::Status(code, msg, nullptr) {}
-
-diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h
-index 983b61629d..a49a982922 100644
---- a/cpp/src/arrow/status.h
-+++ b/cpp/src/arrow/status.h
-@@ -330,14 +330,18 @@ class ARROW_EXPORT [[nodiscard]] Status : public
util::EqualityComparable<Status
-
- /// \brief Return the specific error message attached to this status.
- const std::string& message() const {
-- static const std::string no_message = "";
-- return ok() ? no_message : state_->msg;
-+ if (ARROW_PREDICT_FALSE(state_ != NULLPTR)) {
-+ return state_->msg;
-+ }
-+ return NoMessage();
- }
-
- /// \brief Return the status detail attached to this message.
- const std::shared_ptr<StatusDetail>& detail() const {
-- static std::shared_ptr<StatusDetail> no_detail = NULLPTR;
-- return state_ ? state_->detail : no_detail;
-+ if (ARROW_PREDICT_FALSE(state_ != NULLPTR)) {
-+ return state_->detail;
-+ }
-+ return NoDetail();
- }
-
- const void* debug_state_addr() const { return state_; }
-@@ -396,6 +400,8 @@ class ARROW_EXPORT [[nodiscard]] Status : public
util::EqualityComparable<Status
- delete state_;
- state_ = NULLPTR;
- }
-+ static const std::string& NoMessage();
-+ static const std::shared_ptr<StatusDetail>& NoDetail();
- void CopyFrom(const Status& s);
- inline void MoveFrom(Status& s);
- };
diff --git a/thirdparty/patches/paimon-cpp-buildutils-static-deps.patch
b/thirdparty/patches/paimon-cpp-buildutils-static-deps.patch
index 31af1db7f0f..fc1fe155312 100644
--- a/thirdparty/patches/paimon-cpp-buildutils-static-deps.patch
+++ b/thirdparty/patches/paimon-cpp-buildutils-static-deps.patch
@@ -25,6 +25,20 @@ index 74654a4..4065297 100644
if(_paimon_objlib_deps)
add_dependencies(${LIB_NAME}_objlib ${_paimon_objlib_deps})
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 57f6c50..d8e3cd0 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -38,6 +38,8 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_BUILD_TYPE)
+
+-set(CMAKE_CXX_STANDARD 17)
++if(NOT DEFINED CMAKE_CXX_STANDARD)
++ set(CMAKE_CXX_STANDARD 17)
++endif()
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+ set(CMAKE_CXX_EXTENSIONS OFF)
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
diff --git a/cmake_modules/ThirdpartyToolchain.cmake
b/cmake_modules/ThirdpartyToolchain.cmake
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]