- Add zigcc, zigc++ scripts because cmake doens't accept a compiler with spaces in the name like "zig cc".
- The zigcc/zigc++ scripts can also add a target for cross-compiling as shown here.
- Disable threads (perhaps cmake cross-compiling needs to be set up?).
- Use a static build (otherwise cmake emits a .so - again, do we need cmake cross-compiling here?).
ninja
stalls on the final links: it just hangs. To solve that, runninja wasm-opt
and so forth manually, as a specific build target works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Build with | |
// | |
// -pthread -s PROXY_TO_PTHREAD -s EXIT_RUNTIME | |
// | |
#include <stdlib.h> | |
#include <emscripten.h> | |
#include <emscripten/threading.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 "tests/core/test_atomic_cxx.cpp" | |
# 1 "<built-in>" 1 | |
# 1 "<built-in>" 3 | |
# 355 "<built-in>" 3 | |
# 1 "<command line>" 1 | |
# 1 "<built-in>" 2 | |
# 1 "tests/core/test_atomic_cxx.cpp" 2 | |
# 13 "tests/core/test_atomic_cxx.cpp" | |
# 1 "/home/azakai/Dev/emscripten/cache/sysroot/include/c++/v1/atomic" 1 3 | |
# 577 "/home/azakai/Dev/emscripten/cache/sysroot/include/c++/v1/atomic" 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.wasm | |
temp | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" int foo(); | |
int main() { | |
foo(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
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: