summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-04-18 15:40:30 -0700
committerGitHub <noreply@github.com>2019-04-18 15:40:30 -0700
commit5becae69e29c876f3ba46d6746764e409bd7fd9b (patch)
treef0fee2c10772faf9466b3f5ec0828e98184e516c /src
parent9233afca9a27f8794fb0c8b79b5fa0d8e47060d4 (diff)
downloadbinaryen-5becae69e29c876f3ba46d6746764e409bd7fd9b.tar.gz
binaryen-5becae69e29c876f3ba46d6746764e409bd7fd9b.tar.bz2
binaryen-5becae69e29c876f3ba46d6746764e409bd7fd9b.zip
Reland emitting of DataCount section (#2027)
This reverts commit cb2d63586c08a3dd194d2b733ceb3f5051c081f8. The issues with feature validation were mostly resolved in #1993, and this PR finishes the job by adding feature flags to wasm-as to avoid emitting the DataCount section when bulk-memory is not enabled.
Diffstat (limited to 'src')
-rw-r--r--src/tools/wasm-as.cpp6
-rw-r--r--src/wasm/wasm-binary.cpp11
2 files changed, 6 insertions, 11 deletions
diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp
index fb79eb7cf..20e51e31f 100644
--- a/src/tools/wasm-as.cpp
+++ b/src/tools/wasm-as.cpp
@@ -19,12 +19,12 @@
//
#include "support/colors.h"
-#include "support/command-line.h"
#include "support/file.h"
#include "wasm-io.h"
#include "wasm-s-parser.h"
#include "wasm-validator.h"
+#include "tool-options.h"
#include "tool-utils.h"
using namespace cashew;
@@ -35,7 +35,7 @@ int main(int argc, const char *argv[]) {
std::string symbolMap;
std::string sourceMapFilename;
std::string sourceMapUrl;
- Options options("wasm-as", "Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)");
+ ToolOptions options("wasm-as", "Assemble a .wast (WebAssembly text format) into a .wasm (WebAssembly binary format)");
options.extra["validate"] = "wasm";
options
.add("--output", "-o", "Output file (stdout if not specified)",
@@ -91,7 +91,7 @@ int main(int argc, const char *argv[]) {
Fatal() << "error in parsing input";
}
- wasm.features = FeatureSet::All;
+ options.applyFeatures(wasm);
if (options.extra["validate"] != "none") {
if (options.debug) std::cerr << "Validating..." << std::endl;
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index d6091e93c..f3642203d 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -317,14 +317,9 @@ void WasmBinaryWriter::writeDataCount() {
if (!wasm->features.hasBulkMemory() || !wasm->memory.segments.size()) {
return;
}
-
- // TODO(tlively): re-enable writing the data count once the default feature
- // set is no longer All, which causes validation errors in Emscripten due to
- // the presence of an unrecognized section.
-
- // auto start = startSection(BinaryConsts::Section::DataCount);
- // o << U32LEB(wasm->memory.segments.size());
- // finishSection(start);
+ auto start = startSection(BinaryConsts::Section::DataCount);
+ o << U32LEB(wasm->memory.segments.size());
+ finishSection(start);
}
void WasmBinaryWriter::writeDataSegments() {