Skip to content

Instantly share code, notes, and snippets.

(func $ThreadMain\28void*\29 (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(loop $label$1
(local.set $0
(call $__cxa_allocate_exception
(i32.const 4)
)
)
(block $label$2
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp
index 221629557..8381b0bb6 100644
--- a/src/tools/wasm-emscripten-finalize.cpp
+++ b/src/tools/wasm-emscripten-finalize.cpp
@@ -49,21 +49,21 @@ int main(int argc, const char* argv[]) {
std::string dataSegmentFile;
bool emitBinary = true;
bool debugInfo = false;
bool DWARF = false;
bool sideModule = false;
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $i32_=>_none (func (param i32)))
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(type $none_=>_i32 (func (result i32)))
(type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32)))
(type $i32_f64_i32_i32_i32_i32_=>_i32 (func (param i32 f64 i32 i32 i32 i32) (result i32)))
(type $i32_i32_=>_none (func (param i32 i32)))

Simple WasmBoxC Library Example

This shows how to easily sandbox a real-world library using WasmBoxC. Specifically we sandbox the zlib compression library.

To follow along with this, you can clone this gist and then do the following commands.

First, get the emsdk:

Sizes

(html+js+wasm)

Non-emscripten: 19,964 bytes
Emscripten:     11,086 bytes
diff --git a/test/wasm2js/emscripten-grow-no.2asm.js b/test/wasm2js/emscripten-grow-no.2asm.js
index 92a99dfb7..0444134ed 100644
--- a/test/wasm2js/emscripten-grow-no.2asm.js
+++ b/test/wasm2js/emscripten-grow-no.2asm.js
@@ -22,8 +22,10 @@ function asmFunc(global, env, buffer) {
var abort = env.abort;
var nan = global.NaN;
var infinity = global.Infinity;
- // EMSCRIPTEN_START_FUNCS;
- // EMSCRIPTEN_END_FUNCS;
diff --git a/test/wasm2js/dynamicLibrary.2asm.js b/test/wasm2js/dynamicLibrary.2asm.js
index 98332dead..9666eb5ae 100644
--- a/test/wasm2js/dynamicLibrary.2asm.js
+++ b/test/wasm2js/dynamicLibrary.2asm.js
@@ -50,23 +50,27 @@ function asmFunc(global, env, buffer) {
}
var memasmFunc = new ArrayBuffer(16777216);
-var assignasmFunc = (
- function(mem) {
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e987ba311..ec35cd4c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -184,6 +184,16 @@ ADD_SUBDIRECTORY(src/passes)
ADD_SUBDIRECTORY(src/support)
ADD_SUBDIRECTORY(src/wasm)
+# Object files
+SET(binaryen_objs
(module
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$v (func))
(import "spectest" "print" (func $print (param i32)))
(memory $0 1 1)
(global $sleeping (mut i32) (i32.const 0))
(global $__asyncify_state (mut i32) (i32.const 0))
(global $__asyncify_data (mut i32) (i32.const 0))
(export "asyncify_start_unwind" (func $asyncify_start_unwind))
(export "asyncify_stop_unwind" (func $asyncify_stop_unwind))
#!/bin/bash
~/Dev/emscripten/em++ -std=c++11 \
-I./libc/include -Oz -s SUPPORT_ERRNO=1 -s EXIT_RUNTIME=0 -s WASM_OBJECT_FILES=0 --llvm-lto 1 -s MALLOC=emmalloc --closure 1 -s ENVIRONMENT=node \
-fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden \
-DHB_TINY -DHB_USE_INTERNAL_QSORT \
-s 'EXPORTED_FUNCTIONS=["_malloc", "_hb_blob_create", "_hb_face_create", "_hb_font_create", "_hb_buffer_create", "_hb_buffer_add_utf8", "_hb_buffer_guess_segment_properties", "_hb_buffer_set_direction", "_hb_shape", "_hb_buffer_get_glyph_infos", "_hb_buffer_get_glyph_positions", "_hb_buffer_get_length", "_hb_buffer_destroy", "_hb_font_destroy", "_hb_face_destroy", "_hb_blob_destroy", "_hb_blob_get_length", "_hb_font_set_scale", "_free"]' \
libc/zephyr-string.c libc/main.c harfbuzz/src/harfbuzz.cc