Add a flag to remove producers section

This should help handle instances like the recent Webpack bug and is
also a useful flag in its own right. For now it's set to `false`, but if
the Webpack bug persists through to tomorrow we likely want to publish a
version of `wasm-bindgen` with it default set to `true`.
This commit is contained in:
Alex Crichton
2019-02-14 10:08:24 -08:00
parent 7c7acf2aa6
commit 5e3cedfaf2
3 changed files with 26 additions and 15 deletions

View File

@ -27,6 +27,7 @@ pub struct Bindgen {
demangle: bool,
keep_debug: bool,
remove_name_section: bool,
remove_producers_section: bool,
emit_start: bool,
// Experimental support for `WeakRefGroup`, an upcoming ECMAScript feature.
// Currently only enable-able through an env var.
@ -57,6 +58,7 @@ impl Bindgen {
demangle: true,
keep_debug: false,
remove_name_section: false,
remove_producers_section: false,
emit_start: true,
weak_refs: env::var("WASM_BINDGEN_WEAKREF").is_ok(),
threads: threads_config(),
@ -130,6 +132,11 @@ impl Bindgen {
self
}
pub fn remove_producers_section(&mut self, remove: bool) -> &mut Bindgen {
self.remove_producers_section = remove;
self
}
pub fn emit_start(&mut self, emit: bool) -> &mut Bindgen {
self.emit_start = emit;
self
@ -159,6 +166,7 @@ impl Bindgen {
.strict_validate(false)
.generate_dwarf(self.keep_debug)
.generate_name_section(!self.remove_name_section)
.generate_producers_section(!self.remove_producers_section)
.parse(&contents)
.context("failed to parse input file as wasm")?;
let stem = match &self.out_name {