Skip to content

How to compile with STANDALONE_WASM #358

@syrusakbary

Description

@syrusakbary

I've been trying to play with the new emscripten option STANDALONE_WASM (from emscripten-core/emscripten#9461 ), but all my attempts have been unsuccessful.

How STANDALONE_WASM can be enabled with the emsdk?

I tried so far:

Incoming SDK

./emsdk install sdk-incoming-64bit
./emsdk activate sdk-incoming-64bit

# and then
source ./emsdk_env.sh

But then, when trying to compile I got this error:

➜  tests git:(incoming) emcc hello_world.cpp -s STANDALONE_WASM=1
cache:INFO: generating system asset: is_vanilla.txt... (this will be cached in "/Users/syrusakbary/.emscripten_cache/is_vanilla.txt" for subsequent builds)
cache:INFO:  - ok
shared:INFO: (Emscripten: Running sanity checks)
shared:ERROR: STANDALONE_WASM is only available in the upstream wasm backend path

Mix incoming/upstream

Then, I activated upstream:

./emsdk install latest-upstream
./emsdk activate latest-upstream

Changing the ~/.emscripten file, to have incoming:

import os
LLVM_ROOT = '/Users/syrusakbary/Development/emsdk/upstream/bin'
# EMSCRIPTEN_ROOT = '/Users/syrusakbary/Development/emsdk/upstream/emscripten'
EMSCRIPTEN_ROOT = '/Users/syrusakbary/Development/emsdk/emscripten/incoming'
EMSCRIPTEN_NATIVE_OPTIMIZER = '/Users/syrusakbary/Development/emsdk/emscripten/incoming_64bit_optimizer/optimizer'
BINARYEN_ROOT = '/Users/syrusakbary/Development/emsdk/upstream'
NODE_JS = '/Users/syrusakbary/Development/emsdk/node/12.9.1_64bit/bin/node'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = '/var/folders/l5/vjn0dbf96fx3rd6d2vx2mcxm0000gn/T'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

But still fails:

➜  tests git:(incoming) emcc hello_world.cpp -o hello.wasm
cache:INFO: generating system library: libc.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libcompiler_rt.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libcompiler_rt.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc-wasm.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libc-wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libdlmalloc.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libdlmalloc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libpthreads_stub.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libpthreads_stub.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libcompiler_rt_wasm.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libcompiler_rt_wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc_rt_wasm.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libc_rt_wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libstandalonewasm.a... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/libstandalonewasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system asset: generated_struct_info.json... (this will be cached in "/Users/syrusakbary/.emscripten_cache/wasm-obj/generated_struct_info.json" for subsequent builds)
cache:INFO:  - ok
Unknown option '--standalone-wasm'
shared:ERROR: '/Users/syrusakbary/Development/emsdk/upstream/bin/wasm-emscripten-finalize /var/folders/l5/vjn0dbf96fx3rd6d2vx2mcxm0000gn/T/emscripten_temp_SyKPuo/hello.wasm -o /var/folders/l5/vjn0dbf96fx3rd6d2vx2mcxm0000gn/T/emscripten_temp_SyKPuo/hello.wasm.o.wasm --detect-features --no-legalize-javascript-ffi --global-base=1024 --standalone-wasm' failed (1)

Any idea on how can I start using it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions