• Stars
    star
    2,976
  • Rank 14,613 (Top 0.3 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust bindings for the V8 JavaScript engine

Rusty V8 Binding

V8 Version: 11.7.439.1

ci crates docs

Goals

  1. Provide high quality Rust bindings to V8's C++ API. The API should match the original API as closely as possible.

  2. Do not introduce additional call overhead. (For example, previous attempts at Rust V8 bindings forced the use of Persistent handles.)

  3. Do not rely on a binary libv8.a built outside of cargo. V8 is a very large project (over 600,000 lines of C++) which often takes 30 minutes to compile. Furthermore, V8 relies on Chromium's bespoke build system (gn + ninja) which is not easy to use outside of Chromium. For this reason many attempts to bind to V8 rely on pre-built binaries that are built separately from the binding itself. While this is simple, it makes upgrading V8 difficult, it makes CI difficult, it makes producing builds with different configurations difficult, and it is a security concern since binary blobs can hide malicious code. For this reason we believe it is imperative to build V8 from source code during "cargo build".

  4. Publish the crate on crates.io and allow docs.rs to generate documentation. Due to the complexity and size of V8's build, this is nontrivial. For example the crate size must be kept under 10 MiB in order to publish.

Binary Build

V8 is very large and takes a long time to compile. Many users will prefer to use a prebuilt version of V8. We publish static libs for every version of rusty v8 on Github.

Binaries builds are turned on by default: cargo build will initiate a download from github to get the static lib. To disable this build using the V8_FROM_SOURCE environmental variable.

When making changes to rusty_v8 itself, it should be tested by build from source. The CI always builds from source.

The V8_FORCE_DEBUG environment variable

By default rusty_v8 will link against release builds of v8, if you want to use a debug build of v8 set V8_FORCE_DEBUG=true.

We default to release builds of v8 due to performance & CI reasons in deno.

The RUSTY_V8_MIRROR environment variable

Tells the build script where to get binary builds from. Understands http:// and https:// URLs, and file paths. The default is https://github.com/denoland/rusty_v8/releases/download.

File-based mirrors are good for using cached downloads. First, point the environment variable to a suitable location:

# you might want to add this to your .bashrc
$ export RUSTY_V8_MIRROR=$HOME/.cache/rusty_v8

Then populate the cache:

#!/bin/bash

# see https://github.com/denoland/rusty_v8/releases

for REL in v0.13.0 v0.12.0; do
  mkdir -p $RUSTY_V8_MIRROR/$REL
  for FILE in \
    librusty_v8_debug_x86_64-unknown-linux-gnu.a \
    librusty_v8_release_x86_64-unknown-linux-gnu.a \
  ; do
    if [ ! -f $RUSTY_V8_MIRROR/$REL/$FILE ]; then
      wget -O $RUSTY_V8_MIRROR/$REL/$FILE \
        https://github.com/denoland/rusty_v8/releases/download/$REL/$FILE
    fi
  done
done

The RUSTY_V8_ARCHIVE environment variable

Tell the build script to use a specific v8 library. This can be an URL or a path. This is useful when you have a prebuilt archive somewhere:

export RUSTY_V8_ARCHIVE=/path/to/custom_archive.a
cargo build

Build V8 from Source

Use V8_FROM_SOURCE=1 cargo build -vv to build the crate completely from source.

The build scripts require Python 3 to be available as python3 in your PATH. If you want to specify the exact binary of Python to use, you should use the PYTHON environment variable.

The build also requires curl to be installed on your system.

For linux builds: glib-2.0 development files need to be installed such that pkg-config can find them. On Ubuntu, run sudo apt install libglib2.0-dev to install them.

For Windows builds: the 64-bit toolchain needs to be used. 32-bit targets are not supported.

For Mac builds: You'll need Xcode and Xcode CLT installed. Recent macOS versions will also require you to pass PYTHON=python3 because macOS no longer ships with python simlinked to Python 3.

The build depends on several binary tools: gn, ninja and clang. The tools will automatically be downloaded, if they are not detected in the environment.

Specifying the $GN and $NINJA environmental variables can be used to skip the download of gn and ninja. The clang download can be skipped by setting $CLANG_BASE_PATH to the directory containing a llvm/clang installation. V8 is known to rely on bleeding edge features, so LLVM v8.0+ or Apple clang 11.0+ is recommended.

Arguments can be passed to gn by setting the $GN_ARGS environmental variable.

Env vars used in when building from source: SCCACHE, CCACHE, GN, NINJA, CLANG_BASE_PATH, GN_ARGS

FAQ

Building V8 takes over 30 minutes, this is too slow for me to use this crate. What should I do?

Install sccache or ccache. Our build scripts will detect and use them. Set the $SCCACHE or $CCACHE environmental variable if it's not in your path.

What are all these random directories for like build and buildtools are these really necessary?

In order to build V8 from source code, we must provide a certain directory structure with some git submodules from Chromium. We welcome any simplifications to the code base, but this is a structure we have found after many failed attempts that carefully balances the requirements of cargo crates and GN/Ninja.

V8 has a very large API with hundreds of methods. Why don't you automate the generation of this binding code?

In the limit we would like to auto-generate bindings. We have actually started down this route several times, however due to many eccentric features of the V8 API, this has not proven successful. Therefore we are proceeding in a brute-force fashion for now, focusing on solving our stated goals first. We hope to auto-generate bindings in the future.

Why are you building this?

This is to support the Deno project. We previously have gotten away with a simpler high-level Rust binding to V8 called libdeno. But as Deno has matured we've found ourselves continually needing access to an increasing amount of V8's API in Rust.

When building I get unknown argument: '-gno-inline-line-tables'

Use export GN_ARGS="no_inline_line_tables=false" during build.

For maintainers

Cut a release

Go to https://github.com/denoland/rusty_v8/actions/workflows/release.yml, select proper release kind and wait for the workflow to complete. It will bump the version and create a tag. You will need to manually upload binary archives for M1 build.

$ V8_FROM_SOURCE=1 cargo build
$ V8_FROM_SOURCE=1 cargo build --release

More Repositories

1

deno

A modern runtime for JavaScript and TypeScript.
Rust
92,633
star
2

fresh

The next-gen web framework.
TypeScript
11,819
star
3

deno_std

Deno standard library
TypeScript
2,705
star
4

deno_lint

Blazing fast linter for JavaScript and TypeScript written in Rust
Rust
1,499
star
5

vscode_deno

Visual Studio Code plugin for Deno
TypeScript
1,453
star
6

dnt

Deno to npm package build tool.
Rust
1,147
star
7

saaskit

A modern SaaS template built on Fresh.
TypeScript
1,071
star
8

dotland

[Archived] deno.land website
TypeScript
966
star
9

deno_install

Deno Binary Installer
PowerShell
945
star
10

deno_docker

Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
Dockerfile
838
star
11

deno-lambda

A deno runtime for AWS Lambda. Deploy deno via docker, SAM, serverless, or bundle it yourself.
TypeScript
836
star
12

fastwebsockets

A fast RFC6455 WebSocket implementation
Rust
741
star
13

deno_blog

Minimal boilerplate blogging.
TypeScript
435
star
14

denokv

A self-hosted backend for Deno KV
TypeScript
380
star
15

deployctl

Command line tool for Deno Deploy
TypeScript
321
star
16

showcase_chat

TypeScript
303
star
17

merch

The Deno shop!
TypeScript
282
star
18

roll-your-own-javascript-runtime

Rust
261
star
19

deno_bindgen

Write high-level Deno FFI libraries in Rust.
Rust
257
star
20

wasmbuild

Build tool to use Rust code in Deno and the browser.
TypeScript
251
star
21

deno_doc

Documentation generator for Deno
Rust
247
star
22

meet-me

A calendly clone in Deno and hosted on Deno Deploy
TypeScript
243
star
23

setup-deno

Set up your GitHub Actions workflow with a specific version of Deno
JavaScript
230
star
24

deno_kv_oauth

High-level OAuth 2.0 powered by Deno KV.
TypeScript
221
star
25

deno-gfm

Server-side GitHub Flavored Markdown rendering for Deno
TypeScript
209
star
26

eszip

A compact file format to losslessly serialize an ECMAScript module graph into a single file
Rust
208
star
27

webgpu-examples

TypeScript
201
star
28

doc_website

Archived. New version at https://github.com/denoland/docland
TypeScript
195
star
29

deno_core

The core engine at the heart of Deno
Rust
179
star
30

deno_emit

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
TypeScript
177
star
31

manual

Deprecated - find these resources on docs.deno.com instead
TypeScript
163
star
32

denobyexample

Deno by example - short examples showcasing how to use Deno
TypeScript
142
star
33

node_shims

npm packages providing shims for the Deno namespace and other globals. Useful for running Deno-first programs on Node.
TypeScript
140
star
34

deno_ast

Source text parsing, lexing, and AST related functionality for Deno
Rust
134
star
35

fresh_charts

A server-side-rendered charting library for Fresh
TypeScript
126
star
36

deploy_examples

Examples for Deno Deploy
TypeScript
124
star
37

docland

The documentation generation website for Deno
TypeScript
120
star
38

deno_task_shell

Cross-platform shell for deno task.
Rust
100
star
39

deno_graph

The module graph logic for Deno CLI
Rust
94
star
40

deno_registry2

The backend for the deno.land/x service
TypeScript
93
star
41

deno_third_party

TypeScript
78
star
42

monch

Inspired by nom, but specifically for strings.
Rust
76
star
43

examples

A simple todo app using Deno and React.
TypeScript
75
star
44

showcase_todo

Collaborative todo-list app built with Deno and Fresh
TypeScript
74
star
45

tic-tac-toe

A global, real-time multiplayer TicTacToe game for Deno 🦕
TypeScript
73
star
46

deploy_feedback

For reporting issues with Deno Deploy
72
star
47

v8

floating patches for rusty_v8
TypeScript
57
star
48

pixelpage

Pixel page is an r/place style shared pixel art canvas 🎨🦕
TypeScript
54
star
49

rust-urlpattern

Rust implementation of the `URLPattern` web API
Rust
54
star
50

apiland

The API server for deno.land
TypeScript
53
star
51

fresh-wordpress-themes

https://wp-blog-example.deno.dev/ https://wp-sweets-co.deno.dev/
TypeScript
51
star
52

deno-astro-adapter

A Deno adapter for running Astro applications on the Deno runtime.
TypeScript
49
star
53

wanted_modules

Is there a missing deno module that is preventing you from building something? Let us know here.
46
star
54

cargo_gn

Cargo GN integration
Rust
40
star
55

deno-astro-template

Template repo for an Astro site, preconfigured to run with Deno and Deno Deploy
Astro
39
star
56

wasmbuild_example

Example of using wasmbuild.
JavaScript
37
star
57

deno-docs

Docusaurus site for a unified Deno docs experience
MDX
37
star
58

deno_cache_dir

Deno CLI's module cache
JavaScript
37
star
59

ga

Utilities for server side processing of Google Analytics in Deno CLI and Deploy
TypeScript
37
star
60

serde_v8

Moved to https://github.com/denoland/deno
Rust
36
star
61

chromium_build

Deno floats patches to //build here (they will be sent upstream eventually)
Python
29
star
62

import_map

An implementation of WICG Import Maps specification
Rust
29
star
63

fresh-blog-example

An example for building a blog with Fresh.
TypeScript
25
star
64

flaky_test

atttribute macro for running a flaky test multiple times
Rust
25
star
65

libffi-rs

Fork of libffi-rs which corrects autotools usage
C
22
star
66

chatspace

Real-time, collaborative GPT frontend built with Deno KV
TypeScript
22
star
67

deno_npm

npm registry client and dependency resolver used in the Deno CLI.
Rust
21
star
68

doc_components

A set of components for rendering deno_doc doc nodes
TypeScript
21
star
69

terraform-deploy-provider

Terraform provider for Deno Deploy
Go
21
star
70

deno-vue-example

An example of using Vue with Deno.
Vue
20
star
71

deploy_lume_example

An example demonstrating using static site generators on Deno Deploy
TypeScript
20
star
72

deno-kv-hackathon

Rules, details, and place to submit your project for the Deno KV hackathon.
18
star
73

rustls-tokio-stream

AsyncRead/AsyncWrite interface for rustls-on-Tokio
Rust
18
star
74

kv_api

WORK IN PROGRESS: Attach a flexible REST API to your Deno web app to manage data in Deno KV
TypeScript
18
star
75

subhosting_ide_starter

Basic starter app for a browser-based IDE using the Deno Subhosting API
JavaScript
18
star
76

chromium_buildtools

forked from chromium to use git submodules instead of gclient
Python
17
star
77

image-resizing-api

A simple image resizing API written in Deno.
TypeScript
16
star
78

benchmark_data

TypeScript
16
star
79

react18-with-deno

A starter app and tutorial with React18 and Deno.
TypeScript
16
star
80

deno-sveltekit-template

A starter template for running SvelteKit on Deno Deploy
JavaScript
15
star
81

monaco-nextjs-demo

A demo Next.js app that features an in-browser IDE built with Monaco.
JavaScript
15
star
82

automation

Automation scripts used for denoland org repos
TypeScript
15
star
83

fresh-deno-kv-oauth-demo

Fresh + Deno KV OAuth demo
TypeScript
14
star
84

terraform-provider-deno

Terraform provider for hosted Deno APIs
Go
14
star
85

fresh_template

template repository for a Fresh project
12
star
86

experimental-deno-specifiers-example

TypeScript
12
star
87

deno_lockfile

Rust
12
star
88

icu

For floating patches on top of https://chromium.googlesource.com/chromium/deps/icu.git
C++
11
star
89

deno-nuxt-template

A template repo for a Nuxt project preconfigured for Deno Deploy
TypeScript
10
star
90

notebook

TypeScript
10
star
91

deno_media_type

Media type used in Deno.
Rust
10
star
92

deno_config

Rust
9
star
93

eszip_viewer

TypeScript
8
star
94

website_feedback

For reporting issues & suggestions for deno.com and deno.land
8
star
95

fresh-auth-example

TypeScript
8
star
96

v8_valueserializer

A Rust implementation of V8's ValueSerializer and ValueDeserializer
Rust
8
star
97

ga4

A GA4 measurement protocol module for Deno.
TypeScript
7
star
98

oak_template

A template of REST API app using Oak framework
TypeScript
7
star
99

deno_semver

Semver used in Deno's CLI.
Rust
7
star
100

comparing-git-deploys-to-edge

Comparing git deployments to the edge.
TypeScript
7
star