Commit ed3fe11d authored by Per Lindgren's avatar Per Lindgren

rust example test1

parent c618827e
......@@ -14,6 +14,21 @@
"kind": "build",
"isDefault": true
}
},
{
"label": "cargo build",
"type": "shell",
"command": "cargo rustc --release -- -C linker=true --emit=llvm-ir,llvm-bc",
"options": {
"cwd": "${workspaceFolder}/rust"
},
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
\ No newline at end of file
......@@ -27,4 +27,8 @@ Conseqitive re-build is done from the `build` directory using `make`.
$ cd ctest
$ clang -S -emit-llvm test1.c
$ opt -load ../build/skeleton/libSkeletonPass.* -callgirl test1.ll -o dummy.ll
$
$ cd rust
$ cargo rustc --release -- -C linker=true --emit=llvm-ir,llvm-bc
$ opt -load build/callgirl/libCallgirlPass.so -print-callgirl rust/target/release/deps/rust-*.ll -o dummy.ll
```
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cargo src/main",
"type": "shell",
"command": "cargo rustc --release -- -C linker=true --emit=llvm-ir,llvm-bc",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "cargo test1",
"type": "shell",
"command": "cargo rustc --release --example test1 -- -C linker=true --emit=llvm-ir,llvm-bc",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
\ No newline at end of file
[[package]]
name = "panic-abort"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rust"
version = "0.1.0"
dependencies = [
"panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c14a66511ed17b6a8b4256b868d7fd207836d891db15eea5195dbcaf87e630f"
......@@ -5,6 +5,7 @@ authors = ["pln <Per Lindgren>"]
# edition = "2018"
[dependencies]
panic-abort = "0.3.1"
[profile.dev]
panic = "abort"
......@@ -13,4 +14,4 @@ panic = "abort"
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
lto = true # better optimizations
#![no_std]
#![no_main]
extern crate panic_abort;
use core::ptr;
#[inline(never)]
fn f1() -> u32 {
unsafe { ptr::read_volatile(&0) }
}
#[no_mangle]
fn main() {
f1();
}
// cargo rustc --release -- -C linker=true --emit=llvm-ir,llvm-bc
#![no_std]
#![feature(compiler_builtins_lib)]
#![feature(lang_items)]
#![feature(core_intrinsics)]
#![no_main]
use core::intrinsics;
use core::panic::PanicInfo;
extern crate panic_abort;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
unsafe { intrinsics::abort() }
}
use core::ptr;
#[inline(never)]
fn f1() -> u32 {
0
unsafe { ptr::read_volatile(&0) }
}
#[no_mangle]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment