Skip to content

Commit 6f55457

Browse files
authored
Avoid errors in binaryen.js assertions builds, and enable ASSERTIONS in debug builds. (#2507)
1 parent 65c334d commit 6f55457

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ if(EMSCRIPTEN)
366366
target_link_libraries(binaryen_js optimized "--closure 1")
367367
target_link_libraries(binaryen_js optimized "--llvm-lto 1")
368368
target_link_libraries(binaryen_js debug "--profiling")
369+
target_link_libraries(binaryen_js debug "-s ASSERTIONS")
369370
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD 14)
370371
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD_REQUIRED ON)
371372
install(TARGETS binaryen_js DESTINATION ${CMAKE_INSTALL_BINDIR})

src/js/binaryen.js-post.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,6 +2768,12 @@ Module['emitText'] = function(expr) {
27682768
};
27692769

27702770
// Parses a binary to a module
2771+
2772+
// If building with Emscripten ASSERTIONS, there is a property added to
2773+
// Module to guard against users mistakening using the removed readBinary()
2774+
// API. We must defuse that carefully.
2775+
Object.defineProperty(Module, 'readBinary', { writable: true });
2776+
27712777
Module['readBinary'] = function(data) {
27722778
var buffer = allocate(data, 'i8', ALLOC_NORMAL);
27732779
var ptr = Module['_BinaryenModuleRead'](buffer, data.length);

0 commit comments

Comments
 (0)