v8/v8.dev

Could not build v8 on windows with VS2019

SamCZ opened this issue · 12 comments

SamCZ commented

Hi for a few days I've been trying to build v8 on windows with MSVC 14.29.30133 and WinSDK 10.0.19041.0

My build commands:

python3 tools/dev/v8gen.py x64.release.sample
ninja -C out.gn/x64.release.sample v8_monolith

it produces this error

FAILED: obj/v8_base_without_compiler/api.obj
..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /c ../../src/api/api.cc /Foobj/v8_base_without_compiler/api.obj /nologo /showIncludes:user "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" "-imsvcC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" -DUSE_AURA=1 "-DCR_CLANG_REVISION=\"llvmorg-14-init-18258-g9477a308-1\"" -D_HAS_NODISCARD -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_VB -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DV8_INTL_SUPPORT -DENABLE_HANDLE_ZAPPING -DV8_ATOMIC_OBJECT_FIELD_WRITES -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_SHORT_BUILTIN_CALLS -DV8_EXTERNAL_CODE_SPACE -DV8_ENABLE_SYSTEM_INSTRUMENTATION -DV8_ENABLE_WEBASSEMBLY -DV8_ALLOCATION_FOLDING -DV8_ALLOCATION_SITE_TRACKING -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_COMPRESS_POINTERS -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DCPPGC_CAGED_HEAP -DV8_TARGET_ARCH_X64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_WIN -DV8_RUNTIME_CALL_STATS -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../include -Igen/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/zlib -fno-delete-null-pointer-checks -fno-ident -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 /clang:-ffp-contract=off -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase /Zc:sizedDealloc- /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1916 -m64 -msse3 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes /W4 -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wextra-semi /WX -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wno-null-pointer-subtraction -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wmax-tokens -Wshadow /Z7 -gcodeview-ghash -Xclang -fuse-ctor-homing /guard:cf /MT -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Winvalid-offsetof -Wno-range-loop-construct -Werror -Wmissing-field-initializers -Wno-shadow -Wunreachable-code -Wshorten-64-to-32 /wd4245 /wd4267 /wd4324 /wd4701 /wd4702 /wd4703 /wd4709 /wd4714 /wd4715 /wd4718 /wd4723 /wd4724 /wd4800 /O2 /Ob2 /Oy- /Zc:inline /Gw -Wexit-time-destructors /std:c++17 -Wno-trigraphs /Zc:alignedNew- /TP /GR- /Fd"obj/v8_base_without_compiler_cc.pdb"
In file included from ../../src/api/api.cc:52:
../..\src/deoptimizer/deoptimizer.h(109,38): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
  static int input_offset() { return offsetof(Deoptimizer, input_); }
                                     ^                     ~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\14.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/api/api.cc:52:
../..\src/deoptimizer/deoptimizer.h(111,12): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
    return offsetof(Deoptimizer, output_count_);
           ^                     ~~~~~~~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\14.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/api/api.cc:52:
../..\src/deoptimizer/deoptimizer.h(113,39): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
  static int output_offset() { return offsetof(Deoptimizer, output_); }
                                      ^                     ~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\14.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from ../../src/api/api.cc:52:
../..\src/deoptimizer/deoptimizer.h(116,12): error: offset of on non-standard-layout type 'v8::internal::Deoptimizer' [-Werror,-Winvalid-offsetof]
    return offsetof(Deoptimizer, caller_frame_top_);
           ^                     ~~~~~~~~~~~~~~~~~
..\..\third_party\llvm-build\Release+Asserts\lib\clang\14.0.0\include\stddef.h(104,24): note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
4 errors generated.
[1090/1772] CXX obj/v8_base_without_compiler/modules.obj
ninja: build stopped: subcommand failed.

I tried added -Winvalid-offsetof to cflags and also to toolchain.ninja, but with no luck.

Can sombody please help me ?

It needs to be patched. Please refer to this doc for the patch script.

SamCZ commented

Were do I find the python %JAVET_HOME%\scripts\python\patch_v8_build.py -p .\ JAVET ?

SamCZ commented

Im trying to build v8 to use it as embedded scripting in my C++ engine

SamCZ commented

ok I found the script in javet git repo, I will try it

SamCZ commented

@caoccao What version of v8 are you recommending ? There is so much tags I don't know what is the best stable

@caoccao What version of v8 are you recommending ? There is so much tags I don't know what is the best stable

The V8 listed on Javet home page is the recommended one.

SamCZ commented

Thanks, build is working now.

It is normal that the v8_monolith is almost 1GB on release ?
image

SamCZ commented

I got this error while linking v8 to simple VS program E:\v8\v8\out\x64.release\obj\v8_libbase.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0xCC2E

SamCZ commented

@caoccao I tried to recompile it all again and I cannot still link it in VS

SamCZ commented

Got it working, the problem was the v8 was in default building with clang, when I disabled that I managed to link it in VS

SamCZ commented

So the only question remains if the v8_monolith library should be around 1GB
@caoccao Thanks fror the help
image

No. If you go with the MSVC, it should be 100+MB. Please refer to this dockerfile for the complete steps.

v8_monolith