1

I would like to build a static, monolithic library suitable for embedding via MinGW. This is a multiplatform project and I want to avoid switching my entire toolchain over to MSVC. All answers on StackOverflow, Google Groups and the v8 wiki refer to SCons, GYP or MinGW build generation files that no longer exist. I have:

  1. Followed the instructions here to install depot_tools and fetch v8.
  2. Added [User Directory]\depot_tools to the front of my PATH variable.
  3. Set DEPOT_TOOLS_WIN_TOOLCHAIN=0 in my environment variables.

Instructions here suggest bypassing the manual workflow by outputting build files yourself. When I run gn args out/mingw I get a python stack trace ending with:

Exception: No supported Visual Studio can be found. Supported versions are: 16.0 (2019), 17.0 (2022), 15.0 (2017).
ERROR at //build/config/win/visual_studio_version.gni:27:7: Script returned non-zero exit code.
      exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
      ^----------
DragonDePlatino
  • 159
  • 1
  • 10
  • 1
    I wish they would just use cmake or meson... – Brecht Sanders Aug 03 '22 at 13:16
  • Why don't use pre-built https://packages.msys2.org/package/mingw-w64-x86_64-v8?repo=mingw64? – 273K Aug 03 '22 at 15:21
  • @BrechtSanders: we accept patches, but maintaining another build system doesn't have sufficiently high priority for us to spend time on it, so you'd have to do that on an ongoing basis. (And we can't "just" switch either, for various reasons.) – jmrk Aug 07 '22 at 20:53
  • @273K: one possible reason: those packages are pretty outdated. – jmrk Aug 07 '22 at 20:53
  • @DragonDePlatino: I believe it should be enough to have the "Windows SDK" installed, possibly as part of a MSVC installation. V8 certainly doesn't require the MSVC compiler (but does support it optionally); we compile with our own bundled Clang by default, including on Windows. (I don't know the specifics of MinGW these days, haven't tried it in a while, and don't have time to dig into it.) – jmrk Aug 07 '22 at 20:56

1 Answers1

0

I'm not sure if this answers your question, since you mentioned gn specifically. But a few months ago I managed to compile V8 using gm.py and following these instructions.

This is what I did (I keep all git repos in ~/repos):

mkdir ~/repos/v8/v8 # that's right, type v8 twice
git checkout main

# update V8
git pull

# update V8 dependencies
gclient sync

# compile source
tools/dev/gm.py x64.release
# or, compile source and immediately run the tests
tools/dev/gm.py x64.release.check

If you need to set some specific V8 compile-time flags, I think you cannot use gm.py though. You need to generate build files using either gn or v8gen.py:

After you have managed to generate the build files, you can finally compile V8 using ninja.

A completely different route could be to use zig-v8, which uses the Zig toolchain to build V8. For example, Cosmic is a JS/WASM runtime that uses zig-v8 to embed V8.

jackdbd
  • 4,583
  • 3
  • 26
  • 36