diff options
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r-- | src/tools/wasm-opt.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 7b04f5449..2fd78a3da 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -43,7 +43,7 @@ using namespace wasm; // runs a command and returns its output TODO: portability, return code checking -std::string runCommand(std::string command) { +static std::string runCommand(std::string command) { #ifdef __linux__ std::string output; const int MAX_BUFFER = 1024; @@ -59,6 +59,15 @@ std::string runCommand(std::string command) { #endif } +static bool willRemoveDebugInfo(const std::vector<std::string>& passes) { + for (auto& pass : passes) { + if (pass == "strip" || pass == "strip-debug" || pass == "strip-dwarf") { + return true; + } + } + return false; +} + // // main // @@ -210,6 +219,10 @@ int main(int argc, const char* argv[]) { if (!translateToFuzz) { ModuleReader reader; + // Enable DWARF parsing if we were asked for debug info, and were not + // asked to remove it. + reader.setDWARF(options.passOptions.debugInfo && + !willRemoveDebugInfo(options.passes)); try { reader.read(options.extra["infile"], wasm, inputSourceMapFilename); } catch (ParseException& p) { |