From da91cbbd5bb8cb925dee4a5c6ab6d66588cb2c8f Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 25 Sep 2022 00:00:24 +0200 Subject: added external fn putchard, and added link flag to export symbols from elf file --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 945d588..b660416 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,16 @@ use llvm_kaleidoscope_rs::{ }; use std::collections::HashMap; -use std::io::Read; +use std::io::{Read, Write}; + +#[no_mangle] +#[inline(never)] +pub extern "C" fn putchard(c: libc::c_double) -> f64 { + std::io::stdout() + .write(&[c as u8]) + .expect("Failed to write to stdout!"); + 0f64 +} fn main_loop(mut parser: Parser) where -- cgit v1.2.3