summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-io.cpp')
-rw-r--r--src/wasm/wasm-io.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index c3192efbf..ebc9af8de 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -72,11 +72,21 @@ void ModuleWriter::writeBinary(Module& wasm, std::string filename) {
if (debug) std::cerr << "writing binary to " << filename << "\n";
BufferWithRandomAccess buffer(debug);
WasmBinaryWriter writer(&wasm, buffer, debug);
- writer.setDebugInfo(debugInfo);
+ // if debug info is used, then we want to emit the names section
+ writer.setNamesSection(debugInfo);
+ std::unique_ptr<std::ofstream> sourceMapStream;
+ if (sourceMapFilename.size()) {
+ sourceMapStream = make_unique<std::ofstream>();
+ sourceMapStream->open(sourceMapFilename);
+ writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
+ }
if (symbolMap.size() > 0) writer.setSymbolMap(symbolMap);
writer.write();
Output output(filename, Flags::Binary, debug ? Flags::Debug : Flags::Release);
buffer.writeTo(output);
+ if (sourceMapStream) {
+ sourceMapStream->close();
+ }
}
void ModuleWriter::write(Module& wasm, std::string filename) {
@@ -88,4 +98,3 @@ void ModuleWriter::write(Module& wasm, std::string filename) {
}
}
-