-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for wasmu and compile & run
- Loading branch information
1 parent
f72fc66
commit 3b87621
Showing
8 changed files
with
1,919 additions
and
152 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
# Brainfk -> WASM | ||
## Introduction | ||
This repo contains a brainfk compiler written in Rust which compiles code directly to wasm. Later the generated wasm file can be ran using wasmer. | ||
### Install Wasmer Runtime | ||
Follow this link to install wasmer-runtime | ||
https://docs.wasmer.io/ecosystem/wasmer/getting-started | ||
This repo contains a brainfk compiler written in Rust closely tied to wasm. | ||
|
||
### Example | ||
```shell | ||
$ cargo run | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.01s | ||
Running `target/debug/brainfk-rs` | ||
error: The following required arguments were not provided: | ||
--target <TARGET> | ||
<INPUT_FILE> | ||
<OUTPUT_FILE> | ||
### Features | ||
- Generate wasm from brainfk code | ||
- Compile and run brainfk code | ||
- Compile brainfk to wasmu (wasmer module serial format) which can run with wasmer-headless | ||
- Supports following backends | ||
- LLVM (uses LLVM 12) | ||
- Cranelift | ||
- Singlepass | ||
|
||
USAGE: | ||
brainfk-rs --target <TARGET> <INPUT_FILE> <OUTPUT_FILE> | ||
### Usage | ||
``` | ||
# JIT Compile & Execute brainfk code | ||
$ brainfk-rs run tests/files/hello.bf --backend cranelift | ||
Hello World! | ||
For more information try --help | ||
$ brainfk-rs generate-wasm tests/files/hello.bf hello.wasm --target wasi | ||
✔ Successfully generated wasm. | ||
$ cargo run -- tests/files/hello.f hello.wasm --target wasi | ||
Compiling brainfk-rs v0.1.0 (/root/Documents/brainfk-rs) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.91s | ||
Running `target/debug/brainfk-rs tests/files/hello.f abc.wasm --target wasi` | ||
$ brainfk-rs compile-wasmu tests/files/hello.bf hello.wasmu --backend cranelift | ||
✔ Compiled successfully to wasmu. | ||
Compiled file can be executed using wasmer-headless. | ||
$ wasmer run hello.wasm | ||
# Running in wasmer-headless | ||
$ ./wasmer-headless run hello.wasmu | ||
Hello World! | ||
``` | ||
### Support | ||
- [X] WASI (It uses STDIN and STDOUT) | ||
- [ ] Browser | ||
|
||
### Install Wasmer Runtime | ||
Follow this link to install wasmer-runtime | ||
https://docs.wasmer.io/ecosystem/wasmer/getting-started | ||
|
||
### TODO | ||
- [ ] Memory access validation and growth | ||
- [ ] Add support for JS/Browser | ||
- [ ] Integrate with wasmer and support run & compile | ||
- [x] Integrate with wasmer and support run & compile | ||
- [ ] Add testing | ||
- [ ] Add support for JS/Browser |
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
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
Oops, something went wrong.