rust/src
Alex Crichton d889957dab rustc: Add a #[wasm_import_module] attribute
This commit adds a new attribute to the Rust compiler specific to the wasm
target (and no other targets). The `#[wasm_import_module]` attribute is used to
specify the module that a name is imported from, and is used like so:

    #[wasm_import_module = "./foo.js"]
    extern {
        fn some_js_function();
    }

Here the import of the symbol `some_js_function` is tagged with the `./foo.js`
module in the wasm output file. Wasm-the-format includes two fields on all
imports, a module and a field. The field is the symbol name (`some_js_function`
above) and the module has historically unconditionally been `"env"`. I'm not
sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd
like the ability to configure it!

The proposed ES module integration with wasm (aka a wasm module is "just another
ES module") requires that the import module of wasm imports is interpreted as an
ES module import, meaning that you'll need to encode paths, NPM packages, etc.
As a result, we'll need this to be something other than `"env"`!

Unfortunately neither our version of LLVM nor LLD supports custom import modules
(aka anything not `"env"`). My hope is that by the time LLVM 7 is released both
will have support, but in the meantime this commit adds some primitive
encoding/decoding of wasm files to the compiler. This way rustc postprocesses
the wasm module that LLVM emits to ensure it's got all the imports we'd like to
have in it.

Eventually I'd ideally like to unconditionally require this attribute to be
placed on all `extern { ... }` blocks. For now though it seemed prudent to add
it as an unstable attribute, so for now it's not required (as that'd force usage
of a feature gate). Hopefully it doesn't take too long to "stabilize" this!

cc rust-lang-nursery/rust-wasm#29
2018-03-22 13:16:38 -07:00
..
bootstrap rustc: Add a #[wasm_custom_section] attribute 2018-03-22 13:16:38 -07:00
build_helper
ci rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
dlmalloc@9b2dcac06c
doc Stabilize slice patterns without .. 2018-03-20 02:27:40 +03:00
etc Remove unused 'src/etc/ziggurat_tables.py' Python script. 2018-03-06 19:35:16 -05:00
grammar
jemalloc@1f5a28755e
liballoc Rollup merge of #49117 - nivkner:fixme_fixup3, r=estebank 2018-03-22 22:43:37 +08:00
liballoc_jemalloc
liballoc_system
libarena
libbacktrace
libcompiler_builtins@266ea0740a
libcore Rollup merge of #49038 - canndrew:replace-infallible-with-never, r=SimonSapin 2018-03-22 23:22:38 +08:00
libfmt_macros Add hexadecimal formatting of integers with fmt::Debug 2018-03-13 14:53:06 +01:00
libgetopts
libgraphviz mir dataflow: change graphviz output 2018-03-09 13:53:35 -05:00
liblibc@ed04152aac Update libc to 0.2.39 2018-03-12 10:07:48 -07:00
libpanic_abort
libpanic_unwind make #[unwind] attribute specify expectations more clearly 2018-02-20 19:12:52 -05:00
libproc_macro syntax: Make _ an identifier 2018-03-17 22:08:07 +03:00
libprofiler_builtins
librustc rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
librustc_allocator Rename Span::empty to Span::shrink_to_lo, add Span::shrink_to_hi 2018-03-17 22:12:21 +03:00
librustc_apfloat Stabilize slice patterns without .. 2018-03-20 02:27:40 +03:00
librustc_asan
librustc_back Replace many of the last references to readmes 2018-03-16 12:43:22 -05:00
librustc_borrowck Rollup merge of #49092 - mark-i-m:deptrack_readme, r=nikomatsakis 2018-03-20 07:15:19 +08:00
librustc_const_eval Stabilize slice patterns without .. 2018-03-20 02:27:40 +03:00
librustc_const_math Nuke ConstInt and Const*size 2018-03-08 08:34:10 +01:00
librustc_cratesio_shim
librustc_data_structures Convert SerializedDepGraph to be a struct-of-arrays 2018-03-19 19:45:35 -04:00
librustc_driver Rollup merge of #49092 - mark-i-m:deptrack_readme, r=nikomatsakis 2018-03-20 07:15:19 +08:00
librustc_errors Require the code mapper to be thread-safe 2018-03-15 00:43:03 +01:00
librustc_incremental Convert SerializedDepGraph to be a struct-of-arrays 2018-03-19 19:45:35 -04:00
librustc_lint Stabilize slice patterns without .. 2018-03-20 02:27:40 +03:00
librustc_llvm add compile fail tests 2018-03-15 16:36:02 +01:00
librustc_lsan
librustc_metadata rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
librustc_mir Rollup merge of #49216 - bjorn3:patch-1, r=estebank 2018-03-22 22:43:48 +08:00
librustc_msan
librustc_passes Fix type_dependent_defs ICE on method calls 2018-03-21 18:01:51 +00:00
librustc_platform_intrinsics
librustc_plugin Auto merge of #48524 - abonander:check-macro-stability, r=petrochenkov 2018-03-16 02:46:23 +00:00
librustc_privacy Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00
librustc_resolve Rollup merge of #49117 - nivkner:fixme_fixup3, r=estebank 2018-03-22 22:43:37 +08:00
librustc_save_analysis Rename Span::empty to Span::shrink_to_lo, add Span::shrink_to_hi 2018-03-17 22:12:21 +03:00
librustc_traits Implement Rule Implemented-From-Env 2018-03-20 15:13:44 +00:00
librustc_trans rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
librustc_trans_utils Rollup merge of #49117 - nivkner:fixme_fixup3, r=estebank 2018-03-22 22:43:37 +08:00
librustc_tsan
librustc_typeck rustc: Add a #[wasm_custom_section] attribute 2018-03-22 13:16:38 -07:00
librustdoc Rollup merge of #49189 - GuillaumeGomez:fix-implied-shortcut-links, r=QuietMisdreavus 2018-03-22 22:43:43 +08:00
libserialize Fix Decodable impl for Arc 2018-03-02 10:45:32 +01:00
libstd Rollup merge of #49038 - canndrew:replace-infallible-with-never, r=SimonSapin 2018-03-22 23:22:38 +08:00
libstd_unicode Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichton 2018-03-06 20:52:37 +08:00
libsyntax rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
libsyntax_ext Auto merge of #48917 - petrochenkov:import, r=oli-obk 2018-03-18 01:50:52 +00:00
libsyntax_pos Auto merge of #48917 - petrochenkov:import, r=oli-obk 2018-03-18 01:50:52 +00:00
libterm
libtest add stub for retrieving number of CPUs 2018-03-10 15:01:51 +01:00
libunwind make #[unwind] attribute specify expectations more clearly 2018-02-20 19:12:52 -05:00
llvm@6ceaaa4b01 Merge LLVM fix for undefined bss globals 2018-03-10 12:38:41 +00:00
llvm-emscripten@2717444753
rtstartup
rustc
rustllvm error via bug! instead of stderr+terminate 2018-03-15 16:51:58 +01:00
stdsimd@bcb720e558 update stdsimd 2018-03-21 15:43:06 -05:00
test rustc: Add a #[wasm_import_module] attribute 2018-03-22 13:16:38 -07:00
tools rustc: Add a #[wasm_custom_section] attribute 2018-03-22 13:16:38 -07:00
Cargo.lock Update Cargo to fix regression 2018-03-20 15:59:28 +03:00
Cargo.toml Automatically enable the clippy feature of rls if clippy builds 2018-03-16 18:24:08 +01:00
README.md Start moving to the rustc guide! 2018-02-23 13:20:56 -06:00
stage0.txt Update beta to version with fixed FreeBSD support from #49023. 2018-03-19 12:40:42 -07:00

This directory contains the source code of the rust project, including:

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc guide.

Their is also useful content in the following READMEs, which are gradually being moved over to the guide: