rustup update

This commit is contained in:
khyperia 2020-09-21 09:37:31 +02:00
parent bc003cf6a2
commit 6da1ac5474
6 changed files with 49 additions and 39 deletions

View File

@ -55,7 +55,7 @@ There are a few different components to this repo - for example, the [rfcs folde
rustup +nightly component add rust-src rustc-dev llvm-tools-preview
```
2) `cargo build`. Note the `rust-toolchain` file that specifies nightly, this is equivalent to passing `cargo +nightly build`, without having to type that out. (If you run that `rustup component add` in this directory, you don't need to pass +nightly either)
3) Run (i.e. compile a shader): This is pretty complicated right now, we're working on making the UX better. It involves passing `-Z codegen-backend` to rustc, and `-Z build-std=core` and `--target ./spirv-target.json` to cargo. However, both building the compiler, and compiling a sample test project (`build_libcore_test`) is automated by the script `build_libcore_test.sh`/`build_libcore_test.bat`. Feel free to inspect those scripts for what's needed, if you'd like to try yourself.
3) Run (i.e. compile a shader): This is pretty complicated right now, we're working on making the UX better. It involves passing `-Z codegen-backend` to rustc, and `-Z build-std=core` and `--target spirv-unknown-unknown` to cargo. However, both building the compiler, and compiling a sample test project (`build_libcore_test`) is automated by the script `build_libcore_test.sh`/`build_libcore_test.bat`. Feel free to inspect those scripts for what's needed, if you'd like to try yourself.
## Contributing

View File

@ -4,5 +4,5 @@ cargo build
set RUSTFLAGS=-Zcodegen-backend=%cd%/../target/debug/rustc_codegen_spirv.dll -Ccodegen-units=1
pushd build_libcore_test
cargo build -Z build-std=core --target ../spirv-target.json --release
cargo build -Z build-std=core --target spirv-unknown-unknown --release
popd

View File

@ -9,5 +9,5 @@ cargo build
export RUSTFLAGS="-Zcodegen-backend=$PWD/../target/debug/librustc_codegen_spirv.so -Ccodegen-units=1"
pushd build_libcore_test
cargo build -Z build-std=core --target ../spirv-target.json --release
cargo build -Z build-std=core --target spirv-unknown-unknown --release
popd

View File

@ -1,27 +0,0 @@
{
"arch": "spirv",
"cpu": "unknown",
"os": "unknown",
"vendor": "unknown",
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
"dll-prefix": "",
"dll-suffix": ".spv",
"exe-suffix": ".spv",
"crt-static-allows-dylibs": true,
"dynamic-linking": true,
"emit-debug-gdb-scripts": false,
"env": "",
"executables": true,
"has-elf-tls": false,
"linker-flavor": "ld",
"lld-flavor": "link",
"llvm-target": "no-llvm",
"max-atomic-width": 64,
"no-default-libraries": false,
"panic-strategy": "abort",
"staticlib-prefix": "",
"staticlib-suffix": ".spv",
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "32"
}

View File

@ -6,11 +6,8 @@ use crate::symbols::{parse_attr, SpirvAttribute};
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass};
use rustc_attr::InlineAttr;
use rustc_codegen_ssa::traits::{DeclareMethods, MiscMethods, PreDefineMethods, StaticMethods};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::mir::mono::{Linkage, Visibility};
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
use rustc_middle::ty::layout::FnAbiExt;
use rustc_middle::ty::{Instance, ParamEnv, Ty, TypeFoldable};
use rustc_span::def_id::DefId;
@ -215,6 +212,8 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> {
}
}
// Note: DeclareMethods is getting nuked soon, don't spend time fleshing out these impls.
// https://github.com/rust-lang/rust/pull/76872
impl<'tcx> DeclareMethods<'tcx> for CodegenCx<'tcx> {
fn declare_global(&self, name: &str, ty: Self::Type) -> Self::Value {
let ptr_ty = SpirvType::Pointer {
@ -287,9 +286,8 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
fn codegen_static(&self, def_id: DefId, _is_mutable: bool) {
let g = self.get_static(def_id);
let alloc = match self.tcx.const_eval_poly(def_id) {
Ok(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc,
Ok(val) => panic!("static const eval returned {:#?}", val),
let alloc = match self.tcx.eval_static_initializer(def_id) {
Ok(alloc) => alloc,
// Error has already been reported
Err(_) => return,
};

View File

@ -69,7 +69,7 @@ use rustc_session::config::{self, OptLevel, OutputFilenames, OutputType};
use rustc_session::Session;
use rustc_span::Symbol;
use rustc_target::spec::abi::Abi;
use rustc_target::spec::Target;
use rustc_target::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetTriple};
use std::any::Any;
use std::path::Path;
use std::{fs::File, io::Write, sync::Arc};
@ -95,6 +95,33 @@ fn is_blocklisted_fn(symbol_name: &str) -> bool {
symbol_name.contains("core..fmt..Debug")
}
fn target_options() -> Target {
Target {
llvm_target: "no-llvm".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "unknown".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".to_string(),
arch: "spirv".to_string(),
linker_flavor: LinkerFlavor::Ld,
options: TargetOptions {
dll_prefix: "".to_string(),
dll_suffix: ".spv".to_string(),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
allows_weak_linkage: false,
dynamic_linking: true,
crt_static_allows_dylibs: true,
// TODO: Investigate if main_needs_argc_argv is useful (for building exes)
main_needs_argc_argv: false,
..Default::default()
},
}
}
// TODO: Should this store Vec or Module?
struct SpirvModuleBuffer(Vec<u32>);
@ -133,6 +160,18 @@ impl CodegenBackend for SpirvCodegenBackend {
Box::new(SpirvMetadataLoader)
}
fn target_override(&self, opts: &config::Options) -> Option<Target> {
match opts.target_triple {
TargetTriple::TargetTriple(ref target_triple) => match &**target_triple {
// TODO: Do we want to match *everything* here, since, well, we only support one thing? that will allow
// folks to not specify --target spirv-unknown-unknown on the commandline.
"spirv-unknown-unknown" => Some(target_options()),
_ => None,
},
TargetTriple::TargetPath(_) => None,
}
}
fn provide(&self, providers: &mut Providers) {
// For now, rustc requires this to be provided.
providers.supported_target_features = |_, _| Default::default();