Repository navigation
Conversation
…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.
|
|
| int32_t scale); | ||
|
|
||
| protected: | ||
| // Compiles round(float64, int32) through the Gandiva JIT and evaluates it on the |
There was a problem hiding this comment.
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
…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.
| ARROW_LOG(INFO) << "Detected CPU Name : " << host_target->getCPU(); | ||
| ARROW_LOG(INFO) << "Detected CPU Features: [" |
There was a problem hiding this comment.
setFeatures() is absent in LLVM 8–9
getCPU() is absent in LLVM 8–12
Do we care? LLVM is from 2021 so we probably do not but I'm not sure if pipelines can enforce this in any way
|
|
||
| TEST_F(TestEngine, TestAddWithoutHostCpu) { | ||
| // target_host_cpu=false compiles for the generic CPU of the host triple | ||
| auto conf = TestConfiguration(); |
There was a problem hiding this comment.
TestConfiguration() returns a singleton.
Disabling host-CPU targeting leaves subsequent tests using generic targeting, making coverage order-dependent.
Use ConfigurationBuilder().build() like in cpp/src/gandiva/tests/cache_race_test.cc
p.s.
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:
Reviewed before submission by: