Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 115 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ libc = "0.2.53"
tempfile = "3.0.7"
gimli = { git = "https://github.com/gimli-rs/gimli.git" }
indexmap = "1.0.2"
object = "0.12.0"

# Uncomment to use local checkout of cranelift
#[patch."https://github.com/CraneStation/cranelift.git"]
Expand All @@ -39,5 +40,9 @@ indexmap = "1.0.2"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" }

[patch.crates-io]
faerie = { git = "https://github.com/m4b/faerie.git" }
object = { git = "https://github.com/gimli-rs/object.git" }

[profile.dev.overrides."*"]
opt-level = 3
2 changes: 1 addition & 1 deletion config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ fi

export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
export RUST_LOG=warn # display metadata load errors
export RUSTC_LOG=warn # display metadata load errors
2 changes: 1 addition & 1 deletion src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> {
let _: Result<()> = sections.for_each_mut(|id, section| {
if !section.writer.slice().is_empty() {
artifact
.declare_with(id.name(), Decl::debug_section(), section.writer.take())
.declare_with(id.name(), Decl::section(SectionKind::Debug), section.writer.take())
.unwrap();
}
Ok(())
Expand Down
41 changes: 33 additions & 8 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option<File>) ->
fn run_aot<'a, 'tcx: 'a>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
metadata: EncodedMetadata,
_need_metadata_module: bool,
need_metadata_module: bool,
log: &mut Option<File>,
) -> Box<CodegenResults> {
let new_module = |name: String| {
Expand Down Expand Up @@ -166,6 +166,37 @@ fn run_aot<'a, 'tcx: 'a>(
rustc_incremental::save_dep_graph(tcx);
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));

let metadata_module = if need_metadata_module {
use rustc::mir::mono::CodegenUnitNameBuilder;

let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
let metadata_cgu_name = cgu_name_builder
.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata"))
.as_str()
.to_string();

let mut metadata_artifact =
faerie::Artifact::new(crate::build_isa(tcx.sess).triple().clone(), metadata_cgu_name.clone());
crate::metadata::write_metadata(tcx, &mut metadata_artifact);

let tmp_file = tcx
.output_filenames(LOCAL_CRATE)
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));

let obj = metadata_artifact.emit().unwrap();
std::fs::write(&tmp_file, obj).unwrap();

Some(CompiledModule {
name: metadata_cgu_name,
kind: ModuleKind::Metadata,
object: Some(tmp_file),
bytecode: None,
bytecode_compressed: None,
})
} else {
None
};

Box::new(CodegenResults {
crate_name: tcx.crate_name(LOCAL_CRATE),
modules: vec![emit_module(
Expand All @@ -184,13 +215,7 @@ fn run_aot<'a, 'tcx: 'a>(
} else {
None
},
metadata_module: Some(CompiledModule {
name: "dummy_metadata".to_string(),
kind: ModuleKind::Metadata,
object: None,
bytecode: None,
bytecode_compressed: None,
}),
metadata_module,
crate_hash: tcx.crate_hash(LOCAL_CRATE),
metadata,
windows_subsystem: None, // Windows is not yet supported
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(rustc_private, never_type, decl_macro)]
#![allow(intra_doc_link_resolution_failure)]

extern crate flate2;
extern crate rustc;
extern crate rustc_allocator;
extern crate rustc_codegen_ssa;
Expand Down
Loading