Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JIT configs for aarch64 #1929

Merged
merged 2 commits into from
Mar 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions datafusion-jit/src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps worth linking to bytecodealliance/wasmtime#2907 in the comment so we know to reenable pic when it's supported upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

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 {
Expand All @@ -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| {
Expand Down