{"id":13432794,"url":"https://github.com/denoland/rusty_v8","last_synced_at":"2026-04-17T08:09:24.563Z","repository":{"id":37470266,"uuid":"218872560","full_name":"denoland/rusty_v8","owner":"denoland","description":"Rust bindings for the V8 JavaScript engine","archived":false,"fork":false,"pushed_at":"2025-05-05T12:58:27.000Z","size":3948,"stargazers_count":3572,"open_issues_count":78,"forks_count":329,"subscribers_count":54,"default_branch":"main","last_synced_at":"2025-05-06T14:56:51.686Z","etag":null,"topics":["rust","v8"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/v8","language":"Rust","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/denoland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2019-10-31T22:36:03.000Z","updated_at":"2025-05-06T06:41:40.000Z","dependencies_parsed_at":"2023-10-03T18:01:11.927Z","dependency_job_id":"b12215f3-b4d3-456b-b1cf-9ef59227f4d3","html_url":"https://github.com/denoland/rusty_v8","commit_stats":{"total_commits":981,"total_committers":82,"mean_commits":"11.963414634146341","dds":0.7206931702344546,"last_synced_commit":"64c26f853b738816815a4b95603edad94b635c66"},"previous_names":[],"tags_count":209,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Frusty_v8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Frusty_v8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Frusty_v8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Frusty_v8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denoland","download_url":"https://codeload.github.com/denoland/rusty_v8/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969231,"owners_count":21992262,"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":["rust","v8"],"created_at":"2024-07-31T02:01:16.675Z","updated_at":"2026-04-17T08:09:24.549Z","avatar_url":"https://github.com/denoland.png","language":"Rust","funding_links":[],"categories":["Rust","rust"],"sub_categories":[],"readme":"# Rusty V8 Binding\n\nV8 Version: 14.7.173.19\n\n[![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/rusty_v8/actions)\n[![crates](https://img.shields.io/crates/v/v8.svg)](https://crates.io/crates/v8)\n[![docs](https://docs.rs/v8/badge.svg)](https://docs.rs/v8)\n\n## Goals\n\n1. Provide high quality Rust bindings to\n   [V8's C++ API](https://cs.chromium.org/chromium/src/v8/include/v8.h). The API\n   should match the original API as closely as possible.\n\n2. Do not introduce additional call overhead. (For example, previous attempts at\n   Rust V8 bindings forced the use of Persistent handles.)\n\n3. Do not rely on a binary `libv8.a` built outside of cargo. V8 is a very large\n   project (over 600,000 lines of C++) which often takes 30 minutes to compile.\n   Furthermore, V8 relies on Chromium's bespoke build system (gn + ninja) which\n   is not easy to use outside of Chromium. For this reason many attempts to bind\n   to V8 rely on pre-built binaries that are built separately from the binding\n   itself. While this is simple, it makes upgrading V8 difficult, it makes CI\n   difficult, it makes producing builds with different configurations difficult,\n   and it is a security concern since binary blobs can hide malicious code. For\n   this reason we believe it is imperative to build V8 from source code during\n   \"cargo build\".\n\n4. Publish the crate on crates.io and allow docs.rs to generate documentation.\n   Due to the complexity and size of V8's build, this is nontrivial. For example\n   the crate size must be kept under 10 MiB in order to publish.\n\n## Versioning\n\nRusty V8's major version aligns with Chrome's major version, which corresponds\nto a specific V8 release. For example, Rusty V8 `129.0.0` maps to Chrome\n`129.x.y.z`, which uses V8 `12.9.a.b`. While the minor and patch numbers between\nChrome and V8 may differ, Rusty V8 will follow Chrome's release schedule, with a\nnew major version every 4 weeks.\n\nAs a Rust crate, Rusty V8 follows semantic versioning (semver) and will not\nintroduce breaking changes within a major version. However, major version bumps\nwill occur regularly to stay in sync with Chrome's release cycle.\n\n## Binary Build\n\nV8 is very large and takes a long time to compile. Many users will prefer to use\na prebuilt version of V8. We publish static libs for every version of rusty v8\non [Github](https://github.com/denoland/rusty_v8/releases).\n\nBinaries builds are turned on by default: `cargo build` will initiate a download\nfrom github to get the static lib. To disable this build using the\n`V8_FROM_SOURCE` environmental variable.\n\nWhen making changes to rusty_v8 itself, it should be tested by build from\nsource. The CI always builds from source.\n\n## The `V8_FORCE_DEBUG` environment variable\n\nBy default `rusty_v8` will link against release builds of `v8`, if you want to\nuse a debug build of `v8` set `V8_FORCE_DEBUG=true`.\n\nWe default to release builds of `v8` due to performance \u0026 CI reasons in `deno`.\n\n## The `RUSTY_V8_MIRROR` environment variable\n\nTells the build script where to get binary builds from. Understands `http://`\nand `https://` URLs, and file paths. The default is\nhttps://github.com/denoland/rusty_v8/releases.\n\nFile-based mirrors are good for using cached downloads. First, point the\nenvironment variable to a suitable location:\n\n    # you might want to add this to your .bashrc\n    $ export RUSTY_V8_MIRROR=$HOME/.cache/rusty_v8\n\nThen populate the cache:\n\n```bash\n#!/bin/bash\n\n# see https://github.com/denoland/rusty_v8/releases\n\nfor REL in v0.13.0 v0.12.0; do\n  mkdir -p $RUSTY_V8_MIRROR/$REL\n  for FILE in \\\n    librusty_v8_debug_x86_64-unknown-linux-gnu.a \\\n    librusty_v8_release_x86_64-unknown-linux-gnu.a \\\n  ; do\n    if [ ! -f $RUSTY_V8_MIRROR/$REL/$FILE ]; then\n      wget -O $RUSTY_V8_MIRROR/$REL/$FILE \\\n        https://github.com/denoland/rusty_v8/releases/download/$REL/$FILE\n    fi\n  done\ndone\n```\n\n## The `RUSTY_V8_ARCHIVE` environment variable\n\nTell the build script to use a specific v8 library. This can be an URL or a\npath. This is useful when you have a prebuilt archive somewhere:\n\n```bash\nexport RUSTY_V8_ARCHIVE=/path/to/custom_archive.a\ncargo build\n```\n\n## Build V8 from Source\n\nUse `V8_FROM_SOURCE=1 cargo build -vv` to build the crate completely from\nsource.\n\nThe build scripts require Python 3 to be available as `python3` in your `PATH`.\nIf you want to specify the exact binary of Python to use, you should use the\n`PYTHON` environment variable.\n\nThe build also requires `curl` to be installed on your system.\n\nFor linux builds: glib-2.0 development files need to be installed such that\npkg-config can find them. On Ubuntu, run `sudo apt install libglib2.0-dev` to\ninstall them.\n\nAdditionally, building from source requires libclang 19+ for bindgen:\n\n```bash\nsudo apt install libclang-19-dev\nexport LIBCLANG_PATH=/usr/lib/llvm-19/lib\n```\n\nFor Windows builds: the 64-bit toolchain needs to be used. 32-bit targets are\nnot supported.\n\nFor Mac builds: You'll need Xcode and Xcode CLT installed. Recent macOS versions\nwill also require you to pass PYTHON=python3 because macOS no longer ships with\n`python` simlinked to Python 3.\n\nFor Android builds: You'll need to cross compile from a x86_64 host to the\naarch64 or x64 android. You can use the following commands:\n\n```bash\nrustup target add aarch64-linux-android  # or x86_64-linux-android\nV8_FROM_SOURCE=1 cargo build -vv --target aarch64-linux-android\n# or with cross\ndocker build --build-arg CROSS_BASE_IMAGE=ghcr.io/cross-rs/aarch64-linux-android:0.2.5 -t cross-rusty_v8:aarch64-linux-android .\nV8_FROM_SOURCE=1 cross build -vv --target aarch64-linux-android\n```\n\nThe build depends on several binary tools: `gn`, `ninja` and `clang`. The tools\nwill automatically be downloaded, if they are not detected in the environment.\n\nSpecifying the `$GN` and `$NINJA` environmental variables can be used to skip\nthe download of gn and ninja. The clang download can be skipped by setting\n`$CLANG_BASE_PATH` to the directory containing a `llvm`/`clang` installation. V8\nis known to rely on bleeding edge features, so LLVM v8.0+ or Apple clang 11.0+\nis recommended.\n\nArguments can be passed to `gn` by setting the `$GN_ARGS` environmental\nvariable.\n\nEnv vars used in when building from source: `SCCACHE`, `CCACHE`, `GN`, `NINJA`,\n`CLANG_BASE_PATH`, `GN_ARGS`\n\n## FAQ\n\n**Building V8 takes over 30 minutes, this is too slow for me to use this crate.\nWhat should I do?**\n\nInstall [sccache](https://github.com/mozilla/sccache) or\n[ccache](https://ccache.dev/). Our build scripts will detect and use them. Set\nthe `$SCCACHE` or `$CCACHE` environmental variable if it's not in your path.\n\n**What are all these random directories for like `build` and `buildtools` are\nthese really necessary?**\n\nIn order to build V8 from source code, we must provide a certain directory\nstructure with some git submodules from Chromium. We welcome any simplifications\nto the code base, but this is a structure we have found after many failed\nattempts that carefully balances the requirements of cargo crates and GN/Ninja.\n\n**V8 has a very large API with hundreds of methods. Why don't you automate the\ngeneration of this binding code?**\n\nWe have actually started down this route several times, however due to many\neccentric features of the V8 API, this has not proven successful. Therefore we\nare proceeding in a brute-force fashion for now, focusing on solving our stated\ngoals first. We hope to auto-generate bindings in the future.\n\n**Why are you building this?**\n\nThis is to support [the Deno project](https://deno.land/). We previously have\ngotten away with a simpler high-level Rust binding to V8 called\n[libdeno](https://github.com/denoland/deno/tree/32937251315493ef2c3b42dd29340e8a34501aa4/core/libdeno).\nBut as Deno has matured we've found ourselves continually needing access to an\nincreasing amount of V8's API in Rust.\n\n**When building I get unknown argument: '-gno-inline-line-tables'**\n\nUse `export GN_ARGS=\"no_inline_line_tables=false\"` during build.\n\n**My program crashes when initializing on non-main thread**\n\nInitializing V8 on a non-main thread with the CPUs PKU feature enabled might\nlead to crashes. You can work around this problem by using\n`v8::new_unprotected_default_platform`.\n\nSee https://github.com/denoland/rusty_v8/issues/1381\n\n## Download cache\n\nThe v8 archives used for linking in prebuilt mode can be cached to avoid\nre-downloading archives when switching between branches that otherwise change\nthe current rusty_v8 version.\n\nTo populate the cache by hand, you'll need to place the files in the appropriate\nlocation in your `.cargo` folder. Running `cargo build -v -v` will print two\nlines that you can use to determine the correct file and cache location:\n\n```\n[v8 0.87.0] static lib URL: https://github.com/denoland/rusty_v8/releases/download/v0.87.0/librusty_v8_release_aarch64-apple-darwin.a.gz\n[v8 0.87.0] Looking for download in '\"/Users/\u003cname\u003e/.cargo/.rusty_v8/https___github_com_denoland_rusty_v8_releases_download_v0_87_0_librusty_v8_release_aarch64_apple_darwin_a_gz\"'\n```\n\nGiven the above log output, use `curl` to download the file like so:\n\n```\ncurl -L https://github.com/denoland/rusty_v8/releases/download/v0.87.0/librusty_v8_release_aarch64-apple-darwin.a.gz \u003e\n  /Users/\u003cname\u003e/.cargo/.rusty_v8/https___github_com_denoland_rusty_v8_releases_download_v0_87_0_librusty_v8_release_aarch64_apple_darwin_a_gz\n```\n\n## For maintainers\n\n**Cut a release**\n\nCreate a PR to bump the release version (e.g.\nhttps://github.com/denoland/rusty_v8/pull/1415).\n\nCreate a new release/tag after the bump PR is landed. CI will publish the crate\nand upload release binaries. You will need to manually upload binary archives\nfor M1 build.\n\n```\n$ V8_FROM_SOURCE=1 cargo build\n$ V8_FROM_SOURCE=1 cargo build --release\n```\n\n## Experimental Features\n\nrusty_v8 includes experimental support for certain feature(s) that may be useful in security focused contexts but are not as well tested and do not undergo any sort of CI related testing or prebuilt archives. Due to their experimental status, these features require either ``V8_FROM_SOURCE=1`` to be set or the use of a custom-built archive of v8. \n\n- ``v8_enable_sandbox``: Enables v8 sandbox mode. The v8 sandbox enables improved safety while executing potentially malicious JavaScript code through the use of memory cages. Note that the v8 sandbox will allocate ~1TB of virtual memory (although this should not be an issue as many operating systems allow 128-256TB of virtual memory per process). Creating isolates with the sandbox enabled comes with API limitations and may have increased overhead. Note that enabling the V8 sandbox also implies pointer compression to be enabled as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Frusty_v8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenoland%2Frusty_v8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Frusty_v8/lists"}