Encode a custom "producers" section in wasm files

This commit implements WebAssembly/tool-conventions#65 for wasm files
produced by the Rust compiler. This adds a bit of metadata to wasm
modules to indicate that the file's language includes Rust and the
file's "processed-by" tools includes rustc.

The thinking with this section is to eventually have telemetry in
browsers tracking all this.
This commit is contained in:
Alex Crichton
2018-11-19 12:05:21 -08:00
parent 9e8a982a23
commit 089a50411f
2 changed files with 112 additions and 0 deletions

View File

@@ -692,6 +692,11 @@ fn link_natively(sess: &Session,
if sess.opts.target_triple.triple() == "wasm32-unknown-unknown" {
wasm::rewrite_imports(&out_filename, &codegen_results.crate_info.wasm_imports);
wasm::add_producer_section(
&out_filename,
&sess.edition().to_string(),
option_env!("CFG_VERSION").unwrap_or("unknown"),
);
}
}