Rollup merge of #56075 - alexcrichton:wasm-producer-section, r=estebank

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:
Pietro Albini
2018-11-25 17:05:01 +01:00
committed by GitHub
2 changed files with 112 additions and 0 deletions

View File

@@ -700,6 +700,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"),
);
}
}