diff --git a/dev/build-arrow.sh b/dev/build-arrow.sh index 54c6faaf331..8bb2a19b3fe 100755 --- a/dev/build-arrow.sh +++ b/dev/build-arrow.sh @@ -34,6 +34,9 @@ function prepare_arrow_build() { patch -p1 < $CURRENT_DIR/../ep/build-velox/src/modify_arrow_dataset_scan_option.patch patch -p1 < $CURRENT_DIR/../ep/build-velox/src/cmake-compatibility.patch patch -p1 < $CURRENT_DIR/../ep/build-velox/src/support_ibm_power.patch + # Fix C++20 operator<< ambiguity in Arrow's vendored Howard Hinnant date + # library on macOS libc++ (sys_time overload conflicts with date::operator<<). + patch -p1 < $CURRENT_DIR/../ep/build-velox/src/fix_vendored_datetime_operator.patch popd } diff --git a/ep/build-velox/src/fix_vendored_datetime_operator.patch b/ep/build-velox/src/fix_vendored_datetime_operator.patch new file mode 100644 index 00000000000..3843a9ee68b --- /dev/null +++ b/ep/build-velox/src/fix_vendored_datetime_operator.patch @@ -0,0 +1,37 @@ +Fix C++20 operator<< ambiguity in Arrow's vendored Howard Hinnant date library. + +On macOS libc++ with -std=c++20, std::chrono's own operator<< for sys_time +overloads conflict with the vendored `date::operator<<` pulled in via +`using date::operator<<` / `using namespace date`, producing an ambiguous +overload resolution error when streaming sys_seconds/sys_time values. + +Replace the ADL-driven `<<` call sites with an explicit qualified call +`date::operator<<(os, timepoint)` so the vendored overload is selected +unambiguously regardless of what std::chrono provides. + +diff --git a/cpp/src/arrow/vendored/datetime/tz.cpp b/cpp/src/arrow/vendored/datetime/tz.cpp +--- a/cpp/src/arrow/vendored/datetime/tz.cpp ++++ b/cpp/src/arrow/vendored/datetime/tz.cpp +@@ -2734,8 +2734,7 @@ + std::ostream& + operator<<(std::ostream& os, const leap_second& x) + { +- using namespace date; +- return os << x.date_ << " +"; ++ return date::operator<<(os, x.date_) << " +"; + } + + #if USE_OS_TZDB +diff --git a/cpp/src/arrow/vendored/datetime/tz_private.h b/cpp/src/arrow/vendored/datetime/tz_private.h +--- a/cpp/src/arrow/vendored/datetime/tz_private.h ++++ b/cpp/src/arrow/vendored/datetime/tz_private.h +@@ -291,8 +291,7 @@ + std::ostream& + operator<<(std::ostream& os, const transition& t) + { +- using date::operator<<; +- os << t.timepoint << "Z "; ++ date::operator<<(os, t.timepoint) << "Z "; + if (t.info->offset >= std::chrono::seconds{0}) + os << '+'; + os << make_time(t.info->offset);