rust/compiler
Alex Crichton 482a3d06c3 rustc: Add a new wasm ABI
This commit implements the idea of a new ABI for the WebAssembly target,
one called `"wasm"`. This ABI is entirely of my own invention
and has no current precedent, but I think that the addition of this ABI
might help solve a number of issues with the WebAssembly targets.

When `wasm32-unknown-unknown` was first added to Rust I naively
"implemented an abi" for the target. I then went to write `wasm-bindgen`
which accidentally relied on details of this ABI. Turns out the ABI
definition didn't match C, which is causing issues for C/Rust interop.
Currently the compiler has a "wasm32 bindgen compat" ABI which is the
original implementation I added, and it's purely there for, well,
`wasm-bindgen`.

Another issue with the WebAssembly target is that it's not clear to me
when and if the default C ABI will change to account for WebAssembly's
multi-value feature (a feature that allows functions to return multiple
values). Even if this does happen, though, it seems like the C ABI will
be guided based on the performance of WebAssembly code and will likely
not match even what the current wasm-bindgen-compat ABI is today. This
leaves a hole in Rust's expressivity in binding WebAssembly where given
a particular import type, Rust may not be able to import that signature
with an updated C ABI for multi-value.

To fix these issues I had the idea of a new ABI for WebAssembly, one
called `wasm`. The definition of this ABI is "what you write
maps straight to wasm". The goal here is that whatever you write down in
the parameter list or in the return values goes straight into the
function's signature in the WebAssembly file. This special ABI is for
intentionally matching the ABI of an imported function from the
environment or exporting a function with the right signature.

With the addition of a new ABI, this enables rustc to:

* Eventually remove the "wasm-bindgen compat hack". Once this
  ABI is stable wasm-bindgen can switch to using it everywhere.
  Afterwards the wasm32-unknown-unknown target can have its default ABI
  updated to match C.

* Expose the ability to precisely match an ABI signature for a
  WebAssembly function, regardless of what the C ABI that clang chooses
  turns out to be.

* Continue to evolve the definition of the default C ABI to match what
  clang does on all targets, since the purpose of that ABI will be
  explicitly matching C rather than generating particular function
  imports/exports.

Naturally this is implemented as an unstable feature initially, but it
would be nice for this to get stabilized (if it works) in the near-ish
future to remove the wasm32-unknown-unknown incompatibility with the C
ABI. Doing this, however, requires the feature to be on stable because
wasm-bindgen works with stable Rust.
2021-04-08 08:03:18 -07:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov 2021-04-07 13:07:14 +02:00
rustc_ast_lowering Rollup merge of #83935 - SNCPlay42:param-default-impl-trait, r=varkor 2021-04-07 13:07:15 +02:00
rustc_ast_passes rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_ast_pretty Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
rustc_attr Allow specifying alignment for functions 2021-04-05 17:36:51 -04:00
rustc_builtin_macros Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov 2021-04-07 13:07:14 +02:00
rustc_codegen_cranelift Add an Mmap wrapper to rustc_data_structures 2021-03-30 18:57:03 +02:00
rustc_codegen_llvm rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_codegen_ssa Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov 2021-04-07 13:07:14 +02:00
rustc_data_structures Auto merge of #83821 - camelid:improve-thinvec, r=petrochenkov 2021-04-06 09:57:12 +00:00
rustc_driver Rollup merge of #83895 - eggyal:issue-83883, r=jyn514 2021-04-06 17:42:31 +02:00
rustc_error_codes Bump cfgs 2021-04-04 14:57:05 -04:00
rustc_errors Document compiler/ with -Aprivate-intra-doc-links 2021-04-05 08:38:09 -04:00
rustc_expand Rollup merge of #83816 - JohnTitor:unused-doc-comments-on-macros, r=varkor 2021-04-07 13:07:12 +02:00
rustc_feature rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_fs_util Optimize away a fs::metadata call. 2021-01-06 08:33:15 -08:00
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Auto merge of #82958 - camelid:res-docs, r=petrochenkov 2021-04-08 02:43:31 +00:00
rustc_hir_pretty Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
rustc_incremental Also profile finishing the encoding. 2021-03-30 18:10:08 +02:00
rustc_index Add fixme comment to revert change once const_panic is stable 2021-04-03 13:07:03 +02:00
rustc_infer Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_interface Fix outdated crate names in rustc_interface::callbacks 2021-04-07 11:45:27 -05:00
rustc_lexer Return EOF_CHAR constant instead of magic char. 2021-01-07 13:20:04 +01:00
rustc_lint Trigger unused_doc_comments on macros at once 2021-04-04 05:06:51 +09:00
rustc_lint_defs Fix rustc_lint_defs documentation typo 2021-04-03 12:00:28 -03:00
rustc_llvm Manually set dso_local when its valid to do so 2021-04-03 00:00:29 +03:00
rustc_macros Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_metadata Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa 2021-04-05 00:24:33 +02:00
rustc_middle rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_mir Rollup merge of #83945 - SkiFire13:fix-83924, r=estebank 2021-04-07 13:07:17 +02:00
rustc_mir_build rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_parse Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
rustc_parse_format Rollup merge of #83348 - osa1:issue83344, r=jackh726 2021-03-28 01:33:13 +09:00
rustc_passes Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov 2021-04-07 13:07:14 +02:00
rustc_plugin_impl Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_privacy Update with comments 2021-03-23 17:16:20 +00:00
rustc_query_impl Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_query_system Enable debugging the dep-graph without debug-assertions. 2021-03-31 17:12:06 +02:00
rustc_resolve Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkor 2021-04-07 13:07:11 +02:00
rustc_save_analysis Remove hir::CrateItem. 2021-03-30 20:31:06 +02:00
rustc_serialize Auto merge of #83465 - michaelwoerister:safe-read_raw_bytes, r=cjgillot 2021-03-26 01:28:59 +00:00
rustc_session Remove the insta-stable cfg(wasm) 2021-04-07 23:09:56 +03:00
rustc_span rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_symbol_mangling Rollup merge of #80525 - devsnek:wasm64, r=nagisa 2021-04-05 00:24:23 +02:00
rustc_target rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
rustc_trait_selection Rollup merge of #83689 - estebank:cool-bears-hot-tip, r=davidtwco 2021-04-08 01:01:43 +02:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils Track bound vars 2021-03-31 10:15:27 -04:00
rustc_type_ir Remove nightly features in rustc_type_ir 2021-04-03 10:00:09 +02:00
rustc_typeck Rollup merge of #83952 - estebank:issue-83943, r=petrochenkov 2021-04-08 01:01:45 +02:00