mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2025-02-27 06:15:59 +00:00
Remove all references to wasm
This commit is contained in:
parent
c2996046ed
commit
213db43d68
@ -1,8 +1,8 @@
|
||||
setlocal
|
||||
cargo build
|
||||
|
||||
set RUSTFLAGS=-Zcodegen-backend=%cd%/target/debug/rustc_codegen_spirv.dll -Ccodegen-units=1
|
||||
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
|
||||
cargo build -Z build-std=core --target ../spirv-target.json --release
|
||||
popd
|
||||
|
@ -9,8 +9,5 @@ cargo build
|
||||
export RUSTFLAGS="-Zcodegen-backend=$PWD/../target/debug/librustc_codegen_spirv.so -Ccodegen-units=1"
|
||||
|
||||
pushd build_libcore_test
|
||||
# Use wasm32 because it's a relatively simple platform - if the x86 libcore is used, there's all sorts of "feature sse2
|
||||
# not found" and the like, and our spirv backend is never reached. With wasm32, it at least gets reached.
|
||||
# (We probably want to add our own target eventually)
|
||||
cargo build -Z build-std=core --target ../spirv-target.json --release
|
||||
popd
|
||||
|
@ -1,10 +1,4 @@
|
||||
setlocal
|
||||
|
||||
(set /p nightly=)<rust-toolchain
|
||||
|
||||
echo %nightly%
|
||||
|
||||
rustup install %nightly%
|
||||
rustup default %nightly%
|
||||
rustup install nightly
|
||||
rustup component add rust-src rustc-dev llvm-tools-preview
|
||||
rustup target add wasm32-unknown-unknown
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
rustup install nightly
|
||||
rustup component add rust-src rustc-dev llvm-tools-preview
|
||||
rustup target add wasm32-unknown-unknown
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"arch": "wasm32",
|
||||
"arch": "spirv",
|
||||
"cpu": "unknown",
|
||||
"os": "unknown",
|
||||
"vendor": "unknown",
|
||||
|
@ -69,6 +69,11 @@ impl<'tcx> CodegenCx<'tcx> {
|
||||
llfn
|
||||
}
|
||||
|
||||
// The call graph of how this is reachable is a little tangled, so:
|
||||
// MiscMethods::get_fn -> get_fn_ext -> declare_fn_ext
|
||||
// MiscMethods::get_fn_addr -> get_fn_ext -> declare_fn_ext
|
||||
// PreDefineMethods::predefine_fn -> declare_fn_ext
|
||||
// DeclareMethods::declare_fn -> declare_fn_ext (as of right now, this is never called)
|
||||
fn declare_fn_ext(
|
||||
&self,
|
||||
name: &str,
|
||||
|
@ -66,6 +66,7 @@ use rustc_serialize::json;
|
||||
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 std::any::Any;
|
||||
use std::path::Path;
|
||||
@ -114,17 +115,42 @@ impl CodegenBackend for SpirvCodegenBackend {
|
||||
}
|
||||
|
||||
fn provide(&self, providers: &mut Providers) {
|
||||
rustc_symbol_mangling::provide(providers);
|
||||
|
||||
providers.supported_target_features = |_tcx, _cnum| {
|
||||
// Temp hack to make wasm target work
|
||||
[("simd128".to_string(), None)].iter().cloned().collect()
|
||||
// For now, rustc requires this to be provided.
|
||||
providers.supported_target_features = |_, _| Default::default();
|
||||
// This is a lil weird: so, we obviously don't support C ABIs at all. However, libcore does declare some extern
|
||||
// C functions:
|
||||
// https://github.com/rust-lang/rust/blob/5fae56971d8487088c0099c82c0a5ce1638b5f62/library/core/src/slice/cmp.rs#L119
|
||||
// However, those functions will be implemented by compiler-builtins:
|
||||
// https://github.com/rust-lang/rust/blob/5fae56971d8487088c0099c82c0a5ce1638b5f62/library/core/src/lib.rs#L23-L27
|
||||
// This theoretically then should be fine to leave as C, but, there's no backend hook for
|
||||
// FnAbi::adjust_for_cabi, causing it to panic:
|
||||
// https://github.com/rust-lang/rust/blob/5fae56971d8487088c0099c82c0a5ce1638b5f62/compiler/rustc_target/src/abi/call/mod.rs#L603
|
||||
// So, treat any extern "C" functions as actually being Rust ABI, to be able to compile libcore with arch=spirv.
|
||||
providers.fn_sig = |tcx, def_id| {
|
||||
// We can't capture the old fn_sig and just call that, because fn_sig is a `fn`, not a `Fn`, i.e. it can't
|
||||
// capture variables. Fortunately, the defaults are exposed (thanks rustdoc), so use that instead.
|
||||
let result = (rustc_interface::DEFAULT_QUERY_PROVIDERS.fn_sig)(tcx, def_id);
|
||||
result.map_bound(|mut inner| {
|
||||
if inner.abi == Abi::C {
|
||||
inner.abi = Abi::Rust;
|
||||
}
|
||||
inner
|
||||
})
|
||||
};
|
||||
// Temp hack to make wasm target work
|
||||
providers.wasm_import_module_map = |_tcx, _crate| Default::default();
|
||||
}
|
||||
|
||||
fn provide_extern(&self, _providers: &mut Providers) {}
|
||||
fn provide_extern(&self, providers: &mut Providers) {
|
||||
// See comments in provide(), only this time we use the default *extern* provider.
|
||||
providers.fn_sig = |tcx, def_id| {
|
||||
let result = (rustc_interface::DEFAULT_EXTERN_QUERY_PROVIDERS.fn_sig)(tcx, def_id);
|
||||
result.map_bound(|mut inner| {
|
||||
if inner.abi == Abi::C {
|
||||
inner.abi = Abi::Rust;
|
||||
}
|
||||
inner
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
fn codegen_crate<'tcx>(
|
||||
&self,
|
||||
|
Loading…
Reference in New Issue
Block a user