From a64983257cdd1bce76d8478d79495d06145051d4 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Mon, 2 Jan 2023 21:46:08 -0800 Subject: [PATCH] Fix to use the default calling convention ... doesn't help. --- src/bin.rs | 5 +++-- src/runtime.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bin.rs b/src/bin.rs index 7aa9478..c04e036 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -91,10 +91,11 @@ fn main() -> Result<(), MainError> { .render_colored(72, StandardStream::stdout(ColorChoice::Auto)) .unwrap(); - let isa = isa::lookup(Triple::host())?.finish(settings::Flags::new(settings::builder()))?; + let platform = Triple::host(); + let isa = isa::lookup(platform.clone())?.finish(settings::Flags::new(settings::builder()))?; let object_builder = ObjectBuilder::new(isa, "example", default_libcall_names())?; let mut object_module = ObjectModule::new(object_builder); - let rtfuns = RuntimeFunctions::new(&mut object_module)?; + let rtfuns = RuntimeFunctions::new(&platform, &mut object_module)?; let _compiled = lil_tree.into_cranelift(&mut object_module, &rtfuns)?; diff --git a/src/runtime.rs b/src/runtime.rs index d807399..bcece5a 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -1,6 +1,7 @@ use cranelift_codegen::ir::{types, AbiParam, FuncRef, Function, Signature}; use cranelift_codegen::isa::CallConv; use cranelift_module::{FuncId, Linkage, Module, ModuleResult}; +use target_lexicon::Triple; use std::collections::HashMap; use thiserror::Error; @@ -16,7 +17,7 @@ pub enum RuntimeFunctionError { } impl RuntimeFunctions { - pub fn new(module: &mut M) -> ModuleResult { + pub fn new(platform: &Triple, module: &mut M) -> ModuleResult { let mut builtin_functions = HashMap::new(); let _referenced_functions = Vec::new(); @@ -29,7 +30,7 @@ impl RuntimeFunctions { &Signature { params: vec![string_param, int64_param], returns: vec![], - call_conv: CallConv::AppleAarch64, + call_conv: CallConv::triple_default(platform), }, )?; builtin_functions.insert("print".to_string(), print_id);