{"id":13626589,"url":"https://github.com/fubark/zig-v8","last_synced_at":"2025-04-13T10:44:12.646Z","repository":{"id":42196932,"uuid":"435678987","full_name":"fubark/zig-v8","owner":"fubark","description":"Simple V8 builds with C and Zig bindings.","archived":false,"fork":false,"pushed_at":"2024-08-28T12:11:11.000Z","size":685,"stargazers_count":148,"open_issues_count":6,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-27T02:09:36.521Z","etag":null,"topics":["js","v8","wasm","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/fubark.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}},"created_at":"2021-12-06T23:22:27.000Z","updated_at":"2025-03-25T23:55:06.000Z","dependencies_parsed_at":"2023-02-08T04:15:47.510Z","dependency_job_id":"bed92c95-ee72-4f33-b958-c814ac91acca","html_url":"https://github.com/fubark/zig-v8","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fubark%2Fzig-v8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fubark%2Fzig-v8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fubark%2Fzig-v8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fubark%2Fzig-v8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fubark","download_url":"https://codeload.github.com/fubark/zig-v8/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248702081,"owners_count":21148114,"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":["js","v8","wasm","zig"],"created_at":"2024-08-01T21:02:24.440Z","updated_at":"2025-04-13T10:44:12.625Z","avatar_url":"https://github.com/fubark.png","language":"Zig","readme":"# zig-v8\n\nBuilds V8 from official source and provides C bindings and a Zig API. This would be used for embedding the V8 runtime into your Zig or C ABI compatible projects.\n\nV8 is the JS/WASM runtime that powers Google Chrome and Microsoft Edge.\n\n## Project Status\nStatic libs are built and released with [Github Actions](https://github.com/fubark/zig-v8/actions).\n| Native | Cross Compile | Target | Demo Binary ([shell.zig](https://github.com/fubark/zig-v8/blob/master/src/shell.zig))* |\n| ------ | ------ | -------- | -------- |\n| ✅ | | Linux x64 | shell - 19 M |\n| ✅ | ✅ | Windows x64 | shell.exe - 14 M |\n| ✅ | | macOS x64 | shell - 24 M |\n| ✅ | ✅ | macOS arm64 | shell - 21 M |\n\n\\* shell.zig is a JS repl and statically linked with v8. Compiled with -Doptimize=ReleaseSafe. The V8 dependency can be further reduced in size if you don't need all the features (eg. disable WASM runtime).\n\n| Toolchain | Fresh Build* | Cached Build* |\n| ------ | ------ | ------ |\n| gclient, full feature + v8 toolchain | 1.5-2 hrs | with sccache: 10-20min |\n| minimal feature + v8 toolchain | 40-50 min | with sccache: 5-10min |\n| minimal feature + zig c++ toolchain |  | with zig caching:  |\n\n\\* Time is measured on standard Github instances.\n\n## System Requirements\n- Zig compiler (0.11.0). You can get that [here](https://ziglang.org/download/).\n- Python 3 (2.7 seems to work as well)\n- For native macOS builds:\n  - XCode (You won't need this when using zig's c++ toolchain!)\u003cbr/\u003e\nif you come across this error:\u003cbr /\u003e\n`xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance`\u003cbr /\u003e\n  run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`\n\n## Build\nBy default UseGclient=false in build.zig. This will pull the minimum sources and deps needed to build v8 and reduce build times.\n\nIf you want to include everything, set UseGclient=true. Build times can be quite long using gclient but afterwards rerunning \"zig build\" should be incremental. You can also use sccache for better incremental build times.\n\n```sh\n# Clone the repo.\ngit clone https://github.com/fubark/zig-v8.git\ncd zig-v8\n\n# Pull prebuilt GN/Ninja. If UseGclient=true, it also pulls depot_tools.\nzig build get-tools\n\n# Pull v8 source\nzig build get-v8\n\n# Build, resulting static library should be at:\n# v8-build/{target}/{debug/release}/ninja/obj/zig/libc_v8.a\n# On windows, use msvc: zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-windows-msvc\nzig build -Doptimize=ReleaseSafe\n```\n## Demo\n```sh\n# shell.zig is a simple JS repl.\n# Assumes you've already built v8.\nzig build run -Dpath=\"src/shell.zig\" -Doptimize=ReleaseSafe\n\n# If you built v8 using the zig toolchain, you'll need to add the flag here as well.\nzig build run -Dpath=\"src/shell.zig\" -Doptimize=ReleaseSafe -Dzig-toolchain\n```\n\n## Cross Compiling\nWith Zig's toolchain, we can build V8 from libstdc++ that's bundled with zig and cross compile to foreign targets/cpus! Simply amazing. Eventually, this will also replace the default V8 toolchain for native builds after further testing.\n### Linux x64 (Host) to MacOS arm64 (Target)\n```sh\n# Assumes you've fetched tools and v8 sources. See above build steps.\n# Resulting static lib will be at:\n# v8-build/aarch64-macos/release/ninja/obj/zig/libc_v8.a\nzig build -Doptimize=ReleaseSafe -Dtarget=aarch64-macos-gnu -Dzig-toolchain\n```\n\n### Cross compile to Windows with gnu (mingw64)\nZig comes with mingw64 source and headers so you'll be able to target Windows without MSVC.\n```sh\nzig build -Doptimize=ReleaseSafe -Dtarget=x86_64-windows-gnu -Dzig-toolchain\n```\n\n## Usage\n\nSee src/shell.zig or test/test.zig on how to use the library with the Zig API as well as build.zig (fn linkV8) on how to link with the built V8 static library.\n\n## Contributing\n\nThe C bindings is incomplete but it should be relatively easy to add more as we need them.\n\nC API naming convention should closely follow the V8 C++ API.\n\n## Troubleshooting\n\nIf you get an error saying that it can't find any of the following:\n\n```\n\npkg-config\nglib-2.0\ngmodule-2.0\ngobject-2.0\ngthread-2.0\n\n```\n\nYou'll need to run the following command before continuing:\n\n```\nsudo apt install -y pkg-config libglib2.0-dev\n```\nOr your distro's equivalent\n","funding_links":[],"categories":["Zig","Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffubark%2Fzig-v8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffubark%2Fzig-v8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffubark%2Fzig-v8/lists"}