diff options
author | Derek Schuff <dschuff@chromium.org> | 2018-11-14 13:03:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 13:03:30 -0800 |
commit | 7e9f7f62d230f7ed083c0c2d425ae47dac4f513f (patch) | |
tree | 0c9967b8d9708160b5fef2eef6be8ab4046a22dd /src/tools | |
parent | 37d82ba9574d440a89b1d7f91af89cd30b35b158 (diff) | |
download | binaryen-7e9f7f62d230f7ed083c0c2d425ae47dac4f513f.tar.gz binaryen-7e9f7f62d230f7ed083c0c2d425ae47dac4f513f.tar.bz2 binaryen-7e9f7f62d230f7ed083c0c2d425ae47dac4f513f.zip |
Add wasm-emscripten-finalize flag to separate data segments into a file (#1741)
This writes the data section into a file suitable for use with emscripten's
--memory-init-file flag
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/wasm-emscripten-finalize.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 4c9f8df36..495ed5df9 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -40,6 +40,7 @@ int main(int argc, const char *argv[]) { std::string inputSourceMapFilename; std::string outputSourceMapFilename; std::string outputSourceMapUrl; + std::string dataSegmentFile; bool emitBinary = true; bool debugInfo = false; bool legalizeJavaScriptFFI = true; @@ -94,6 +95,9 @@ int main(int argc, const char *argv[]) { .add("--output-source-map-url", "-osu", "Emit specified string as source map URL", Options::Arguments::One, [&outputSourceMapUrl](Options *o, const std::string& argument) { outputSourceMapUrl = argument; }) + .add("--separate-data-segments", "", "Separate data segments to a file", + Options::Arguments::One, + [&dataSegmentFile](Options *o, const std::string& argument) { dataSegmentFile = argument;}) .add_positional("INFILE", Options::Arguments::One, [&infile](Options *o, const std::string& argument) { infile = argument; @@ -161,6 +165,10 @@ int main(int argc, const char *argv[]) { generator.generateDynCallThunks(); generator.generateJSCallThunks(numReservedFunctionPointers); std::string metadata = generator.generateEmscriptenMetadata(dataSize, initializerFunctions, numReservedFunctionPointers); + if (!dataSegmentFile.empty()) { + Output memInitFile(dataSegmentFile, Flags::Binary, Flags::Release); + generator.separateDataSegments(&memInitFile); + } if (options.debug) { std::cerr << "Module after:\n"; |