{"id":13726791,"url":"https://github.com/zshipko/ocaml-rs","last_synced_at":"2025-05-14T16:14:59.082Z","repository":{"id":29119977,"uuid":"121578782","full_name":"zshipko/ocaml-rs","owner":"zshipko","description":"OCaml extensions in Rust","archived":false,"fork":false,"pushed_at":"2025-02-07T22:46:23.000Z","size":1685,"stargazers_count":271,"open_issues_count":31,"forks_count":32,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-14T11:51:11.608Z","etag":null,"topics":["ffi","ocaml","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/ocaml","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zshipko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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,"publiccode":null,"codemeta":null}},"created_at":"2018-02-15T00:53:40.000Z","updated_at":"2025-04-24T16:16:09.000Z","dependencies_parsed_at":"2024-01-07T21:04:46.740Z","dependency_job_id":"b09323ba-d83d-43c3-8d1d-98874c042f22","html_url":"https://github.com/zshipko/ocaml-rs","commit_stats":{"total_commits":399,"total_committers":16,"mean_commits":24.9375,"dds":"0.14035087719298245","last_synced_commit":"cae584cfd7bab89ac8634f6b50acd27191f8b815"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zshipko%2Focaml-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zshipko%2Focaml-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zshipko%2Focaml-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zshipko%2Focaml-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zshipko","download_url":"https://codeload.github.com/zshipko/ocaml-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254161465,"owners_count":22024768,"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":["ffi","ocaml","rust"],"created_at":"2024-08-03T01:03:22.522Z","updated_at":"2025-05-14T16:14:59.047Z","avatar_url":"https://github.com/zshipko.png","language":"Rust","funding_links":[],"categories":["Rust","rust"],"sub_categories":[],"readme":"# ocaml-rs - OCaml extensions in Rust\n\n\u003ca href=\"https://crates.io/crates/ocaml\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/ocaml.svg\"\u003e\n\u003c/a\u003e\n\n`ocaml-rs` allows for OCaml extensions to be written directly in Rust with no C stubs. It was originally forked from [raml](https://crates.io/crates/raml), but has been almost entirely re-written thanks to support from the [OCaml Software Foundation](http://ocaml-sf.org/).\n\nWorks with OCaml versions `4.10.0` and up\n\nPlease report any issues on [github](https://github.com/zshipko/ocaml-rs/issues)\n\nNOTE: While `ocaml-rs` *can* be used safely, it does not prevent a wide range of potential errors or mistakes. It should be thought of as a Rust implementation of the existing C API. [ocaml-interop](https://github.com/simplestaking/ocaml-interop) can be used to perform safe OCaml/Rust interop. \n\n### Documentation\n\n- [ocaml-rs Book](https://zshipko.github.io/ocaml-rs)\n- [docs.rs](https://docs.rs/ocaml)\n\n### Getting started\n\n[ocaml-rust-starter](http://github.com/zshipko/ocaml-rust-starter) is a basic example to help get started with `ocaml-rs`.\n\nOn the Rust side, you will need to add the following to your `Cargo.toml`:\n\n```toml\nocaml = \"*\"\n```\n\nor\n\n```toml\nocaml = {git = \"https://github.com/zshipko/ocaml-rs\"}\n```\n\nFor macOS you will need also to add the following to your project's `.cargo/config` file:\n\n```toml\n[build]\nrustflags = [\"-C\", \"link-args=-Wl,-undefined,dynamic_lookup\"]\n```\n\nThis is because macOS doesn't allow undefined symbols in dynamic libraries by default.\n\nAdditionally, if you plan on releasing to [opam](https://github.com/ocaml/opam), you will need to vendor your Rust dependencies to avoid making network requests during the build phase, since reaching out to crates.io/github will be blocked by the opam sandbox. To do this you should run:\n\n```shell\ncargo vendor\n```\n\nthen follow the instructions for editing `.cargo/config`\n\n### Build options\n\nBy default, building `ocaml-sys` will invoke the `ocamlopt` command to figure out the version and location of the OCaml compiler. There are a few environment variables to control this.\n\n- `OCAMLOPT` (default: `ocamlopt`) is the command that will invoke `ocamlopt`\n- `OCAML_VERSION` (default: result of `$OCAMLOPT -version`) is the target runtime OCaml version.\n- `OCAML_WHERE_PATH` (default: result of `$OCAMLOPT -where`) is the path of the OCaml standard library.\n- `OCAML_INTEROP_NO_CAML_STARTUP` (default: unset) can be set when loading an `ocaml-rs` library into an OCaml\n  bytecode runtime (such as `utop`) to avoid linking issues with `caml_startup`\n\nIf both `OCAML_VERSION` and `OCAML_WHERE_PATH` are present, their values are used without invoking `ocamlopt`. If any of those two env variables is undefined, then `ocamlopt` will be invoked to obtain both values.\n\nDefining the `OCAML_VERSION` and `OCAML_WHERE_PATH` variables is useful for saving time in CI environments where an OCaml install is not really required (to run `clippy` for example).\n\n### Features\n\n- `derive`\n  * enabled by default, adds `#[ocaml::func]` and friends and `derive` implementations for `FromValue` and `ToValue`\n- `link`\n  * link the native OCaml runtime, this should only be used when no OCaml code will be linked statically\n- `no-std`\n  * Allows `ocaml` to be used in `#![no_std]` environments like MirageOS\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzshipko%2Focaml-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzshipko%2Focaml-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzshipko%2Focaml-rs/lists"}