@@ -37,6 +37,8 @@ int main(int argc, const char *argv[]) {
3737 bool runOptimizationPasses = false ;
3838 Asm2WasmBuilder::TrapMode trapMode = Asm2WasmBuilder::TrapMode::JS;
3939 bool wasmOnly = false ;
40+ std::string binaryMapFile;
41+ std::string binaryMapUrl;
4042 std::string symbolMap;
4143 bool emitBinary = true ;
4244
@@ -101,9 +103,15 @@ int main(int argc, const char *argv[]) {
101103 [&legalizeJavaScriptFFI](Options *o, const std::string &) {
102104 legalizeJavaScriptFFI = false ;
103105 })
104- .add (" --debuginfo" , " -g" , " Emit names section and debug info (for debug info you must emit text, -S, for this to work )" ,
106+ .add (" --debuginfo" , " -g" , " Emit names section in wasm binary (or full debuginfo in wast )" ,
105107 Options::Arguments::Zero,
106108 [&](Options *o, const std::string &arguments) { passOptions.debugInfo = true ; })
109+ .add (" --binarymap-file" , " -bm" , " Emit binary map (if using binary output) to the specified file" ,
110+ Options::Arguments::One,
111+ [&binaryMapFile](Options *o, const std::string &argument) { binaryMapFile = argument; })
112+ .add (" --binarymap-url" , " -bu" , " Use specified string as binary map URL" ,
113+ Options::Arguments::One,
114+ [&binaryMapUrl](Options *o, const std::string &argument) { binaryMapUrl = argument; })
107115 .add (" --symbolmap" , " -s" , " Emit a symbol map (indexes => names)" ,
108116 Options::Arguments::One,
109117 [&](Options *o, const std::string &argument) { symbolMap = argument; })
@@ -132,7 +140,6 @@ int main(int argc, const char *argv[]) {
132140 }
133141
134142 Asm2WasmPreProcessor pre ;
135- // wasm binaries can contain a names section, but not full debug info
136143 pre .debugInfo = passOptions.debugInfo ;
137144 auto input (
138145 read_file<std::vector<char >>(options.extra [" infile" ], Flags::Text, options.debug ? Flags::Debug : Flags::Release));
@@ -200,7 +207,11 @@ int main(int argc, const char *argv[]) {
200207 writer.setDebugInfo (passOptions.debugInfo );
201208 writer.setSymbolMap (symbolMap);
202209 writer.setBinary (emitBinary);
203- writer.write (wasm, options.extra [" output" ]);
210+ if (emitBinary && binaryMapFile.size ()) {
211+ writer.writeBinary (wasm, options.extra [" output" ], binaryMapFile, binaryMapUrl);
212+ } else {
213+ writer.write (wasm, options.extra [" output" ]);
214+ }
204215
205216 if (options.debug ) std::cerr << " done." << std::endl;
206217}
0 commit comments