Test object::write backend on travis

This commit is contained in:
bjorn3 2019-10-19 10:56:35 +02:00
parent ecd9c4f2e3
commit bb5cefe838
3 changed files with 12 additions and 2 deletions

View File

@ -21,3 +21,6 @@ env:
- RUST_BACKTRACE=1
# Reduce amount of benchmark runs as they are slow.
- COMPILE_RUNS=2 RUN_RUNS=2
CG_CLIF_COMPILE_FLAGS:
- ""
- "--features backend_object"

View File

@ -10,14 +10,14 @@ edition = "2018"
crate-type = ["dylib"]
[features]
backend_object = ["object/write"]
backend_object = ["object/write", "cranelift-object"]
[dependencies]
# These have to be in sync with each other
cranelift = { git = "https://github.com/CraneStation/cranelift.git" }
cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" }
cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" }
cranelift-object = { git = "https://github.com/CraneStation/cranelift.git" }
cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true }
target-lexicon = "0.8.1"
faerie = "0.11.0"

View File

@ -5,9 +5,13 @@ use rustc::session::Session;
use cranelift_module::{FuncId, Module};
use faerie::*;
#[cfg(feature = "backend_object")]
use object::{SectionKind, RelocationKind, RelocationEncoding};
#[cfg(feature = "backend_object")]
use object::write::*;
use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection};
#[cfg(feature = "backend_object")]
use cranelift_object::*;
use gimli::SectionId;
@ -41,6 +45,7 @@ impl WriteMetadata for faerie::Artifact {
}
}
#[cfg(feature = "backend_object")]
impl WriteMetadata for object::write::Object {
fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>, _is_like_osx: bool) {
let segment = self.segment_name(object::write::StandardSegment::Data).to_vec();
@ -108,6 +113,7 @@ impl WriteDebugInfo for FaerieProduct {
}
}
#[cfg(feature = "backend_object")]
impl WriteDebugInfo for ObjectProduct {
type SectionId = (object::write::SectionId, object::write::SymbolId);
@ -158,6 +164,7 @@ impl Emit for FaerieProduct {
}
}
#[cfg(feature = "backend_object")]
impl Emit for ObjectProduct {
fn emit(self) -> Vec<u8> {
self.object.write().unwrap()