summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rwxr-xr-xcheck.py10
m---------test/emscripten0
3 files changed, 12 insertions, 8 deletions
diff --git a/README.md b/README.md
index b07d435db..a48ff1c60 100644
--- a/README.md
+++ b/README.md
@@ -109,13 +109,15 @@ Pass `--debug` on the command line to see debug info, about asm.js functions as
### wasm.js
+Update your emscripten configuration file, setting the `BINARYEN_ROOT` variable to point to the directory containing binaryen.
+
Run Emscripten's `emcc` command, passing it an additional flag:
```
-emcc -s 'BINARYEN="path-to-this-dir"' [whatever other emcc flags you want]
+emcc -s BINARYEN=1 [whatever other emcc flags you want]
```
-(Note the need for quotes on the path, and on the entire `BINARYEN=..` argument, due to how shell argument parsing works.) The `BINARYEN` flag tells it to emit code using `wasm.js`, and where to find `wasm.js` itself. The output `*.js` file will then contain the entire polyfill (`asm2wasm` translator + `wasm.js` interpreter). The asm.js code will be in `*.asm.js`.
+The `BINARYEN` flag tells it to emit code using `wasm.js`, and the `BINARYEN_ROOT` config variable tells where to find `wasm.js` itself. The output `*.js` file will then contain the entire polyfill (`asm2wasm` translator + `wasm.js` interpreter). The asm.js code will be in `*.asm.js`.
### C/C++ Source => asm2wasm => WebAssembly
@@ -144,13 +146,13 @@ s2wasm code.s > code.wast
You can also use Emscripten, which will do those steps for you (as well as link to system libraries, etc.). You can use either normal Emscripten, including it's "fastcomp" fork of LLVM, or you can use "vanilla" LLVM, that is, pure upstream LLVM without Emscripten's additions. With Vanilla LLVM, you can build with
````
-./emcc input.cpp -s 'BINARYEN="path-to-binaryen"'
+./emcc input.cpp -s BINARYEN=1
````
With normal Emscripten, you will need to tell it to use the WebAssembly backend, since its default is asm.js, by setting an env var,
````
-EMCC_WASM_BACKEND=1 ./emcc input.cpp -s 'BINARYEN="path-to-binaryen"'
+EMCC_WASM_BACKEND=1 ./emcc input.cpp -s BINARYEN=1
````
(without the env var, the `BINARYEN` option will make it use the asm.js backend, then `asm2wasm`).
diff --git a/check.py b/check.py
index 6e767c292..09326c6b1 100755
--- a/check.py
+++ b/check.py
@@ -48,6 +48,8 @@ BASE_DIR = os.path.abspath('test')
WATERFALL_BUILD_DIR = os.path.join(BASE_DIR, 'wasm-install')
BIN_DIR = os.path.abspath(os.path.join(WATERFALL_BUILD_DIR, 'wasm-install', 'bin'))
+os.environ['BINARYEN'] = os.getcwd()
+
def fetch_waterfall():
rev = open(os.path.join('test', 'revision')).read().strip()
try:
@@ -525,7 +527,7 @@ if has_vanilla_emcc and has_vanilla_llvm:
print '..', c
base = c.replace('.cpp', '').replace('.c', '')
expected = open(os.path.join('test', 'wasm_backend', base + '.txt')).read()
- command = [VANILLA_EMCC, '-o', 'a.wasm.js', '-s', 'BINARYEN="' + os.getcwd() + '"', os.path.join('test', 'wasm_backend', c), '-O1', '-s', 'ONLY_MY_CODE=1']
+ command = [VANILLA_EMCC, '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', 'wasm_backend', c), '-O1', '-s', 'ONLY_MY_CODE=1']
print '....' + ' '.join(command)
if os.path.exists('a.wasm.js'): os.unlink('a.wasm.js')
subprocess.check_call(command)
@@ -565,13 +567,13 @@ if has_emcc:
for method in [None, 'asm2wasm', 'wasm-s-parser', 'just-asm']:
for success in [1, 0]:
- command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN="' + os.getcwd() + '"', os.path.join('test', 'hello_world.c') ]
+ command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', 'hello_world.c') ]
if method:
command += ['-s', 'BINARYEN_METHOD="' + method + '"']
else:
method = 'wasm-s-parser' # this is the default
print method, ' : ', ' '.join(command), ' => ', success
- subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ subprocess.check_call(command)
def break_cashew():
asm = open('a.wasm.asm.js').read()
asm = asm.replace('"almost asm"', '"use asm"; var not_in_asm = [].length + (true || { x: 5 }.x);')
@@ -621,7 +623,7 @@ if has_emcc:
if os.path.exists('a.normal.js'): os.unlink('a.normal.js')
for opts in [[], ['-O1'], ['-O2'], ['-O3'], ['-Oz']]:
for method in ['asm2wasm', 'wasm-s-parser', 'just-asm']:
- command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN="' + os.getcwd() + '"', os.path.join('test', c)] + opts + extra
+ command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN=1', os.path.join('test', c)] + opts + extra
command += ['-s', 'BINARYEN_METHOD="' + method + '"']
subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print '....' + ' '.join(command)
diff --git a/test/emscripten b/test/emscripten
-Subproject eae355d2de1cb66693ef5eaac3381a206dad7a6
+Subproject 328820b69e4b87ee15b2309df8f9072fada9dce