From cfa647c9fb0474687014de8d3f0b6c9f0d56a88b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 19 Nov 2019 17:05:22 -0800 Subject: Add a --strip-dwarf pass (#2454) This pass strips DWARF debug sections, but not other debug sections. This is useful when emitting source maps, as we do need the SourceMapURL section, but the DWARF sections are not longer necessary (and we've seen a testcase where they are massively large, so big the wasm can't even be loaded in a browser...). Also contains a trivial one-line fix in --extract-function which was necessary to create the testcase here: that pass extracts a function from a wasm file (like llvm-extract) but it didn't check if an export already existed for the function. --- src/passes/ExtractFunction.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/passes/ExtractFunction.cpp') diff --git a/src/passes/ExtractFunction.cpp b/src/passes/ExtractFunction.cpp index 01daf3504..fbc1aa7c4 100644 --- a/src/passes/ExtractFunction.cpp +++ b/src/passes/ExtractFunction.cpp @@ -49,12 +49,14 @@ struct ExtractFunction : public Pass { module->memory.segments.clear(); module->table.segments.clear(); // leave just an export for the thing we want - module->exports.clear(); - auto* export_ = new Export; - export_->name = name; - export_->value = name; - export_->kind = ExternalKind::Function; - module->addExport(export_); + if (!module->getExportOrNull(name)) { + module->exports.clear(); + auto* export_ = new Export; + export_->name = name; + export_->value = name; + export_->kind = ExternalKind::Function; + module->addExport(export_); + } } }; -- cgit v1.2.3