summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-12-06 10:27:31 -0800
committerGitHub <noreply@github.com>2019-12-06 10:27:31 -0800
commit6f55457c3edbeed202f27647a2cf0482160af098 (patch)
treebe826c6dd946c17fd77d72be793be7220968068d
parent65c334d514347af34c16ba95fa416896654d6484 (diff)
downloadbinaryen-6f55457c3edbeed202f27647a2cf0482160af098.tar.gz
binaryen-6f55457c3edbeed202f27647a2cf0482160af098.tar.bz2
binaryen-6f55457c3edbeed202f27647a2cf0482160af098.zip
Avoid errors in binaryen.js assertions builds, and enable ASSERTIONS in debug builds. (#2507)
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/js/binaryen.js-post.js6
2 files changed, 7 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f78070115..c040425a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -366,6 +366,7 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_js optimized "--closure 1")
target_link_libraries(binaryen_js optimized "--llvm-lto 1")
target_link_libraries(binaryen_js debug "--profiling")
+ target_link_libraries(binaryen_js debug "-s ASSERTIONS")
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD 14)
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD_REQUIRED ON)
install(TARGETS binaryen_js DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index d5943176e..3d732c1fc 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -2768,6 +2768,12 @@ Module['emitText'] = function(expr) {
};
// Parses a binary to a module
+
+// If building with Emscripten ASSERTIONS, there is a property added to
+// Module to guard against users mistakening using the removed readBinary()
+// API. We must defuse that carefully.
+Object.defineProperty(Module, 'readBinary', { writable: true });
+
Module['readBinary'] = function(data) {
var buffer = allocate(data, 'i8', ALLOC_NORMAL);
var ptr = Module['_BinaryenModuleRead'](buffer, data.length);