dmitry-chirkov-dremio commented on code in PR #55506:
URL: https://github.com/apache/arrow/pull/55506#discussion_r4559022797


##########
cpp/src/gandiva/engine.cc:
##########
@@ -117,9 +117,44 @@
 
 namespace gandiva {
 
+// Oldest macOS release for each architecture. Used as a floor and as the 
fallback when
+// the Darwin kernel version is missing or can't be converted.
+constexpr unsigned kMinMacOSMajorArm64 = 11;  // first Apple Silicon release
+constexpr unsigned kMinMacOSMinorArm64 = 0;
+constexpr unsigned kMinMacOSMajorX86 = 10;
+constexpr unsigned kMinMacOSMinorX86 = 15;
+
 extern const unsigned char kPrecompiledBitcode[];
 extern const size_t kPrecompiledBitcodeSize;
 
+llvm::Triple NormalizeDarwinTriple(llvm::Triple triple) {

Review Comment:
   Part of me wants to do something like this which is conditioned on 
https://github.com/llvm/llvm-project/pull/210674 making it into LLVM 24 (and 
then us supporting it). Thoughts?
   
   This is a bit wider change to clean up assumptions of the past since we are 
here anyway.
   
   ```c++
   Result<llvm::orc::JITTargetMachineBuilder> MakeTargetMachineBuilder(
       const Configuration& conf) {
     auto detected = llvm::orc::JITTargetMachineBuilder::detectHost();
     ARROW_ASSIGN_OR_RAISE(
         auto jtmb, AsArrowResult(detected, "Could not detect host: "));
   
     if (!conf.target_host_cpu()) {
       jtmb.setCPU("");
       jtmb.setFeatures("");
     }
   
   #if defined(__APPLE__) && LLVM_VERSION_MAJOR < 24
     auto& triple = jtmb.getTargetTriple();
     if (triple.getOS() == llvm::Triple::Darwin) {
       char version[64]{};
       size_t size = sizeof(version);
       if (sysctlbyname("kern.osproductversion", version, &size,
                       nullptr, 0) != 0) {
         return arrow::internal::IOErrorFromErrno(
             errno, "sysctlbyname failed for 'kern.osproductversion'");
       }
       triple.setOSName(std::string("macosx") + version);
     }
   #endif
   
     jtmb.setRelocationModel(llvm::Reloc::PIC_);
   
   #if LLVM_VERSION_MAJOR >= 18
     using CodeGenOptLevel = llvm::CodeGenOptLevel;
   #else
     using CodeGenOptLevel = llvm::CodeGenOpt::Level;
   #endif
     jtmb.setCodeGenOptLevel(
         conf.optimize() ? CodeGenOptLevel::Aggressive : CodeGenOptLevel::None);
   
     return jtmb;
   }```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to