paint-brush
Understanding Chrome V8 — Chapter 1:Checkout, Build, Run V8 by@huidou
427 reads
427 reads

Understanding Chrome V8 — Chapter 1:Checkout, Build, Run V8

by 灰豆August 14th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

# Let’s Understand Chrome V8 — Chapter 1:Checkout, Build, Run V8, and then build. System Requirements: Win 10 64bit, VS2019 community, Git, windows 10 SDK(10.0.19041 and higher) depot_tools. Building V8 with VS2019 Compile with Compile: Checkout, Run, Build and Compile, Compile V8. Compile Compile is a free-form version of the Chrome Web browser.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Understanding Chrome V8 — Chapter 1:Checkout, Build, Run V8
灰豆 HackerNoon profile picture


Welcome to the chapters of Let’s Understand Chrome V8.


1. Checkout, Build

1. 1. System Requirements

  • win 10 64bit, VS2019 community, Git
  • Win 10 64bit, VS2019 community, Git, windows 10 SDK(10.0.19041 and higher)


Note: Install SDK separately, do not use VS installer, because the SDK installed with VS installer is incomplete.


1.2. depot_tools

Download the depot_tools bundle and extract it somewhere.


Warning: DO NOT use drag-n-drop or copy-n-paste extract from Explorer, this will not extract the hidden “.git” folder which is necessary for depot_tools to auto-update itself. You can use “Extract all…” from the context menu though.


Add depot_tools to the start of your PATH (must be ahead of any installs of Python. Note that environment variable names are case insensitive).


Assuming you unzipped the bundle to C:\src\depot_tools, open: Control Panel → System and Security → System → Advanced system settings.


If you have Administrator access, Modify the PATH system variable and put C:\src\depot_tools at the front (or at least in front of any directory that might already have a copy of Python or Git).


If you don’t have Administrator access, you can add a user-level PATH environment variable by opening: Control Panel → System and Security → System → Search for “Edit environment variables for your account”.


Add C:\src\depot_tools at the front. Note: If your system PATH has a Python in it, you will be out of luck.


Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN environment variable in the same way, and set it to 0. This tells depot_tools to use your locally installed version of Visual Studio (by default, depot_tools will try to use a google-internal version).


From a cmd.exe shell, run.


Note: No Powershell!


On the first run, gclient will install all the Windows-specific bits needed to work with the code, including msysgit and python.


If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell), it may appear to run properly, but msysgit, python and other tools may not get installed correctly.


If you see strange errors with the file system on the first run of gclient, you may want to disable Windows Indexing.


1.3. Get the Code

  • First, configure Git:
  • Create a chromium directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):
  • Fetch V8
  • fetch v8git pull origin master
  • At least 10GB of free disk space on an NTFS-formatted hard drive.
  • Generate GN project file


cd ~\v8\src> gn gen --ide=vs out\default --args="is_component_build = true is_debug = true v8_optimized_debug = false"


is_debug = true enable V8 debug,v8_optimized_debug = false disenable the optimization that interferes with debug. My args.gn is below:


is_component_build = trueis_debug = truev8_optimized_debug = falsev8_use_snapshot = false


1.4. Build and Run

Compile V8 with VS2019


src\out\default — ->all.sln


Open it,as shown in Figure 1.


In the Solution Explorer, there is the v8_hello_world, right-click it to “Set as Startup Project”, and then build. You can see the compilation process in the output window, as shown in Figure 1.


Figure 2 is the call stack of hello-world.cc.


In summary, if you see strange errors, maybe related to the SDK version or environment path.


2. Where is our starting point

The V8 has huge code, so we need to find an easy way.


The source code of V8 is in src, as shown in Figure 3.



We start to learn from hello-world.cc(it is in the samples directory) as shown in Figure 1.

V8 is the JavaScript engine, the hello-world.cc includes initialization, isolate creation, handle creation, JavaScript compilation, and execution.


Again, the easy way is to debug hello-world.cc one step by one step.


Okay, my blog is cncyclops.com. Please reach out to me if you have any issues.

WeChat: qq9123013 Email: [email protected]



Also published here.