This is an automated email from the ASF dual-hosted git repository.

jiayuliu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new dd94fcf  Fix JIT configs for aarch64 (#1929)
dd94fcf is described below

commit dd94fcf088f4a4a4c1dfb5904f90a890c413cadd
Author: Dan Harris <[email protected]>
AuthorDate: Sat Mar 5 21:28:48 2022 -0500

    Fix JIT configs for aarch64 (#1929)
---
 datafusion-jit/src/jit.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/datafusion-jit/src/jit.rs b/datafusion-jit/src/jit.rs
index 225366b..e4450ad 100644
--- a/datafusion-jit/src/jit.rs
+++ b/datafusion-jit/src/jit.rs
@@ -42,6 +42,7 @@ pub struct JIT {
 }
 
 impl Default for JIT {
+    #[cfg(target_arch = "x86_64")]
     fn default() -> Self {
         let builder = 
JITBuilder::new(cranelift_module::default_libcall_names());
         let module = JITModule::new(builder);
@@ -51,6 +52,28 @@ impl Default for JIT {
             module,
         }
     }
+
+    #[cfg(target_arch = "aarch64")]
+    fn default() -> Self {
+        let mut flag_builder = settings::builder();
+        // On at least AArch64, "colocated" calls use shorter-range 
relocations,
+        // which might not reach all definitions; we can't handle that here, so
+        // we require long-range relocation types.
+        flag_builder.set("use_colocated_libcalls", "false").unwrap();
+        flag_builder.set("is_pic", "false").unwrap();
+        let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {
+            panic!("host machine is not supported: {}", msg);
+        });
+        let isa = isa_builder.finish(settings::Flags::new(flag_builder));
+        let builder =
+            JITBuilder::with_isa(isa, 
cranelift_module::default_libcall_names());
+        let module = JITModule::new(builder);
+        Self {
+            builder_context: FunctionBuilderContext::new(),
+            ctx: module.make_context(),
+            module,
+        }
+    }
 }
 
 impl JIT {
@@ -62,7 +85,13 @@ impl JIT {
     {
         let mut flag_builder = settings::builder();
         flag_builder.set("use_colocated_libcalls", "false").unwrap();
+
+        #[cfg(target_arch = "x86_64")]
         flag_builder.set("is_pic", "true").unwrap();
+
+        #[cfg(target_arch = "aarch64")]
+        flag_builder.set("is_pic", "false").unwrap();
+
         flag_builder.set("opt_level", "speed").unwrap();
         flag_builder.set("enable_simd", "true").unwrap();
         let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| {

Reply via email to