Skip to content

[VL] Respect INSTALL_PREFIX in Velox native builds#12331

Merged
jackylee-ch merged 1 commit into
apache:mainfrom
jackylee-ch:gluten-native-build-isolation
Jul 2, 2026
Merged

[VL] Respect INSTALL_PREFIX in Velox native builds#12331
jackylee-ch merged 1 commit into
apache:mainfrom
jackylee-ch:gluten-native-build-isolation

Conversation

@jackylee-ch

@jackylee-ch jackylee-ch commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

This PR keeps the native build behavior focused on INSTALL_PREFIX propagation and macOS-only /usr/local protection.

  • Propagate a user-provided INSTALL_PREFIX to native CMake entry points as CMAKE_PREFIX_PATH and CMAKE_INSTALL_PREFIX for dependency builds, Velox, and Gluten CPP.
  • Prefer Arrow artifacts from the selected CMAKE_PREFIX_PATH/INSTALL_PREFIX before falling back to the existing library discovery paths.
  • On Linux, keep the existing system discovery behavior. This PR does not ignore /usr or /usr/local by default.
  • On macOS, when INSTALL_PREFIX is outside /usr/local, keep /usr/local out of CMake package discovery and rebuild compiler system include flags from the SDK so /usr/local/include is not injected ahead of the selected prefix. When INSTALL_PREFIX is /usr/local or under it, /usr/local remains visible.
  • Apply the same macOS prefix policy to fetched Velox setup scripts used by --run_setup_script=ON. Folly jemalloc is preserved by linking Homebrew jemalloc explicitly when available; this PR does not disable jemalloc.
  • Keep prefix-installed local test dependencies from being mixed with incompatible system target metadata during macOS test builds, and make Velox C++ test data paths independent of the process working directory.

How was this patch tested?

  • Rebased on latest upstream/main: d666ceb.
  • git diff --check
  • bash -n dev/build-helper-functions.sh dev/builddeps-veloxbe.sh ep/build-velox/src/build-velox.sh ep/build-velox/src/get-velox.sh
  • env PATH=/opt/homebrew/Cellar/llvm@15/15.0.7/bin:$PATH ./dev/format-cpp-code.sh
  • macOS arm64, --run_setup_script=ON, --enable_vcpkg=OFF, Debug, tests and benchmarks enabled: setup dependencies, Arrow, Velox, and Gluten CPP build completed with INSTALL_PREFIX under the Velox build directory.
  • Final incremental Gluten CPP Debug build: env CCACHE_DISABLE=1 cmake --build cpp/build -j4
  • Gluten C++ test binaries executed successfully, including core tests, delta tests, shuffle writer tests, plan conversion tests, runtime tests, and checksum/timer tests.
  • CTest isolation group passed: ctest --test-dir cpp/build -R 'VeloxColumnar|VeloxRowToColumnar|VeloxBatchResizer|ValueStreamDynamicFilter|MemoryManagerTest|MultiMemoryManagerTest' --output-on-failure -j1 (71/71 passed).
  • Benchmark smoke passed for velox_batch_resizer_benchmark, delta_bitmap_benchmark, plan_validator_util, and generic_benchmark. parquet_write_benchmark was checked separately and currently fails because the benchmark passes an aggregate memory pool to a leaf-only Velox allocation path; that file is not changed by this PR.
  • Verified final generated compile commands/build files have zero /usr/local/include matches. /opt/homebrew/include appears only as -isystem, with INSTALL_PREFIX include paths kept ahead of it.
  • Static check for --enable_vcpkg=ON found no direct conflict; the vcpkg build was not executed.

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

Generated-by: OpenAI Codex (GPT-5)

Copilot AI review requested due to automatic review settings June 22, 2026 12:28

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

Introduces a unified native-build “component isolation” resolver (dev/build-isolation.sh) and wires it into the Velox/Arrow build entrypoints so that path-discovery isolation (CMake + compiler include search demotion) is consistently applied across macOS and Linux.

Changes:

  • Add dev/build-isolation.sh to compute isolation policy, generate a toolchain fragment, and export discovery/ignore flags for all nested CMake builds.
  • Update native build entrypoints (builddeps-veloxbe.sh, build-velox.sh, build-helper-functions.sh) to consume the resolver outputs instead of duplicating macOS-only /usr/local ignore logic.
  • Add a dry-run scenario test harness (dev/tests/test-build-isolation.sh) and ignore generated artifacts via .gitignore; harden dev/build-arrow.sh’s managed-dir cleanup behavior.

Reviewed changes

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

Show a summary per file
File Description
ep/build-velox/src/build-velox.sh Sources the isolation resolver and injects resolved CMake/compiler isolation flags into Velox’s build.
dev/tests/test-build-isolation.sh Adds dry-run tests validating resolved isolation behavior and propagation.
dev/builddeps-veloxbe.sh Establishes/install-prefix explicitness and applies resolver-derived CMake isolation across native build stages.
dev/build-isolation.sh New single-source resolver that generates toolchain/env artifacts and exports isolation flags/toolchain.
dev/build-helper-functions.sh Uses the resolver to apply isolation flags consistently for CMake-based dependency builds.
dev/build-arrow.sh Avoids wiping user-provided Arrow prefixes and consults resolver for standalone prefix defaults.
.gitignore Ignores generated isolation artifacts under .gluten-build-cache/.

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

Comment thread dev/build-arrow.sh Outdated
Comment thread dev/build-isolation.sh Outdated
Comment thread dev/build-isolation.sh Outdated
@jackylee-ch jackylee-ch marked this pull request as draft June 22, 2026 13:47
@jackylee-ch jackylee-ch force-pushed the gluten-native-build-isolation branch 3 times, most recently from 51280f4 to 44b67a8 Compare June 23, 2026 07:29
@jackylee-ch jackylee-ch force-pushed the gluten-native-build-isolation branch from 44b67a8 to c6f0328 Compare July 1, 2026 02:23
@jackylee-ch jackylee-ch changed the title [VL] Unify native-build component isolation via a single resolver (macOS + Linux) [VL] Respect INSTALL_PREFIX in Velox native builds Jul 1, 2026
@jackylee-ch jackylee-ch marked this pull request as ready for review July 1, 2026 07:10
Copilot AI review requested due to automatic review settings July 1, 2026 07:10

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 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread dev/builddeps-veloxbe.sh
Comment on lines +265 to +268
if [ -n "${INSTALL_PREFIX:-}" ]; then
GLUTEN_CMAKE_OPTIONS+=" -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX"
GLUTEN_CMAKE_OPTIONS+=" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX"
fi
Comment thread ep/build-velox/src/get-velox.sh
Comment thread cpp/velox/CMakeLists.txt Outdated
Propagate a user-provided INSTALL_PREFIX into the native Velox build flow by exporting it on Linux when set and passing it to CMake as CMAKE_PREFIX_PATH/CMAKE_INSTALL_PREFIX for dependency builds, Velox, and Gluten CPP. This keeps Linux's existing system-path discovery unchanged unless the user explicitly chooses a prefix.

On macOS, keep the existing /usr/local isolation only when the effective INSTALL_PREFIX is outside /usr/local. Also demote /usr/local/include in compiler flags so Apple clang does not prefer stale system headers over the selected install prefix, and patch fetched Velox setup scripts before --run_setup_script=ON builds dependencies such as Folly.

Teach the Gluten Velox module to resolve thrift from CMAKE_INSTALL_PREFIX/CMAKE_PREFIX_PATH before falling back to /usr/local.
@jackylee-ch jackylee-ch force-pushed the gluten-native-build-isolation branch from c6f0328 to 6304aa8 Compare July 1, 2026 07:25
@jackylee-ch

Copy link
Copy Markdown
Contributor Author

cc @zhouyuan @philo-he

@zhouyuan zhouyuan 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.

👍

@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. Just one follow-up suggestion. Thanks.

Comment thread ep/build-velox/src/get-velox.sh
@jackylee-ch jackylee-ch merged commit ce411ad into apache:main Jul 2, 2026
60 checks passed
@prestodb-ci

prestodb-ci commented Jul 2, 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.

5 participants