[VL] Fix Arrow vendored datetime build failure on macOS C++20 libc++#12104
Open
jackylee-ch wants to merge 1 commit into
Open
[VL] Fix Arrow vendored datetime build failure on macOS C++20 libc++#12104jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
Arrow 15.0.0 ships a vendored copy of Howard Hinnant's date library. On macOS with `-std=c++20`, libc++'s `std::chrono` exposes its own `operator<<` for `sys_time` and related clock types that collides with `date::operator<<` pulled in via `using namespace date;` / `using date::operator<<;` in `vendored/datetime/tz.cpp` and `vendored/datetime/tz_private.h`. The resulting ambiguous overload resolution fails the Arrow CPP build: cpp/src/arrow/vendored/datetime/tz.cpp: error: use of overloaded operator '<<' is ambiguous (with operand types 'std::ostream' and 'const date::sys_seconds') Linux libstdc++ does not expose the conflicting `chrono::operator<<` so the build is unaffected there. Add `ep/build-velox/src/fix_vendored_datetime_operator.patch` that replaces the ADL-driven `os << timepoint` call sites with an explicit qualified call `date::operator<<(os, timepoint)` so the vendored overload is selected unambiguously regardless of what `std::chrono` provides. Apply the patch from `dev/build-arrow.sh::prepare_arrow_build` right after the existing Arrow patches (`modify_arrow.patch`, `modify_arrow_dataset_scan_option.patch`, `cmake-compatibility.patch`, `support_ibm_power.patch`). Two callsites are touched: - tz.cpp:2734 in `operator<<(std::ostream&, const leap_second&)` — drops the `using namespace date;` and calls `date::operator<<(os, x.date_)`. - tz_private.h:291 in `operator<<(std::ostream&, const transition&)` — drops `using date::operator<<;` and calls `date::operator<<(os, t.timepoint)`. Verification: - macOS 14 arm64 with Apple Clang 17, `-std=c++20`: Arrow CPP build reaches successful link of `libarrow.a` and the JNI cdata/dataset shared libraries; before the patch the build aborted at the first TU including `tz_private.h`. - Linux x86_64 build is unaffected because the patched code paths only fail on libc++. Local Ubuntu 22.04 build verified clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Building Arrow CPP on macOS with
-std=c++20and Apple Clang's libc++fails at the first translation unit that includes
vendored/datetime/tz_private.h:Arrow 15.0.0 ships a vendored copy of Howard Hinnant's date library.
On macOS
-std=c++20, libc++'sstd::chronoexposes its ownoperator<<forsys_timeand related clock types that collideswith
date::operator<<pulled in viausing namespace date;/using date::operator<<;insidevendored/datetime/tz.cppandtz_private.h.Linux libstdc++ does not expose the conflicting
chrono::operator<<,so the build is unaffected there.
This PR adds
ep/build-velox/src/fix_vendored_datetime_operator.patchthat replaces the ADL-driven
os << timepointcall sites with anexplicit qualified call
date::operator<<(os, timepoint)so thevendored overload is selected unambiguously regardless of what
std::chronoprovides. The patch is applied fromdev/build-arrow.sh::prepare_arrow_buildafter the existing Arrowpatches (
modify_arrow.patch,modify_arrow_dataset_scan_option.patch,cmake-compatibility.patch,support_ibm_power.patch).Two callsites are touched, both inside Arrow's vendored date code:
cpp/src/arrow/vendored/datetime/tz.cpp:2734operator<<(std::ostream&, const leap_second&)using namespace date;, calldate::operator<<(os, x.date_)cpp/src/arrow/vendored/datetime/tz_private.h:291operator<<(std::ostream&, const transition&)using date::operator<<;, calldate::operator<<(os, t.timepoint)The patch is platform-agnostic: explicit qualification works on any
toolchain. Linux builds (which currently succeed) are unaffected
because the rewritten call resolves to the same overload they
previously selected via ADL.
Relationship to #11869
This is a different and lower-layer problem from #11869, even though
both are macOS-only and timezone-adjacent:
spark.sql.session.timeZone=GMTsession 'session_timezone' set with invalid value 'GMT'error: use of overloaded operator '<<' is ambiguousGMTas a valid IANA namechrono::operator<<overloads that collide with the vendoreddate::operator<<via ADL<<ADL)backends-velox/,cpp/core/,cpp/velox/dev/build-arrow.sh+ newep/build-velox/src/fix_vendored_datetime_operator.patch(patches Arrow's vendored datetime)spark.sql.session.timeZone=GMT)-std=c++20+ libc++ macOS build, regardless of configWithout the change in this PR, Arrow CPP fails to compile, so
libarrow.a/libvelox.dylib/libgluten.dylibare never producedand #11869's runtime fix has no chance of being exercised on macOS
libc++ in the first place. They are complementary: #11869 fixes the
runtime tz config flow; this PR unblocks the build that hosts that
runtime.
How was this patch tested?
-std=c++20): Arrow CPP buildreaches successful link of
libarrow.a,libarrow_cdata_jni.dylib,libarrow_dataset_jni.dylib. Before the patch, the build aborted atthe first TU including
tz_private.hwith the ambiguity errorshown above.
(VeloxBloomFilterTest, ColumnarBatchTest, VeloxListenerApiTest,
OnHeapFileSystemTest, ArrowColumnVectorTest) all pass on the
resulting build.
resolve to the same
date::operator<<overload as before. LocalUbuntu build verified clean.
Was this patch authored or co-authored using generative AI tooling?
co-auth: Claude (Sonnet/Opus) via Claude Code 1.x