mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-16 22:41:24 +00:00
Add a flag to remove the wasm name section
This commit adds a `--remove-name-section` flag to the `wasm-bindgen` command which will remove the `name` section of the wasm file, used to indicate the names of functions typically used in debugging. This flag is off-by-default and will primarily be controlled by wasm-pack, typically being passed by default with `wasm-pack build --release`. Closes #1021
This commit is contained in:
@ -116,6 +116,7 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
|
||||
pub fn finalize(&mut self, module_name: &str) -> Result<(String, String), Error> {
|
||||
self.parse_wasm_names();
|
||||
self.write_classes()?;
|
||||
|
||||
self.bind("__wbindgen_object_clone_ref", &|me| {
|
||||
@ -1689,7 +1690,6 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
|
||||
fn gc(&mut self) {
|
||||
self.parse_wasm_names();
|
||||
gc::Config::new()
|
||||
.demangle(self.config.demangle)
|
||||
.keep_debug(self.config.keep_debug || self.config.debug)
|
||||
@ -1700,6 +1700,14 @@ impl<'a> Context<'a> {
|
||||
let module = mem::replace(self.module, Module::default());
|
||||
let module = module.parse_names().unwrap_or_else(|p| p.1);
|
||||
*self.module = module;
|
||||
if self.config.remove_name_section {
|
||||
self.module.sections_mut().retain(|s| {
|
||||
match s {
|
||||
Section::Name(_) => false,
|
||||
_ => true,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn describe(&mut self, name: &str) -> Option<Descriptor> {
|
||||
|
Reference in New Issue
Block a user