Skip to content

GH-55505: Gandiva: normalize Darwin host triple to macosx so exp10 libcall is available - #55506

Open
lriggs wants to merge 3 commits into
apache:mainfrom
lriggs:gh-55505
Open

lriggs wants to merge 3 commits into
apache:mainfrom
lriggs:gh-55505

Conversation

@lriggs

@lriggs lriggs commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

An incorrect target machine setting leads to an undefined function reference in LLVM resulting in a crash for MacOS.

Gandiva builds its JIT target machine from llvm::sys::getDefaultTargetTriple(), which on macOS is an unversioned/kernel-versioned arm64-apple-darwin. LLVM only enables macOS libcalls such as __exp10 for the macosx OS name. With optimization off, pow(10, x) (used by get_scale_multiplier for scales outside 0..19) is
lowered to llvm.exp10, and the backend finds no libcall for it.

What changes are included in this PR?

Changes to the target machine configuration on Mac. Unit test.

Are these changes tested?

Yes manual with a repro and unit test.

Are there any user-facing changes?

No.

This PR contains a "Critical Fix". Fixes a potential crash on MacOs when optimization is disabled for llvm.

Was AI used for this PR?

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

…p10 libcall is available

An incorrect target machine setting leads to an undefined function reference in LLVM resulting in a crash.

LLVM's default host triple names the OS "darwin", but LLVM only enables
macOS libcalls (e.g. __exp10 for llvm.exp10) for the "macosx" OS. Fix
the naming of the target machine.
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55505 has been automatically assigned in GitHub to PR creator.

Comment thread cpp/src/gandiva/engine.cc Resolved
Comment thread cpp/src/gandiva/engine.cc Resolved
int32_t scale);

protected:
// Compiles round(float64, int32) through the Gandiva JIT and evaluates it on the

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.

nit: One of my favorite things to do is test-only first commit that fails the CI however here I still don't know what runs on pull requests before the green light from the overseer

Comment thread cpp/src/gandiva/engine.cc Resolved
…ectHost(), clears CPU/features when target_host_cpu() is false, and rewrites darwin → macosx<kern.osproductversion> only under __APPLE__ && LLVM_VERSION_MAJOR < 24. I checked that llvm/llvm-project#210674 isn't on release/23.x, so 24 is the first release with the fix. Host detection runs once in InitOnce() and each engine gets a copy, so we don't re-detect CPU features (which reads /proc/cpuinfo on Linux/arm) for every projector. NormalizeDarwinTriple and its unit tests are gone; the round(float64, int32) JIT tests still cover the crash.
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.

3 participants