mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-15 02:11:08 +00:00
Separate compilation and linker phases (#376)
Separate between compilation and linker phases to allow deploy time linking and back-porting era compiler changes to fix #91. Unlinked contract binaries (caused by missing libraries or missing factory dependencies in turn) are emitted as raw ELF object. Few drive by fixes: - #98 - A compiler panic on missing libraries definitions. - Fixes some incosistent type forwarding in JSON output (empty string vs. null object). - Remove the unused fallback for size optimization setting. - Remove the broken `--lvm-ir` mode. - CI workflow fixes. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Signed-off-by: xermicus <bigcyrill@hotmail.com> Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,47 +1,36 @@
|
||||
//! The deploy code function.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::polkavm::context::code_type::CodeType;
|
||||
use crate::polkavm::context::function::runtime;
|
||||
use crate::polkavm::context::Context;
|
||||
use crate::polkavm::Dependency;
|
||||
use crate::polkavm::WriteLLVM;
|
||||
|
||||
/// The deploy code function.
|
||||
/// Is a special function that is only used by the front-end generated code.
|
||||
#[derive(Debug)]
|
||||
pub struct DeployCode<B, D>
|
||||
pub struct DeployCode<B>
|
||||
where
|
||||
B: WriteLLVM<D>,
|
||||
D: Dependency + Clone,
|
||||
B: WriteLLVM,
|
||||
{
|
||||
/// The deploy code AST representation.
|
||||
inner: B,
|
||||
/// The `D` phantom data.
|
||||
_pd: PhantomData<D>,
|
||||
}
|
||||
|
||||
impl<B, D> DeployCode<B, D>
|
||||
impl<B> DeployCode<B>
|
||||
where
|
||||
B: WriteLLVM<D>,
|
||||
D: Dependency + Clone,
|
||||
B: WriteLLVM,
|
||||
{
|
||||
/// A shortcut constructor.
|
||||
pub fn new(inner: B) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
_pd: PhantomData,
|
||||
}
|
||||
Self { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, D> WriteLLVM<D> for DeployCode<B, D>
|
||||
impl<B> WriteLLVM for DeployCode<B>
|
||||
where
|
||||
B: WriteLLVM<D>,
|
||||
D: Dependency + Clone,
|
||||
B: WriteLLVM,
|
||||
{
|
||||
fn declare(&mut self, context: &mut Context<D>) -> anyhow::Result<()> {
|
||||
fn declare(&mut self, context: &mut Context) -> anyhow::Result<()> {
|
||||
let function_type = context.function_type::<inkwell::types::BasicTypeEnum>(vec![], 0);
|
||||
context.add_function(
|
||||
runtime::FUNCTION_DEPLOY_CODE,
|
||||
@@ -54,7 +43,7 @@ where
|
||||
self.inner.declare(context)
|
||||
}
|
||||
|
||||
fn into_llvm(self, context: &mut Context<D>) -> anyhow::Result<()> {
|
||||
fn into_llvm(self, context: &mut Context) -> anyhow::Result<()> {
|
||||
context.set_current_function(runtime::FUNCTION_DEPLOY_CODE, None)?;
|
||||
|
||||
context.set_basic_block(context.current_function().borrow().entry_block());
|
||||
|
||||
Reference in New Issue
Block a user