mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-25 08:14:12 +00:00
Merge branch 'master' into main
This commit is contained in:
commit
dd93edce2a
2
run.bat
2
run.bat
@ -1 +1 @@
|
||||
rustc +nightly -Zcodegen-backend=target\debug\rustc_codegen_spirv.dll --crate-type lib tests\empty.rs
|
||||
rustc +nightly -Zcodegen-backend=target\debug\rustc_codegen_spirv.dll --crate-name=empty --crate-type lib tests\empty.rs
|
46
src/lib.rs
46
src/lib.rs
@ -3,6 +3,7 @@
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_errors;
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_mir;
|
||||
#[macro_use]
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
@ -27,6 +28,8 @@ use rustc_target::spec::Target;
|
||||
use std::any::Any;
|
||||
use std::path::Path;
|
||||
|
||||
use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
|
||||
|
||||
pub struct NoLlvmMetadataLoader;
|
||||
|
||||
impl MetadataLoader for NoLlvmMetadataLoader {
|
||||
@ -52,9 +55,10 @@ impl CodegenBackend for TheBackend {
|
||||
fn provide(&self, providers: &mut Providers) {
|
||||
rustc_symbol_mangling::provide(providers);
|
||||
|
||||
// providers.supported_target_features = |tcx, _cnum| {
|
||||
// Default::default() // Just a dummy
|
||||
// };
|
||||
// jb-todo: target_features_whitelist is old name for supported_target_features
|
||||
providers.target_features_whitelist = |tcx, _cnum| {
|
||||
Default::default() // Just a dummy
|
||||
};
|
||||
providers.is_reachable_non_generic = |_tcx, _defid| true;
|
||||
providers.exported_symbols = |_tcx, _crate| &[];
|
||||
}
|
||||
@ -73,6 +77,42 @@ impl CodegenBackend for TheBackend {
|
||||
|
||||
println!("In codegen_crate");
|
||||
|
||||
let cgus = if tcx.sess.opts.output_types.should_codegen() {
|
||||
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1
|
||||
} else {
|
||||
// If only `--emit metadata` is used, we shouldn't perform any codegen.
|
||||
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
|
||||
&[]
|
||||
};
|
||||
|
||||
dbg!(cgus.len());
|
||||
|
||||
cgus.iter().for_each(|cgu| {
|
||||
dbg!(cgu.name());
|
||||
|
||||
let cgu = tcx.codegen_unit(cgu.name());
|
||||
let mono_items = cgu.items_in_deterministic_order(tcx);
|
||||
|
||||
for (mono_item, (linkage, visibility)) in mono_items {
|
||||
match mono_item {
|
||||
MonoItem::Fn(inst) => {
|
||||
let mut mir = ::std::io::Cursor::new(Vec::new());
|
||||
|
||||
crate::rustc_mir::util::write_mir_pretty(
|
||||
tcx,
|
||||
Some(inst.def_id()),
|
||||
&mut mir,
|
||||
).unwrap();
|
||||
let s = String::from_utf8(mir.into_inner()).unwrap();
|
||||
|
||||
println!("{}", s);
|
||||
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol)
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,14 @@
|
||||
#![feature(no_core)]
|
||||
#![feature(no_core, lang_items)]
|
||||
#![no_core]
|
||||
|
||||
#[lang = "sized"]
|
||||
pub trait Sized {}
|
||||
|
||||
#[lang = "unsize"]
|
||||
pub trait Unsize<T: ?Sized> {}
|
||||
|
||||
#[lang = "coerce_unsized"]
|
||||
pub trait CoerceUnsized<T> {}
|
||||
|
||||
|
||||
pub fn jasper() {}
|
Loading…
Reference in New Issue
Block a user