diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-26 21:40:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 21:40:09 -0700 |
commit | ea5b5e20910d8b1773a2adeaad5c92a5f37d0cab (patch) | |
tree | fbb8f3dbd73829a82d70432658ac6e284861589d /src | |
parent | ad79b7d1a8773ea08203ebece5da49a432dd8877 (diff) | |
download | binaryen-ea5b5e20910d8b1773a2adeaad5c92a5f37d0cab.tar.gz binaryen-ea5b5e20910d8b1773a2adeaad5c92a5f37d0cab.tar.bz2 binaryen-ea5b5e20910d8b1773a2adeaad5c92a5f37d0cab.zip |
Make wasm-as emit the names section/debug info only with -g (#705)
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-as.cpp | 5 | ||||
-rw-r--r-- | src/wasm-binary.h | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp index 376c1288c..95e6c9371 100644 --- a/src/tools/wasm-as.cpp +++ b/src/tools/wasm-as.cpp @@ -28,6 +28,7 @@ using namespace cashew; using namespace wasm; int main(int argc, const char *argv[]) { + bool debugInfo = false; Options options("wasm-as", "Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)"); options.extra["validate"] = "wasm"; options @@ -46,6 +47,9 @@ int main(int argc, const char *argv[]) { } o->extra["validate"] = argument; }) + .add("--debuginfo", "-g", "Emit names section and debug info", + Options::Arguments::Zero, + [&](Options *o, const std::string &arguments) { debugInfo = true; }) .add_positional("INFILE", Options::Arguments::One, [](Options *o, const std::string &argument) { o->extra["infile"] = argument; @@ -78,6 +82,7 @@ int main(int argc, const char *argv[]) { if (options.debug) std::cerr << "binarification..." << std::endl; BufferWithRandomAccess buffer(options.debug); WasmBinaryWriter writer(&wasm, buffer, options.debug); + writer.setDebugInfo(debugInfo); writer.write(); if (options.debug) std::cerr << "writing to output..." << std::endl; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index a901412e0..3047d43b7 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -466,6 +466,7 @@ class WasmBinaryWriter : public Visitor<WasmBinaryWriter, void> { Module* wasm; BufferWithRandomAccess& o; bool debug; + bool debugInfo = true; MixedArena allocator; @@ -484,6 +485,10 @@ public: prepare(); } + void setDebugInfo(bool set) { + debugInfo = set; + } + void write() { writeHeader(); @@ -497,7 +502,7 @@ public: writeStart(); writeFunctions(); writeDataSegments(); - writeNames(); + if (debugInfo) writeNames(); finishUp(); } |