使用 MSVC 在 Windows 10 上编译 V8 引擎时出现编译错误

Compilation errors while compiling V8 engine on Windows 10 with MSVC

首先,我运行下一个命令:

python tools/dev/v8gen.py x64.release.sample

所有GN文件生成成功。之后我 运行 以下命令:

ninja -C out.gn/x64.release.sample v8_monolith

经过几分钟的编译,我收到了很多编译错误:

[226/1842] LINK bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
FAILED: bytecode_builtins_list_generator.exe bytecode_builtins_list_generator.exe.pdb
..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /OUT:./bytecode_builtins_list_generator.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang.0.0\lib\windows "-libpath:../../../Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/ATLMFC/lib/x64" "-libpath:../../../Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/lib/x64" "-libpath:C:\Program Files (x86)\Windows Kits\NETFXSDK.8\lib\um\x64" "-libpath:C:\Program Files (x86)\Windows Kits\lib.0.19041.0\ucrt\x64" "-libpath:C:\Program Files (x86)\Windows Kits\lib.0.19041.0\um\x64" /MACHINE:X64  /PDB:./bytecode_builtins_list_generator.exe.pdb @./bytecode_builtins_list_generator.exe.rsp
lld-link: error: procedure symbol record for `_CxxThrowException` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\throw.obj refers to PDB item index 0x134F which is not a valid function ID record
lld-link: error: procedure symbol record for `_IsExceptionObjectToBeDestroyed` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\ehhelpers.obj refers to PDB item index 0x1193 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameUnwindFilter` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\ehhelpers.obj refers to PDB item index 0x118E which is not a valid function ID record
lld-link: error: procedure symbol record for `__std_terminate` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\ehhelpers.obj refers to PDB item index 0x1190 which is not a valid function ID record
lld-link: error: procedure symbol record for `_CallSETranslator<__FrameHandler3>` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12F7 which is not a valid function ID record
lld-link: error: procedure symbol record for `_CallSETranslator<__FrameHandler4>` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12F8 which is not a valid function ID record
lld-link: error: procedure symbol record for `FH4::DecompFuncInfo` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x1151 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler3::ExecutionInCatch` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12EC which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler4::ExecutionInCatch` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12DF which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler4::FrameUnwindToEmptyState` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12E2 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler3::GetEstablisherFrame` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12F0 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler3::GetRangeOfTrysToCheck` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12F6 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler3::UnwindNestedFrames` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12F1 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler4::UnwindNestedFrames` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12E3 which is not a valid function ID record
lld-link: error: procedure symbol record for `_CreateFrameInfo` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12DD which is not a valid function ID record
lld-link: error: procedure symbol record for `_GetThrowImageBase` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12EB which is not a valid function ID record
lld-link: error: procedure symbol record for `_SetImageBase` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12DB which is not a valid function ID record
lld-link: error: procedure symbol record for `_SetThrowImageBase` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\risctrnsctrl.obj refers to PDB item index 0x12FB which is not a valid function ID record
lld-link: error: procedure symbol record for `__vcrt_getptd` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\per_thread_data.obj refers to PDB item index 0x1270 which is not a valid function ID record
lld-link: error: procedure symbol record for `__FrameHandler3::GetCurrentState` in d:\a01\_work\s\Intermediate\vctools\libvcruntime.nativeproj_520857879\objr\amd64\ehstate.obj refers to PDB item index 0x12F2 which is not a valid function ID record
lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
[235/1842] CXX obj/torque_base/implementation-visitor.obj
ninja: build stopped: subcommand failed.

是什么导致了这个问题?如何解决?

我遇到了同样的问题,我是这样解决的:

  1. 下载visual studio 2019 安装包,安装vs2019,注意不需要勾选Windows SDK 项,因为这不是重点,也不需要reinstall/add 新版本Windows 个 SDK。并且,vs2019 可以与 vs2022 一起存在。
  2. 切换到vs2019编译环境:打开一个新的Windows终端选项卡,然后执行命令:
> set vs2019_install=[path to your \Microsoft Visual Studio19\Community]
> set WINDOWSSDKDIR=[path to your \Windows Kits]
> set DEPOT_TOOLS_WIN_TOOLCHAIN=0
> gclient sync

  1. 好的,您现在可以使用 vs2019 构建 v8:
> python tools\dev\gm.py x64.release

希望对您有所帮助。