File: README.md

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (95 lines) | stat: -rw-r--r-- 4,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<img alt="WasmKit Icon" src="https://raw.github.com/wiki/akkyie/wakit/images/wakit_icon.png" width="100px">

# WasmKit

**WasmKit** is a standalone and embeddable WebAssembly runtime implementation written in Swift.

## Usage

The best way to learn how to use WasmKit is to look at the [Examples](./Examples) directory.

### Command Line Tool

WasmKit provides a command line tool to run WebAssembly binaries compliant with WASI.

```sh
$ git clone https://github.com/swiftwasm/WasmKit.git
$ cd WasmKit
$ swift run wasmkit-cli run ./Examples/wasm/hello.wasm
Hello, World!
```

### As a Library

#### Swift Package Manager

You can use WasmKit as a [Swift Package Manager](https://www.swift.org/documentation/package-manager/) dependency by adding the following to your `Package.swift` file:

```swift
dependencies: [
    .package(url: "https://github.com/swiftwasm/WasmKit.git", from: "0.1.0"),
],
```

You can find API documentation on the [Swift Package Index](https://swiftpackageindex.com/swiftwasm/WasmKit/main/documentation/wasmkit).

## Features

- [Reasonably fast](./Documentation/RegisterMachine.md#performance-evaluation)
- Minimal dependencies
    - The core runtime engine depends only on [swift-system](https://github.com/apple/swift-system).
    - No Foundation dependency
- Compact and embeddable
    - Debug build complete in 5 seconds[^1]
- Batteries included
    - WASI support, WAT parser, etc.


## Supported Platforms

WasmKit engine works on all major platforms supported by Swift. It is continuously tested on macOS, Ubuntu, and Windows,
and should work on the following platforms:

- macOS 10.13+, iOS 12.0+, tvOS 12.0+, watchOS 6.0+
- Ubuntu 20.04+
- Windows 10+

## Implementation Status

| Category | Feature | Status |
|----------|---------|--------|
| WebAssembly MVP | Parsing binary format | ✅ Implemented |
|                 | Parsing text format (WAT) | ✅ Implemented |
|                 | Execution | ✅ Implemented |
|                 | Validation | ✅ Implemented  |
| WebAssembly Proposal | [Reference types](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md) | ✅ Implemented |
|                      | [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md) | ✅ Implemented |
|                      | [Mutable globals](https://github.com/WebAssembly/mutable-global/blob/master/proposals/mutable-global/Overview.md) | ✅ Implemented |
|                      | [Sign-extension operators](https://github.com/WebAssembly/spec/blob/master/proposals/sign-extension-ops/Overview.md) | ✅ Implemented |
|                      | [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions/blob/main/proposals/nontrapping-float-to-int-conversion/Overview.md) | ✅ Implemented |
|                      | [Memory64](https://github.com/WebAssembly/memory64/blob/main/proposals/memory64/Overview.md) | ✅ Implemented |
|                      | [Tail call](https://github.com/WebAssembly/tail-call/blob/master/proposals/tail-call/Overview.md) | ✅ Implemented |
|                      | [Threads and atomics](https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md) | 🚧 Parser implemented |
| WASI | WASI Preview 1 | ✅ Implemented |


## Minimum Supported Swift Version

The minimum supported Swift version of WasmKit is 5.8, which is the version used to bootstrap the Swift toolchain in [ci.swift.org](https://ci.swift.org/).

## Testing

To run the WasmKit test suite, you need to checkout the test suite repositories first.

```sh
# Checkout test suite repositories
$ ./Vendor/checkout-dependency
# Run tests
$ swift test
```

## Acknowledgement

This project was originally developed by [@akkyie](https://github.com/akkyie), and is now maintained by the community.

[^1]: On a 2020 Mac mini (M1, 16GB RAM) with Swift 5.10. Measured by `swift package resolve && swift package clean && time swift build --product PrintAdd`.