Skip to content
Snippets Groups Projects
Commit ed3fe11d authored by Per Lindgren's avatar Per Lindgren
Browse files

rust example test1

parent c618827e
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,21 @@ ...@@ -14,6 +14,21 @@
"kind": "build", "kind": "build",
"isDefault": true "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`. ...@@ -27,4 +27,8 @@ Conseqitive re-build is done from the `build` directory using `make`.
$ cd ctest $ cd ctest
$ clang -S -emit-llvm test1.c $ clang -S -emit-llvm test1.c
$ opt -load ../build/skeleton/libSkeletonPass.* -callgirl test1.ll -o dummy.ll $ 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]] [[package]]
name = "rust" name = "rust"
version = "0.1.0" 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>"] ...@@ -5,6 +5,7 @@ authors = ["pln <Per Lindgren>"]
# edition = "2018" # edition = "2018"
[dependencies] [dependencies]
panic-abort = "0.3.1"
[profile.dev] [profile.dev]
panic = "abort" panic = "abort"
......
#![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] #![no_std]
#![feature(compiler_builtins_lib)]
#![feature(lang_items)]
#![feature(core_intrinsics)]
#![no_main] #![no_main]
use core::intrinsics; extern crate panic_abort;
use core::panic::PanicInfo;
#[panic_handler] use core::ptr;
fn panic(_info: &PanicInfo) -> ! {
unsafe { intrinsics::abort() }
}
#[inline(never)] #[inline(never)]
fn f1() -> u32 { fn f1() -> u32 {
0 unsafe { ptr::read_volatile(&0) }
} }
#[no_mangle] #[no_mangle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment