bnoordhuis / v8-cmake

The V8 JavaScript engine, but built with CMake instead of GN - WIP
BSD 3-Clause "New" or "Revised" License
189 stars 54 forks source link

LNK2019: unresolved external symbol "PushAllRegistersAndIterateStack" #57

Closed DuKeM-CSGO closed 1 year ago

DuKeM-CSGO commented 1 year ago

I got an error from the vs linker:

(CustomBuild Target) ->
  H:\Program Files\Microsoft Visual Studio\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build "F:\v8_build\CMakeFiles\8b2e19c09aacbe8a611478e0073e1533\inspector.rule;F:\v8_build\CMakeFiles\19dcba53b9e0ec674542b0a31b094bb7\Debugger.h.rule;F:\Github\RoadtoCmake\build\Release\_deps\v8-src\CMakeLists.txt" exited with code 1. [F:\v8_build\v8_inspector.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  v8_base_without_compiler.lib(stack.obj) : error LNK2019: unresolved external symbol "PushAllRegistersAndIterateStack", referenced in function "public: void __cdecl heap::base::Stack::IteratePointers(class heap::base::StackVisitor *)const " (?IteratePointers@Stack@base@heap@@QEBAXPEAVStackVisitor@23@@Z)  [F:\v8_build\mksnapshot.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  F:\v8_build\Release\mksnapshot.exe : fatal error LNK1120: 1 unresolved external [F:\v8_build\mksnapshot.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  H:\Program Files\Microsoft Visual Studio\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build "F:\v8_build\CMakeFiles\8b2e19c09aacbe8a611478e0073e1533\inspector.rule;F:\v8_build\CMakeFiles\19dcba53b9e0ec674542b0a31b094bb7\Debugger.h.rule;F:\Github\RoadtoCmake\build\Release\_deps\v8-src\CMakeLists.txt" exited with code 1.[F:\v8_build\v8_inspector.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  v8_base_without_compiler.lib(stack.obj) : error LNK2019: unresolved external symbol "PushAllRegistersAndIterateStack", referenced in function "public: void __cdecl heap::base::Stack::IteratePointers(class heap::base::StackVisitor *)const " (?IteratePointers@Stack@base@heap@@QEBAXPEAVStackVisitor@23@@Z)  [F:\v8_build\mksnapshot.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  F:\v8_build\Release\mksnapshot.exe : fatal error LNK1120: 1 unresolved external [F:\v8_build\mksnapshot.vcxproj] [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]
  H:\Program Files\Microsoft Visual Studio\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build "F:\Github\RoadtoCmake\build\Release\CMakeFiles\3dba66e75acaa5bd65c70f284da4c5f3\v8_build.rule" exited with code 1. [F:\Github\RoadtoCmake\build\Release\src\deps\v8\v8_build.vcxproj]

The source used in FETCHCONTENT_DECLARE is GIT_TAG 8.9.255.20. Has there been a fix?

bnoordhuis commented 1 year ago

Yes, I believe this is fixed in newer versions.

DuKeM-CSGO commented 1 year ago

Thanks for replying and I'll try cloning the repo instead of the release soon.

DuKeM-CSGO commented 1 year ago

Yes, I believe this is fixed in newer versions.

The master branch is used now. Here are new errors:

F:\Github\v8-cmake-master\v8\src/heap/spaces.h(345,35): error C2607: static_assert failed [F:\v8_build\v8_torque_generated.vcxproj]
F:\Github\v8-cmake-master\v8\src/heap/spaces.h(346,28): error C2607: static_assert failed [F:\v8_build\v8_torque_generated.vcxproj]
F:\Github\v8-cmake-master\v8\src/heap/large-spaces.h(60,33): error C2607: static_assert failed [F:\v8_build\v8_torque_generated.vcxproj]

(and more) Seems something about "heap"? The following steps are what I did: (downloaded the repo and unziped it manually)

cd /d F:\v8_build
cmake -DCMAKE_BUILD_TYPE=Release -DV8_ENABLE_I18N=ON -G "Visual Studio 17 2022" -T "v143" -A "Win32" F:\Github\v8-cmake-master
cmake --build . --config Release -v -- -r
bnoordhuis commented 1 year ago

Oh, that's odd because it builds fine on our CI (also with VS 2022, I think.) Are you trying to build for 32 bits or 64 bits Windows?

DuKeM-CSGO commented 1 year ago

Changing the generete code to

cmake -DCMAKE_BUILD_TYPE=Release -DV8_ENABLE_I18N=ON -G "Visual Studio 17 2022" -T "v143" -A "x64" F:\Github\v8-cmake-master

and all of those static_assert are successful. It's all due to -A "Win32" surely. I'm using win10 x64. Next errors are here while building v8_torque_genereted.vcxproj:

F:\Github\v8-cmake-master\v8\src/objects/instance-type-inl.h(183,1): error C2039: "IsJSCollator": Not the member of "v8::internal::HeapObject" [F:\v8_build\v8_torque_generated.vcxproj]
F:\Github\v8-cmake-master\v8\src/objects/instance-type-inl.h(183,1): error C2039: "IsJSDateTimeFormat": Not the member of "v8::internal::HeapObject" [F:\v8_build\v8_torque_generated.vcxproj]
F:\Github\v8-cmake-master\v8\src/objects/instance-type-inl.h(183,1): error C2039: "IsJSDisplayNames": Not the member of "v8::internal::HeapObject" [F:\v8_build\v8_torque_generated.vcxproj]
F:\Github\v8-cmake-master\v8\src/objects/instance-type-inl.h(183,1): error C2039: "IsJSDurationFormat": Not the member of "v8::internal::HeapObject" [F:\v8_build\v8_torque_generated.vcxproj]

(and more) Seems the macro INSTANCE_TYPE_CHECKERS failed.

petebannister commented 1 year ago

Not sure if building 32bit is an issue on the newer releases but I did do a PR on 8.7 so aupport IA32 (which is what v8 build calls it - it is seemingly not meaning Itanium as instinct would have it). See PR #44

bnoordhuis commented 1 year ago

@DuKeM-CSGO you'll want to pass -DV8_ENABLE_I18N=OFF because i18n support isn't available in the cmake build (yet - see #4.)

@petebannister sorry, that pull request must've escaped my notice. If you rebase it on top of master and add it to .github/workflows/ci.yml, I'll be happy to merge it.

petebannister commented 1 year ago

@bnoordhuis I'll probably be updating v8 version in my project soon - will see what I can do - I expect some things have changed in v8 since then!

DuKeM-CSGO commented 1 year ago

@DuKeM-CSGO you'll want to pass -DV8_ENABLE_I18N=OFF because i18n support isn't available in the cmake build (yet - see #4.)

Have removed -DCMAKE_BUILD_TYPE=Release and -DV8_ENABLE_I18N=ON. Then here are new errors:

F:\Github\v8-cmake-master\v8\src\objects\js-temporal-objects.cc(5873,41): error C2065: "temp": undeclared identifier [F:\v8_build\v8_base_without_compiler.vcxproj]
F:\Github\v8-cmake-master\v8\src\objects\js-temporal-objects.cc(5879,62): error C2059: syntax error: ")" [F:\v8_build\v8_base_without_compiler.vcxproj]
F:\Github\v8-cmake-master\v8\src\objects\js-temporal-objects.cc(5880,15): error C2039: "ToHandleChecked": Not the member of "v8::internal::Handle<v8::internal::BigInt>" [F:\v8_build\v8_base_without_compiler.vcxproj]

What's strange is when I open v8_base_without_compiler.vcxproj in VS 2022, the IntelliSense works and doesn't treat them as errors. I don't use code page 65001. Maybe the char in line 5866 or something else doesn't be read right, I guess.

bnoordhuis commented 1 year ago

That sounds plausible. It's a compiler bug at any rate because the source file itself is syntactically valid.

I don't think this is something we can fix except maybe by replacing with Z everywhere but it'd be really awkward to carry a humongous patch like that.

edit: we can maybe run the replacement from the update_v8.py script but that could be error prone.

DuKeM-CSGO commented 1 year ago

Manually add "/utf-8" to the compile options of the project, but the better way is adding it to the CMake files. Succeed to build v8_base_without_compiler.vcxproj. Maybe consider to open a new issue for this, and your PR can reference to it.