mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 17:41:05 +00:00
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "compiler-builtins"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,31 @@
|
||||
use std::{env, fs, io::Read, path::Path, process::Command};
|
||||
|
||||
fn main() {
|
||||
let lib = "libclang_rt.builtins-riscv32.a";
|
||||
let mut llvm_lib_dir = String::new();
|
||||
|
||||
Command::new("llvm-config")
|
||||
.args(["--libdir"])
|
||||
.output()
|
||||
.expect("llvm-config should be able to provide LD path")
|
||||
.stdout
|
||||
.as_slice()
|
||||
.read_to_string(&mut llvm_lib_dir)
|
||||
.expect("llvm-config output should be utf8");
|
||||
|
||||
let lib_path = std::path::PathBuf::from(llvm_lib_dir.trim())
|
||||
.join("linux")
|
||||
.join(lib);
|
||||
let archive = fs::read(lib_path).expect("clang builtins for riscv32 not fonud");
|
||||
|
||||
let out_dir = env::var_os("OUT_DIR").expect("has OUT_DIR");
|
||||
let archive_path = Path::new(&out_dir).join(lib);
|
||||
let len = archive.len();
|
||||
std::fs::write(archive_path, &archive).expect("can write to OUT_DIR");
|
||||
|
||||
let src_path = Path::new(&out_dir).join("compiler_rt.rs");
|
||||
let src = format!("pub static COMPILER_RT: &[u8; {len}] = include_bytes!(\"{lib}\");");
|
||||
fs::write(src_path, src).expect("can write to OUT_DIR");
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
include!(concat!(env!("OUT_DIR"), "/compiler_rt.rs"));
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "revive"
|
||||
name = "revive-cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
@@ -8,4 +8,4 @@ edition = "2021"
|
||||
[dependencies]
|
||||
hex = { workspace = true }
|
||||
evmil = { workspace = true }
|
||||
ir-tac = { path = "../ir-tac" }
|
||||
revive-ir = { path = "../ir" }
|
||||
@@ -1,5 +1,5 @@
|
||||
use evmil::bytecode::Disassemble;
|
||||
use ir_tac::cfg::{BasicBlockFormatOption, Program};
|
||||
use revive_ir::cfg::{BasicBlockFormatOption, Program};
|
||||
|
||||
fn main() {
|
||||
let hexcode = std::fs::read_to_string(std::env::args().nth(1).unwrap()).unwrap();
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "revive-environment"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "ir-tac"
|
||||
name = "revive-ir"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "lld-sys"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libc = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
cc = { workspace = true }
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::{io::Read, process::Command};
|
||||
|
||||
fn main() {
|
||||
let mut flags = String::new();
|
||||
Command::new("llvm-config")
|
||||
.args(["--cxxflags"])
|
||||
.output()
|
||||
.expect("llvm-config should be able to provide CXX flags")
|
||||
.stdout
|
||||
.as_slice()
|
||||
.read_to_string(&mut flags)
|
||||
.expect("llvm-config output should be utf8");
|
||||
|
||||
let mut builder = cc::Build::new();
|
||||
flags
|
||||
.split_whitespace()
|
||||
.fold(&mut builder, |builder, flag| builder.flag(flag))
|
||||
.cpp(true)
|
||||
.file("src/linker.cpp")
|
||||
.compile("liblinker.a");
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
extern "C" {
|
||||
pub fn LLDELFLink(args: *const *const libc::c_char, size: libc::size_t) -> libc::c_int;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "lld/Common/Driver.h"
|
||||
#include "lld/Common/CommonLinkerContext.h"
|
||||
#include "llvm/Support/CrashRecoveryContext.h"
|
||||
|
||||
extern "C" bool LLDELFLink(const char *argv[], size_t length)
|
||||
{
|
||||
bool canRunAgain;
|
||||
|
||||
{
|
||||
llvm::ArrayRef<const char *> args(argv, length);
|
||||
llvm::CrashRecoveryContext crc;
|
||||
if (!crc.RunSafely([&]()
|
||||
{ canRunAgain = lld::elf::link(args, llvm::outs(), llvm::errs(), false, false); }))
|
||||
return false;
|
||||
}
|
||||
|
||||
llvm::CrashRecoveryContext crc;
|
||||
return canRunAgain && crc.RunSafely([&]()
|
||||
{ lld::CommonLinkerContext::destroy(); });
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "revive-polkavm"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,14 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user