{"id":13693028,"url":"https://github.com/SimonJF/cmm_of_wasm","last_synced_at":"2025-05-02T21:31:11.617Z","repository":{"id":73332135,"uuid":"132119740","full_name":"SimonJF/cmm_of_wasm","owner":"SimonJF","description":"A compiler from WebAssembly to native code, via the OCaml backend.","archived":false,"fork":false,"pushed_at":"2018-08-27T13:51:07.000Z","size":3440,"stargazers_count":88,"open_issues_count":4,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-03T17:14:49.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SimonJF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-05-04T09:33:01.000Z","updated_at":"2024-03-15T15:35:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b7ea70c-4641-4c55-a7af-93c88235c2c6","html_url":"https://github.com/SimonJF/cmm_of_wasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonJF%2Fcmm_of_wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonJF%2Fcmm_of_wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonJF%2Fcmm_of_wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SimonJF%2Fcmm_of_wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SimonJF","download_url":"https://codeload.github.com/SimonJF/cmm_of_wasm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224337256,"owners_count":17294690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T17:01:04.698Z","updated_at":"2024-11-12T19:30:20.002Z","avatar_url":"https://github.com/SimonJF.png","language":"OCaml","funding_links":[],"categories":["Runtimes"],"sub_categories":["**OCaml**"],"readme":"# cmm_of_wasm\n\nA compiler from WebAssembly to native code, via the OCaml backend.\nSee [this blog post](http://simonjf.com/2018/08/27/cmm-of-wasm.html)\nfor motivation and a technical explanation.\n\nThe compiler only supports the `amd64` backend of OCaml at the moment (integer size is assumed to be 64-bit).\n\n## Building\n\nThe compiler currently uses some functionality not present in the main OCaml compiler. To get `cmm_of_wasm` up and running, you'll need to install an opam switch running https://github.com/simonjf/ocaml/tree/patched-branch.\n\nYou will also need `libwasm` on an `opam pin`: https://github.com/SimonJF/libwasm.\n\nI believe the only other dependencies are `dune` and `getopt`.\n\nAfter that, simply run `make`.\n\n## Usage\n\n`./cmm_of_wasm \u003c.wat or .wasm file\u003e`\n\nThere are other options, too:\n\n`./cmm_of_wasm --help`\n\nThis will generate `.o` and `.h` files, which you should be able to link with a C project.\n\n## Running the test suite\n\nFirstly, ensure you've cloned all submodules:\n\n`git submodule update --recursive --remote`\n\nAfter this, you should be able to `cd tests/wasm/` and run `./run-all-tests.py`.\n\n## Project structure\n\n  * `src/lib/cmmcompile`: Compiler from the Stackless IR to CMM code\n  * `src/lib/ir`: Compilation from the WebAssembly AST to a stackless intermediate representation\n  * `src/lib/util`: Utilities\n  * `src/bin`: Entry point and build utilities (I will probably split off the build utilities into `lib` at some point)\n  * `src/rts`: C runtime system, adapted from the `wasm2c` RTS (see https://github.com/webassembly/wabt)\n  * `test/ounit`: Small OUnit test suite for function type hashes\n  * `test/wasm`: Scaffolding for running the WebAssembly test suite, adapted from `wasm2c`'s infrastructure\n\n## Acknowledgements\n\nThanks to Stephen Dolan, KC Sivaramakrishnan, and Mark Shinwell for useful discussions. Thanks also to Pierre Chambart for sharing an early prototype, and whose IR I used.\n\nThis work was funded by an internship at OCaml Labs, who also provided a truly wonderful working environment.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSimonJF%2Fcmm_of_wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSimonJF%2Fcmm_of_wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSimonJF%2Fcmm_of_wasm/lists"}