Disable define_function to prevent crashing on things cranelift doesn't yet support
This commit is contained in:
parent
9615f3a137
commit
9a9054ad23
3 changed files with 26 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
||||||
#![feature(no_core, lang_items)]
|
#![feature(no_core, lang_items)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[lang="sized"]
|
#[lang="sized"]
|
||||||
trait Sized {}
|
trait Sized {}
|
||||||
|
@ -52,14 +53,14 @@ fn bcd(b: bool, a: u8) -> u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME make calls work
|
// FIXME make calls work
|
||||||
/*fn call() {
|
fn call() {
|
||||||
abc(42);
|
abc(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn indirect_call() {
|
fn indirect_call() {
|
||||||
let f: fn() = call;
|
let f: fn() = call;
|
||||||
f();
|
f();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
enum BoolOption {
|
enum BoolOption {
|
||||||
Some(bool),
|
Some(bool),
|
||||||
|
|
|
@ -50,7 +50,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
context.func = f;
|
context.func = f;
|
||||||
cx.module.define_function(func_id, context).unwrap();
|
// TODO: cranelift doesn't yet support some of the things needed
|
||||||
|
// cx.module.define_function(func_id, context).unwrap();
|
||||||
|
|
||||||
context.clear();
|
context.clear();
|
||||||
}
|
}
|
||||||
inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)),
|
inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)),
|
||||||
|
|
38
src/lib.rs
38
src/lib.rs
|
@ -192,27 +192,29 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||||
|
|
||||||
tcx.sess.warn("Compiled everything");
|
tcx.sess.warn("Compiled everything");
|
||||||
|
|
||||||
module.finalize_all();
|
// TODO: this doesn't work most of the time
|
||||||
|
if false {
|
||||||
|
module.finalize_all();
|
||||||
|
tcx.sess.warn("Finalized everything");
|
||||||
|
|
||||||
tcx.sess.warn("Finalized everything");
|
for (inst, func_id) in def_id_fn_id_map.iter() {
|
||||||
|
//if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" {
|
||||||
for (inst, func_id) in def_id_fn_id_map.iter() {
|
if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" {
|
||||||
//if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" {
|
continue;
|
||||||
if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" {
|
}
|
||||||
continue;
|
let finalized_function: *const u8 = module.finalize_function(*func_id);
|
||||||
|
/*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) };
|
||||||
|
let mut res = 0u32;
|
||||||
|
f(&mut res);
|
||||||
|
tcx.sess.warn(&format!("ret_42 returned {}", res));*/
|
||||||
|
let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) };
|
||||||
|
let mut res = false;
|
||||||
|
f(&mut res, &3, false);
|
||||||
|
tcx.sess.warn(&format!("option_unwrap_or returned {}", res));
|
||||||
}
|
}
|
||||||
let finalized_function: *const u8 = module.finalize_function(*func_id);
|
|
||||||
/*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) };
|
|
||||||
let mut res = 0u32;
|
|
||||||
f(&mut res);
|
|
||||||
tcx.sess.warn(&format!("ret_42 returned {}", res));*/
|
|
||||||
let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) };
|
|
||||||
let mut res = false;
|
|
||||||
f(&mut res, &3, false);
|
|
||||||
tcx.sess.warn(&format!("option_unwrap_or returned {}", res));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.finish();
|
module.finish();
|
||||||
|
}
|
||||||
|
|
||||||
tcx.sess.fatal("unimplemented");
|
tcx.sess.fatal("unimplemented");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue