From 4427b856a5a77a8e35e5da409257379e0e3a79c8 Mon Sep 17 00:00:00 2001
From: Per <Per Lindgren>
Date: Tue, 27 Nov 2018 13:08:10 +0100
Subject: [PATCH] rust no_std compiles

---
 rust/{src => }/.gitignore |  0
 rust/Cargo.toml           | 11 ++++++++++-
 rust/src/main.rs          | 22 ++++++++++++++++++++--
 3 files changed, 30 insertions(+), 3 deletions(-)
 rename rust/{src => }/.gitignore (100%)

diff --git a/rust/src/.gitignore b/rust/.gitignore
similarity index 100%
rename from rust/src/.gitignore
rename to rust/.gitignore
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 4b1c249..98c2bc9 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -2,6 +2,15 @@
 name = "rust"
 version = "0.1.0"
 authors = ["pln <Per Lindgren>"]
-edition = "2018"
+# edition = "2018"
 
 [dependencies]
+
+[profile.dev]
+panic = "abort"
+
+[profile.release]
+panic = "abort"
+codegen-units = 1 # better optimizations
+debug = true # symbols are nice and they don't increase the size on Flash
+lto = true # better optimizations
\ No newline at end of file
diff --git a/rust/src/main.rs b/rust/src/main.rs
index 07c4d09..a3edf80 100644
--- a/rust/src/main.rs
+++ b/rust/src/main.rs
@@ -1,7 +1,25 @@
 #![no_std]
+#![feature(compiler_builtins_lib)]
+#![feature(lang_items)]
+#![feature(core_intrinsics)]
+#![no_main]
 
-//use core::ptr::read;
+use core::intrinsics;
+use core::panic::PanicInfo;
 
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+    unsafe { intrinsics::abort() }
+}
+
+#[inline(never)]
+fn f1() -> u32 {
+    0
+}
+
+#[no_mangle]
 fn main() {
-    
+    f1();
 }
+
+// cargo rustc --release -- -C linker=true --emit=llvm-ir,llvm-bc
-- 
GitLab