feat: Support macOS builds with AppleClang and Homebrew Clang#279
Conversation
|
Hi @zjw1111 , could you please help take a look at this PR when you have time? This change adds macOS build support for both AppleClang and Homebrew Clang. I think this would be useful for local development because many contributors use macOS as their daily environment, and being able to configure, build, and run checks locally makes it easier to validate changes before opening PRs. It should also help reduce the feedback cycle for dependency/CMake related work: developers can reproduce more issues locally instead of relying only on Linux CI, while keeping the existing Linux build paths unchanged. Thanks! |
There was a problem hiding this comment.
Pull request overview
Enables building paimon-cpp on macOS (AppleClang and Homebrew LLVM Clang) by adjusting platform-specific CMake/linking behavior, improving third-party bundled dependency configuration, and updating build documentation to include verified macOS flows.
Changes:
- Add macOS-aware handling for GNU-specific linker flags,
dllinking, and gLog initialization program-name retrieval. - Adjust bundled third-party build configuration (notably Protobuf/Zlib, ORC rpath handling, and imported target properties for Arrow/TBB).
- Document verified macOS build commands for AppleClang and Homebrew Clang, including a new Clang/libc++ headers option.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/paimon/common/logging/logging.cpp | Makes gLog initialization portable by using an OS-specific program-name source. |
| src/paimon/CMakeLists.txt | Avoids linking dl on macOS by conditionally appending it only on non-Apple platforms. |
| README.md | Updates the “verified builds” statement to include macOS arm64. |
| docs/source/building.rst | Adds macOS build instructions for AppleClang and Homebrew Clang; updates general build examples. |
| CMakeLists.txt | Adds a macOS Clang/libc++ headers option and disables version-script flags on Apple. |
| cmake_modules/ThirdpartyToolchain.cmake | Tweaks bundled dependency builds (Protobuf Zlib args, ORC rpath flags, Arrow/TBB imported target properties). |
| cmake_modules/SetupCxxFlags.cmake | Adds logic to use Apple SDK libc++ headers when building with upstream Clang on macOS. |
| cmake_modules/BuildUtils.cmake | Guards GNU-ld-specific shared-library linker options on non-Apple platforms only. |
| cmake_modules/arrow.diff | Updates Arrow patching to accept macOS libtool version-string variants and adds CMake policy compatibility. |
| build_support/run_clang_tidy.py | Updates shebang to python3. |
| build_support/run_clang_format.py | Updates shebang to python3. |
| build_support/iwyu/iwyu.sh | Uses ${PYTHON:-python3} instead of python. |
| build_support/iwyu/iwyu_tool.py | Updates shebang and usage example to python3. |
| build_support/asan_symbolize.py | Updates shebang to python3. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Great work, and thanks for the improvement!
I have a quick question: is this intended to be an intermediate version that supports building on macOS?
I noticed that the current codebase can now build successfully on macOS in the default configuration. However, if -DPAIMON_BUILD_TESTS=ON is enabled, there still seem to be some build issues. For example, a few linker flags such as --whole-archive and --no-as-needed are ELF-specific and are not supported by the macOS toolchain.
So I’m wondering whether:
- full macOS support is planned in follow-up changes, or
- we only intend to make the main build pass on macOS
Thanks again for the work!
My goal is to support macOS builds as fully as possible, not just the default build configuration. For example, making |
|
This pr rely on #282, it will be rebased after pr#282 merged |
|
@suxiaogang223 Amazing work! |
8d5b93b to
ec4fbab
Compare
|
@zjw1111 Thanks for the suggestions on improving the CMake structure and making the linking logic cleaner. I have updated the code following your direction :) |
|
I re-tested the latest PR head on macOS with tests enabled: cmake -S . -B build-pr279-tests -DPAIMON_DEPENDENCY_SOURCE=BUNDLED -DPAIMON_BUILD_TESTS=ON
cmake --build build-pr279-tests -- -j4The configure step succeeds, and Arrow/Brotli now use the bundled path correctly, but the build still fails while linking The immediate cause appears to be calls such as Could you please make the BIGINT test literals platform-independent, for example by using |
Thank you for your review:) I didn't consider all CMake compilation options during my local verification. Perhaps we should add a corresponding macOS verification CI pipeline after this pr merged to ensure compilation stability on macOS. |
|
LGTM! Could you take a review? @lucasfang |
Thanks for the suggestion. I agree that adding macOS verification would help keep the build stable. We plan to add a macOS compilation CI pipeline after the Apache migrate is completed, so future changes can be verified on macOS more consistently. |
|
LGTM!
LGTM! |
Summary
Related Issue
Part of #260.
Motivation
paimon-cpp could not be built cleanly on macOS with the bundled dependency path. The failures came from a mix of Linux-specific linker options, macOS dynamic library naming/runtime differences, bundled third-party build assumptions, and compiler/header compatibility issues.
This PR first makes the project build with AppleClang from Xcode Command Line Tools. It then extends the CMake setup so developers can also use Homebrew LLVM clang without manually patching bundled third-party sources. For upstream Clang on macOS, CMake defaults to Apple SDK libc++ headers to avoid current incompatibilities in bundled fmt and Arrow's bundled thrift when using the newest Homebrew libc++ headers.
Validation
cmake -S . -B build-macos-fix3 -DPAIMON_DEPENDENCY_SOURCE=BUNDLED -DPAIMON_BUILD_TESTS=OFFcmake --build build-macos-fix3 -j8cmake -S . -B build-macos-homebrew-clang22-cmake-auto -DPAIMON_DEPENDENCY_SOURCE=BUNDLED -DPAIMON_BUILD_TESTS=OFF -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++cmake --build build-macos-homebrew-clang22-cmake-auto -j8