diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-04-05 16:08:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 16:08:51 -0700 |
commit | fc13d0f3585318ada789b9f27421e667056e9a84 (patch) | |
tree | 7d1056029e89823a8c2b291413f68bd4b5e6ed70 /src/wasm/wasm-emscripten.cpp | |
parent | 2129cef6acbbe4acd5fd675fbb00c329e2220a40 (diff) | |
download | binaryen-fc13d0f3585318ada789b9f27421e667056e9a84.tar.gz binaryen-fc13d0f3585318ada789b9f27421e667056e9a84.tar.bz2 binaryen-fc13d0f3585318ada789b9f27421e667056e9a84.zip |
Add feature options to emscripten metadata (#1982)
Emscripten runs wasm-emscripten-finalize before running wasm-opt, so the target features section is stripped out before optimizations are run. One option would have been to add another wasm-opt invocation at the very end to strip the target features section, but dumping the features as metadata avoids the extra tool invocation. In the long run, it would be nice to have only as single binaryen invocation to do all the work that needs doing.
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 0c02c758e..3f521caf9 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -789,7 +789,8 @@ void printSet(std::ostream& o, C& c) { } std::string EmscriptenGlueGenerator::generateEmscriptenMetadata( - Address staticBump, std::vector<Name> const& initializerFunctions) { + Address staticBump, std::vector<Name> const& initializerFunctions, + FeatureSet features) { bool commaFirst; auto nextElement = [&commaFirst]() { if (commaFirst) { @@ -926,6 +927,15 @@ std::string EmscriptenGlueGenerator::generateEmscriptenMetadata( } }); meta << "\n ]\n"; + + meta << " \"features\": ["; + commaFirst = true; + meta << nextElement() << "\"--mvp-features\""; + features.iterFeatures([&](FeatureSet::Feature f) { + meta << nextElement() << "\"--enable-" << FeatureSet::toString(f) << '"'; + }); + meta << "\n ]\n"; + meta << "}\n"; return meta.str(); |