Skip to content

Remove asm2wasm #3042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ full changeset diff at the end of each section.

Current Trunk
-------------
- Remove asm2wasm, which supported Emscripten's fastcomp backend, after fastcomp
was removed.

v96
---
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ endfunction()
binaryen_add_executable(wasm-opt src/tools/wasm-opt.cpp)
binaryen_add_executable(wasm-shell src/tools/wasm-shell.cpp)
binaryen_add_executable(wasm-metadce src/tools/wasm-metadce.cpp)
binaryen_add_executable(asm2wasm src/tools/asm2wasm.cpp)
binaryen_add_executable(wasm2js src/tools/wasm2js.cpp)
binaryen_add_executable(wasm-emscripten-finalize src/tools/wasm-emscripten-finalize.cpp)
binaryen_add_executable(wasm-as src/tools/wasm-as.cpp)
Expand Down
59 changes: 1 addition & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ effective**:

Compilers using Binaryen include:

* [`asm2wasm`](https://github.com/WebAssembly/binaryen/blob/master/src/asm2wasm.h) which compiles asm.js to WebAssembly
* [`AssemblyScript`](https://github.com/AssemblyScript/assemblyscript) which compiles a subset of TypeScript to WebAssembly
* [`wasm2js`](https://github.com/WebAssembly/binaryen/blob/master/src/wasm2js.h) which compiles WebAssembly to JS
* [`Asterius`](https://github.com/tweag/asterius) which compiles Haskell to WebAssembly
Expand Down Expand Up @@ -168,9 +167,6 @@ This repository contains code that builds the following tools in `bin/`:
also run the spec test suite.
* **wasm-emscripten-finalize**: Takes a wasm binary produced by llvm+lld and
performs emscripten-specific passes over it.
* **asm2wasm**: An asm.js-to-WebAssembly compiler, using Emscripten's asm
optimizer infrastructure. This is used by Emscripten in Binaryen mode when it
uses Emscripten's fastcomp asm.js backend.
* **wasm-ctor-eval**: A tool that can execute C++ global constructors ahead of
time. Used by Emscripten.
* **binaryen.js**: A standalone JavaScript library that exposes Binaryen methods for [creating and optimizing WASM modules](https://github.com/WebAssembly/binaryen/blob/master/test/binaryen.js/hello-world.js). For builds, see [binaryen.js on npm](https://www.npmjs.com/package/binaryen) (or download it directly from [github](https://raw.githubusercontent.com/AssemblyScript/binaryen.js/master/index.js), [rawgit](https://cdn.rawgit.com/AssemblyScript/binaryen.js/master/index.js), or [unpkg](https://unpkg.com/binaryen@latest/index.js)).
Expand Down Expand Up @@ -323,66 +319,13 @@ Things keep to in mind with wasm2js's output:
int/float conversions do not trap, and so forth. There may also be slight
differences in corner cases of conversions, like non-trapping float to int.

### asm2wasm

Run

```
bin/asm2wasm [input.asm.js file]
```

This will print out a WebAssembly module in s-expression format to the console.

For example, try

```
$ bin/asm2wasm test/hello_world.asm.js
```

That input file contains

```javascript
function () {
"use asm";
function add(x, y) {
x = x | 0;
y = y | 0;
return x + y | 0;
}
return { add: add };
}
```

You should see something like this:

![example output](https://raw.github.com/WebAssembly/wasm-emscripten/master/media/example.png)

By default you should see pretty colors as in that image. Set `COLORS=0` in the
env to disable colors if you prefer that. On Linux and Mac, you can set
`COLORS=1` in the env to force colors (useful when piping to `more`, for
example). For Windows, pretty colors are only available when `stdout/stderr` are
not redirected/piped.

Pass `--debug` on the command line to see debug info, about asm.js functions as
they are parsed, etc.

### C/C++ Source ⇒ asm2wasm ⇒ WebAssembly

When using `emcc` with the `BINARYEN` option, it will use Binaryen to build to
WebAssembly. This lets you compile C and C++ to WebAssembly, with emscripten
using asm.js internally as a build step. Since emscripten's asm.js generation is
very stable, and asm2wasm is a fairly simple process, this method of compiling C
and C++ to WebAssembly is usable already. See the [emscripten
wiki](https://github.com/kripken/emscripten/wiki/WebAssembly) for more details
about how to use it.

## Testing

```
./check.py
```

(or `python check.py`) will run `wasm-shell`, `wasm-opt`, `asm2wasm`, etc. on the testcases in `test/`, and verify their outputs.
(or `python check.py`) will run `wasm-shell`, `wasm-opt`, etc. on the testcases in `test/`, and verify their outputs.

The `check.py` script supports some options:

Expand Down
46 changes: 0 additions & 46 deletions auto_update_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,6 @@
from scripts.test import wasm_opt


def update_asm_js_tests():
print('[ processing and updating testcases... ]\n')
for asm in shared.get_tests(shared.options.binaryen_test, ['.asm.js']):
basename = os.path.basename(asm)
for precise in [0, 1, 2]:
for opts in [1, 0]:
cmd = shared.ASM2WASM + [asm]
if 'threads' in basename:
cmd += ['--enable-threads']
wasm = asm.replace('.asm.js', '.fromasm')
if not precise:
cmd += ['--trap-mode=allow', '--ignore-implicit-traps']
wasm += '.imprecise'
elif precise == 2:
cmd += ['--trap-mode=clamp']
wasm += '.clamp'
if not opts:
wasm += '.no-opts'
if precise:
cmd += ['-O0'] # test that -O0 does nothing
else:
cmd += ['-O']
if 'debugInfo' in basename:
cmd += ['-g']
if 'noffi' in basename:
cmd += ['--no-legalize-javascript-ffi']
if precise and opts:
# test mem init importing
open('a.mem', 'wb').write(bytes(basename, 'utf-8'))
cmd += ['--mem-init=a.mem']
if basename[0] == 'e':
cmd += ['--mem-base=1024']
if '4GB' in basename:
cmd += ['--mem-max=4294967296']
if 'i64' in basename or 'wasm-only' in basename or 'noffi' in basename:
cmd += ['--wasm-only']
print(' '.join(cmd))
actual = support.run_command(cmd)
with open(os.path.join(shared.options.binaryen_test, wasm), 'w') as o:
o.write(actual)
if 'debugInfo' in basename:
cmd += ['--source-map', os.path.join(shared.options.binaryen_test, wasm + '.map'), '-o', 'a.wasm']
support.run_command(cmd)


def update_bin_fmt_tests():
print('\n[ checking binary format testcases... ]\n')
for wast in shared.get_tests(shared.options.binaryen_test, ['.wast']):
Expand Down Expand Up @@ -224,7 +179,6 @@ def update_spec_tests():

TEST_SUITES = OrderedDict([
('wasm-opt', wasm_opt.update_wasm_opt_tests),
('asm2wasm', update_asm_js_tests),
('wasm-dis', update_wasm_dis_tests),
('example', update_example_tests),
('ctor-eval', update_ctor_eval_tests),
Expand Down
3 changes: 0 additions & 3 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import unittest
from collections import OrderedDict

from scripts.test import asm2wasm
from scripts.test import binaryenjs
from scripts.test import lld
from scripts.test import shared
Expand Down Expand Up @@ -354,8 +353,6 @@ def run_unittest():
TEST_SUITES = OrderedDict([
('help-messages', run_help_tests),
('wasm-opt', wasm_opt.test_wasm_opt),
('asm2wasm', asm2wasm.test_asm2wasm),
('asm2wasm-binary', asm2wasm.test_asm2wasm_binary),
('wasm-dis', run_wasm_dis_tests),
('crash', run_crash_tests),
('dylink', run_dylink_tests),
Expand Down
149 changes: 0 additions & 149 deletions scripts/test/asm2wasm.py

This file was deleted.

Loading