Skip to content

Commit bb5cefe

Browse files
committed
Test object::write backend on travis
1 parent ecd9c4f commit bb5cefe

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ env:
2121
- RUST_BACKTRACE=1
2222
# Reduce amount of benchmark runs as they are slow.
2323
- COMPILE_RUNS=2 RUN_RUNS=2
24+
CG_CLIF_COMPILE_FLAGS:
25+
- ""
26+
- "--features backend_object"

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ edition = "2018"
1010
crate-type = ["dylib"]
1111

1212
[features]
13-
backend_object = ["object/write"]
13+
backend_object = ["object/write", "cranelift-object"]
1414

1515
[dependencies]
1616
# These have to be in sync with each other
1717
cranelift = { git = "https://github.com/CraneStation/cranelift.git" }
1818
cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" }
1919
cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" }
20-
cranelift-object = { git = "https://github.com/CraneStation/cranelift.git" }
20+
cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true }
2121
target-lexicon = "0.8.1"
2222
faerie = "0.11.0"
2323

src/backend.rs

+7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ use rustc::session::Session;
55
use cranelift_module::{FuncId, Module};
66

77
use faerie::*;
8+
#[cfg(feature = "backend_object")]
89
use object::{SectionKind, RelocationKind, RelocationEncoding};
10+
#[cfg(feature = "backend_object")]
911
use object::write::*;
1012
use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection};
13+
14+
#[cfg(feature = "backend_object")]
1115
use cranelift_object::*;
1216

1317
use gimli::SectionId;
@@ -41,6 +45,7 @@ impl WriteMetadata for faerie::Artifact {
4145
}
4246
}
4347

48+
#[cfg(feature = "backend_object")]
4449
impl WriteMetadata for object::write::Object {
4550
fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>, _is_like_osx: bool) {
4651
let segment = self.segment_name(object::write::StandardSegment::Data).to_vec();
@@ -108,6 +113,7 @@ impl WriteDebugInfo for FaerieProduct {
108113
}
109114
}
110115

116+
#[cfg(feature = "backend_object")]
111117
impl WriteDebugInfo for ObjectProduct {
112118
type SectionId = (object::write::SectionId, object::write::SymbolId);
113119

@@ -158,6 +164,7 @@ impl Emit for FaerieProduct {
158164
}
159165
}
160166

167+
#[cfg(feature = "backend_object")]
161168
impl Emit for ObjectProduct {
162169
fn emit(self) -> Vec<u8> {
163170
self.object.write().unwrap()

0 commit comments

Comments
 (0)