Skip to content

[VL] Support test/debug/benchmark native builds on macOS (follow-up to #12331)#12470

Merged
jackylee-ch merged 1 commit into
apache:mainfrom
jackylee-ch:native-build-install-prefix
Jul 9, 2026
Merged

[VL] Support test/debug/benchmark native builds on macOS (follow-up to #12331)#12470
jackylee-ch merged 1 commit into
apache:mainfrom
jackylee-ch:native-build-install-prefix

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Follow-up to #12331, which made INSTALL_PREFIX flow into the Arrow, Velox and Gluten CPP CMake entry points. That behavior is unchanged here. This PR fixes what is still broken when building on macOS with --build_type=Debug, --build_tests=ON or --build_benchmarks=ON:

  • Replace the -isystem /usr/local/include demotion with an SDK sysroot (SDKROOT). Demotion keeps /usr/local/include ahead of imported targets' system includes, so test builds can compile against /usr/local headers (folly, gtest) while linking INSTALL_PREFIX libraries. Selecting the SDK sysroot drops /usr/local/include from the default search path entirely; package-discovery isolation via CMAKE_IGNORE_* is unchanged.
  • Restore BUILD_TYPE after sourcing build-arrow.sh, which otherwise overwrote Debug with Release for the rest of the build.
  • On macOS, force-load the Velox mono archive into libvelox.dylib and link facebook::velox privately, so test executables resolve Velox symbols from the dylib instead of linking a second copy of the archive.
  • On macOS, point folly's imported interface at gflags_shared. Folly exports gflags_static while glog links the shared gflags; loading both makes gflags register its built-in flags twice and abort test binaries. This is done in Gluten's CMake at find_package(Folly) time rather than by patching the installed folly-targets.cmake.
  • Resolve test data from a compile-time source-dir macro instead of the working directory, bump the gtest discovery timeout, and run the ld/ldd post-build checks only on Linux.

Linux discovery logic and the Folly no-jemalloc setup from #12331 are unchanged.

How was this patch tested?

macOS arm64 local Debug build with tests and benchmarks enabled; the full C++ ctest suite passed (5663 tests, 0 failures).

Was this patch authored or co-authored using generative AI tooling?

Yes — drafted with AI assistance and reviewed and verified by the author.

Copilot AI review requested due to automatic review settings July 7, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up to #12331 to make Velox/Gluten native builds on macOS behave correctly for Debug builds and when enabling tests/benchmarks, mainly by tightening header discovery/isolation, preserving requested build type across dependency builds, and improving test execution/linking behavior on Darwin.

Changes:

  • Switch macOS header isolation from /usr/local/include demotion to using an SDK sysroot (SDKROOT), and keep prefix include dirs available when needed.
  • Fix build-type propagation across Arrow build scripting and adjust Velox/Gluten linking on macOS to avoid duplicate archive linkage at test runtime.
  • Improve C++ test robustness (compile-time test data dir, longer gtest discovery timeout) and restrict ld/ldd post-build checks to Linux.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ep/build-velox/src/get-velox.sh Removes macOS /usr/local/include demotion patching and updates Folly jemalloc-related setup notes.
ep/build-velox/src/build-velox.sh Adds SDKROOT-based isolation on macOS, adjusts include flags for prefix installs, and hardens xsimd install handling.
dev/builddeps-veloxbe.sh Exports SDKROOT for macOS prefix-isolated builds and restores BUILD_TYPE after sourcing build-arrow.sh.
dev/build-helper-functions.sh Updates macOS isolation logic in cmake_install() to rely on sysroot-based isolation rather than include-path demotion.
cpp/velox/tests/FilePathGenerator.cc Resolves test data paths via a compile-time source-dir macro instead of working-directory-relative paths.
cpp/velox/tests/CMakeLists.txt Defines the test data dir macro for tests and increases gtest discovery timeout.
cpp/velox/CMakeLists.txt Adds macOS force-load of Velox mono archive into the dylib, adjusts link scope on Darwin, patches Folly↔gflags linkage, and gates ld/ldd checks to Linux.
cpp/core/CMakeLists.txt Adds optional prefix include directories and gates ld/ldd checks to Linux.
cpp/CMakeLists.txt Collects prefix include dirs from CMAKE_INSTALL_PREFIX/CMAKE_PREFIX_PATH for consistent header discovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cpp/velox/tests/CMakeLists.txt
Comment thread dev/build-helper-functions.sh Outdated
Comment on lines +117 to 121
if [[ -n "${INSTALL_PREFIX:-}" && "${INSTALL_PREFIX:-}" != "/usr/local" && "${INSTALL_PREFIX:-}" != /usr/local/* ]]; then
# Some prefix-installed deps only publish loose headers (e.g. xsimd), so
# keep the prefix include dir on the compiler command line.
CXX_FLAGS="$CXX_FLAGS -I${INSTALL_PREFIX}/include"
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is intentionally. ${INSTALL_PREFIX} is used unquoted throughout this script (the very next lines pass -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} and -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} the same way), so paths with spaces are already unsupported here regardless of this line. Since the flag is later embedded into -DCMAKE_CXX_FLAGS="..." and handed to make, quoting just this one occurrence would not actually make space-containing prefixes work. Proper whitespace support would be a separate, script-wide change outside the scope of this test/debug/benchmark follow-up.

@jackylee-ch jackylee-ch marked this pull request as draft July 8, 2026 05:53
…apache#12331)

PR apache#12331 (ce411ad) made INSTALL_PREFIX flow into the Arrow, Velox and
Gluten CPP CMake entry points. This follow-up keeps that behavior unchanged
and fixes what is still broken when building with --build_type=Debug,
--build_tests=ON or --build_benchmarks=ON on macOS:

- Replace the "-isystem /usr/local/include" demotion with an SDK sysroot
  (SDKROOT). Demotion keeps /usr/local/include in the search path ahead of
  imported targets' system includes, so test builds can compile against
  /usr/local headers (folly, gtest) while linking INSTALL_PREFIX libraries.
  Selecting the SDK sysroot removes /usr/local/include from the default
  search path entirely; package discovery isolation via CMAKE_IGNORE_* is
  unchanged.
- Restore BUILD_TYPE after sourcing build-arrow.sh, which overwrote Debug
  with Release for the rest of the build.
- Force-load the Velox mono archive into libvelox.dylib and link
  facebook::velox privately on macOS so test executables resolve Velox
  symbols from the dylib instead of linking a second copy of the archive.
- Rewrite folly's imported interface to use gflags_shared on macOS. Folly
  exports gflags_static while glog links the shared gflags, and loading
  both copies makes gflags register built-in flags twice and abort test
  binaries. Done in Gluten's CMake at find_package(Folly) time instead of
  patching installed folly-targets.cmake.
- Resolve test data files from a compile-time source-dir macro instead of
  the working directory, and bump gtest discovery timeout; run the ld/ldd
  post-build checks only on Linux.

Linux discovery logic and the Folly no-jemalloc setup from apache#12331 are
unchanged.
@jackylee-ch jackylee-ch force-pushed the native-build-install-prefix branch from 3c15656 to 19231b6 Compare July 8, 2026 06:50
@jackylee-ch jackylee-ch marked this pull request as ready for review July 8, 2026 11:17
Copilot AI review requested due to automatic review settings July 8, 2026 11:17
@jackylee-ch

jackylee-ch commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

cc @zhouyuan @philo-he . This is a follow up PR for #12331 to make sure INSTALL_PREFIX works on test/debug/benchmark native builds.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@philo-he philo-he left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@jackylee-ch jackylee-ch merged commit 8aeff65 into apache:main Jul 9, 2026
54 checks passed
@prestodb-ci

prestodb-ci commented Jul 9, 2026

Copy link
Copy Markdown

Rebase job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants