diff --git a/src/tools/wasm-merge.cpp b/src/tools/wasm-merge.cpp index 7c61f19a006..bfce9f0cdc2 100644 --- a/src/tools/wasm-merge.cpp +++ b/src/tools/wasm-merge.cpp @@ -778,14 +778,6 @@ Input source maps can be specified by adding an -ism option right after the modu } } - // If we didn't validate after each merged module, validate once at the very - // end. This won't catch problems at the earliest point, but is still useful. - if (!PassRunner::getPassDebug() && options.passOptions.validate && - !WasmValidator().validate(merged)) { - std::cout << merged << '\n'; - Fatal() << "error in validating final merged"; - } - // Fuse imports and exports now that everything is all together in the merged // module. fuseImportsAndExports(options.passOptions); @@ -808,6 +800,13 @@ Input source maps can be specified by adding an -ism option right after the modu passRunner.run(); } + // Without pass-debug mode, validate once at the very end. + if (!PassRunner::getPassDebug() && options.passOptions.validate && + !WasmValidator().validate(merged)) { + std::cout << merged << '\n'; + Fatal() << "error in validating final merged"; + } + // Output. if (options.extra.count("output") > 0) { ModuleWriter writer(options.passOptions);