Skip to content

[C++][Gandiva] Crash on Mac OS with LLVM optimizations disabled #55505

Open

Description

@lriggs

Describe the bug, including details regarding any error messages, version, and platform.

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.

High level RCA: ROUND(c0, scale) on a double compiles to the Gandiva function round_float64_int32. For scale < 20 it reads a lookup table. For any other scale it calls llvm.exp10.

LLVM (http://llvm.org/):
LLVM version 21.1.8
Optimized build.
TRIPLE RESULT
arm64-apple-darwin27.2.0 FAIL (no libcall available for fexp10)
arm64-apple-darwin FAIL (no libcall available for fexp10)
arm64-apple-macosx26.0.0 OK (___exp10)
arm64-apple-macosx11.0.0 OK (___exp10)
x86_64-apple-darwin19.0.0 FAIL (no libcall available for fexp10)
x86_64-apple-macosx10.15.0 OK (___exp10)

Gandiva (engine.cc:149-150, ...MakeTargetMachineBuilder(
const Configuration& conf)) calls getDefaultTargetTriple() [LLVM: Support/TargetParser]
-> llvm::Triple [LLVM: TargetParser/Triple.cpp]
-> JITTargetMachineBuilder / TargetMachine [Gandiva builds it (engine.cc:146-244); class is LLVM: ExecutionEngine/Orc + Target/AArch64]
-> RuntimeLibcallsInfo [LLVM: IR/RuntimeLibcalls.cpp]
-> darwinHasExp10(TT) [LLVM: IR/RuntimeLibcalls.cpp, the decision]
-> LegalizeDAG [LLVM: CodeGen/SelectionDAG/LegalizeDAG.cpp:2136, the failure]

Component(s)

C++, Gandiva

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions