Open eholk opened 8 years ago
It does need a wasm platform target. I'm not sure the triple but @kripken will know (I'd expect wasm-unknown-emscripten for wasm + the emscripten runtime).
The compiler already has a target for asm.js, asmjs-unknown-emscripten. This target sets target_pointer_width = "32"
, target_os = "emscripten"
, target_arch = "asmjs"
. For wasm the target spec can probably be exactly the same except that target_arch = "wasm"
.
The best way for mir2wasm to proceed for now is probably to create its own target spec and pass that to the session config (or wherever it goes).
Should we need an LLVM target triple in this case? We are not using LLVM in this path. Or is the triple used in some other way?
@kripken target triples are also how rustc thinks about targets. It may be true that mir2wasm can get by without actually defining a string that is a target triple, but mir2wasm's ultimate destiny is as a rustc backend.
In rustc a target triple is shorthand for a 'target spec', and that's the thing that we really do need to define since it impacts a variety of things, like the pointer width and various definitions used for conditional compilation.
Oh ok, got it.
The issue with
isize
failing on 64-bit systems that was recently fixed (#34) got me thinking, does rustc itself need to know it's compiling for Wasm? I feel like WebAssembly is really its own platform, so for example we should always usei32
forisize
regardless of the host architecture. Can this be done just by havingmir2wasm
pass certain flags to the code it imports from rustc, or does rustc actually need to be modified to have a WebAssembly platform target?