]> git.lizzy.rs Git - rust.git/commitdiff
Disable define_function to prevent crashing on things cranelift doesn't yet support
authorbjorn3 <bjorn3@users.noreply.github.com>
Wed, 18 Jul 2018 11:43:17 +0000 (13:43 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Wed, 18 Jul 2018 11:43:17 +0000 (13:43 +0200)
example.rs
src/base.rs
src/lib.rs

index 94215a50fc1b029c7ec812980eabed579dd869d4..7dc816aa7dc9118e16524570acda523addf6cc6b 100644 (file)
@@ -1,5 +1,6 @@
 #![feature(no_core, lang_items)]
 #![no_core]
+#![allow(dead_code)]
 
 #[lang="sized"]
 trait Sized {}
@@ -52,14 +53,14 @@ fn bcd(b: bool, a: u8) -> u8 {
 }
 
 // FIXME make calls work
-/*fn call() {
+fn call() {
     abc(42);
 }
 
 fn indirect_call() {
     let f: fn() = call;
     f();
-}*/
+}
 
 enum BoolOption {
     Some(bool),
index 6f72fadf487263486390147e1621471382cde7dd..31eb6e462bfd9fded5d592a93b3bf6801251af69 100644 (file)
@@ -50,7 +50,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend
                 }
 
                 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();
             }
             inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)),
index dc640838b6b846d58066e55efb87d18b5b534428..e02c431b21b6f4ef70541cac6be9fa077161196c 100644 (file)
@@ -192,27 +192,29 @@ fn codegen_crate<'a, 'tcx>(
 
         tcx.sess.warn("Compiled everything");
 
-        module.finalize_all();
-
-        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" {
-            if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" {
-                continue;
+        // TODO: this doesn't work most of the time
+        if false {
+            module.finalize_all();
+            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" {
+                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");