Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows link errors #10

Closed
bnoordhuis opened this issue Mar 21, 2020 · 11 comments
Closed

Fix Windows link errors #10

bnoordhuis opened this issue Mar 21, 2020 · 11 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bnoordhuis
Copy link
Owner

bnoordhuis commented Mar 21, 2020

2020-03-20T12:33:28.1458979Z   Generating Code...
2020-03-20T12:33:32.6810043Z      Creating library D:/a/v8-cmake/build/Debug/mksnapshot.lib and object D:/a/v8-cmake/build/Debug/mksnapshot.exp
2020-03-20T12:33:33.0922222Z v8_base_without_compiler.lib(setup-heap-internal.obj) : error LNK2019: unresolved external symbol "public: class v8::internal::AllocationResult __cdecl v8::internal::third_party_heap::Heap::Allocate(unsigned __int64,enum v8::internal::AllocationType,enum v8::internal::AllocationAlignment)" (?Allocate@Heap@third_party_heap@internal@v8@@QEAA?AVAllocationResult@34@_KW4AllocationType@34@W4AllocationAlignment@34@@Z) referenced in function "private: class v8::internal::AllocationResult __cdecl v8::internal::Heap::AllocateRaw(int,enum v8::internal::AllocationType,enum v8::internal::AllocationOrigin,enum v8::internal::AllocationAlignment)" (?AllocateRaw@Heap@internal@v8@@AEAA?AVAllocationResult@23@HW4AllocationType@23@W4AllocationOrigin@23@W4AllocationAlignment@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.0923210Z v8_base_without_compiler.lib(heap.obj) : error LNK2001: unresolved external symbol "public: class v8::internal::AllocationResult __cdecl v8::internal::third_party_heap::Heap::Allocate(unsigned __int64,enum v8::internal::AllocationType,enum v8::internal::AllocationAlignment)" (?Allocate@Heap@third_party_heap@internal@v8@@QEAA?AVAllocationResult@34@_KW4AllocationType@34@W4AllocationAlignment@34@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.0923845Z v8_base_without_compiler.lib(factory.obj) : error LNK2001: unresolved external symbol "public: class v8::internal::AllocationResult __cdecl v8::internal::third_party_heap::Heap::Allocate(unsigned __int64,enum v8::internal::AllocationType,enum v8::internal::AllocationAlignment)" (?Allocate@Heap@third_party_heap@internal@v8@@QEAA?AVAllocationResult@34@_KW4AllocationType@34@W4AllocationAlignment@34@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2348702Z v8_base_without_compiler.lib(heap.obj) : error LNK2019: unresolved external symbol "public: static class v8::internal::Isolate * __cdecl v8::internal::Heap::GetIsolateFromWritableObject(class v8::internal::HeapObject)" (?GetIsolateFromWritableObject@Heap@internal@v8@@SAPEAVIsolate@23@VHeapObject@23@@Z) referenced in function "public: static class v8::internal::Heap * __cdecl v8::internal::Heap::FromWritableHeapObject(class v8::internal::HeapObject)" (?FromWritableHeapObject@Heap@internal@v8@@SAPEAV123@VHeapObject@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2350779Z v8_base_without_compiler.lib(objects.obj) : error LNK2001: unresolved external symbol "public: static class v8::internal::Isolate * __cdecl v8::internal::Heap::GetIsolateFromWritableObject(class v8::internal::HeapObject)" (?GetIsolateFromWritableObject@Heap@internal@v8@@SAPEAVIsolate@23@VHeapObject@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2351391Z v8_base_without_compiler.lib(string.obj) : error LNK2001: unresolved external symbol "public: static class v8::internal::Isolate * __cdecl v8::internal::Heap::GetIsolateFromWritableObject(class v8::internal::HeapObject)" (?GetIsolateFromWritableObject@Heap@internal@v8@@SAPEAVIsolate@23@VHeapObject@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2352407Z v8_base_without_compiler.lib(heap.obj) : error LNK2019: unresolved external symbol "public: unsigned __int64 __cdecl v8::internal::third_party_heap::Heap::GetObjectFromInnerPointer(unsigned __int64)" (?GetObjectFromInnerPointer@Heap@third_party_heap@internal@v8@@QEAA_K_K@Z) referenced in function "public: class v8::internal::Code __cdecl v8::internal::Heap::GcSafeFindCodeForInnerPointer(unsigned __int64)" (?GcSafeFindCodeForInnerPointer@Heap@internal@v8@@QEAA?AVCode@23@_K@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2356048Z v8_base_without_compiler.lib(heap.obj) : error LNK2019: unresolved external symbol "public: static bool __cdecl v8::internal::third_party_heap::Heap::IsValidHeapObject(class v8::internal::HeapObject)" (?IsValidHeapObject@Heap@third_party_heap@internal@v8@@SA_NVHeapObject@34@@Z) referenced in function "bool __cdecl v8::internal::IsValidHeapObject(class v8::internal::Heap *,class v8::internal::HeapObject)" (?IsValidHeapObject@internal@v8@@YA_NPEAVHeap@12@VHeapObject@12@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2361054Z v8_base_without_compiler.lib(heap.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl v8::internal::third_party_heap::Heap::CollectGarbage(void)" (?CollectGarbage@Heap@third_party_heap@internal@v8@@QEAA_NXZ) referenced in function "private: bool __cdecl v8::internal::Heap::PerformGarbageCollection(enum v8::internal::GarbageCollector,enum v8::GCCallbackFlags)" (?PerformGarbageCollection@Heap@internal@v8@@AEAA_NW4GarbageCollector@23@W4GCCallbackFlags@3@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2361573Z v8_base_without_compiler.lib(read-only-heap.obj) : error LNK2019: unresolved external symbol "public: static bool __cdecl v8::internal::third_party_heap::Heap::InReadOnlySpace(unsigned __int64)" (?InReadOnlySpace@Heap@third_party_heap@internal@v8@@SA_N_K@Z) referenced in function "public: static bool __cdecl v8::internal::ReadOnlyHeap::Contains(class v8::internal::HeapObject)" (?Contains@ReadOnlyHeap@internal@v8@@SA_NVHeapObject@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2362036Z v8_base_without_compiler.lib(serializer.obj) : error LNK2019: unresolved external symbol "public: static bool __cdecl v8::internal::third_party_heap::Heap::InCodeSpace(unsigned __int64)" (?InCodeSpace@Heap@third_party_heap@internal@v8@@SA_N_K@Z) referenced in function "enum v8::internal::SnapshotSpace __cdecl v8::internal::`anonymous namespace'::GetSnapshotSpace(class v8::internal::HeapObject)" (?GetSnapshotSpace@?A0xce24117a@internal@v8@@YA?AW4SnapshotSpace@23@VHeapObject@23@@Z) [D:\a\v8-cmake\build\mksnapshot.vcxproj]
2020-03-20T12:33:33.2880218Z D:\a\v8-cmake\build\Debug\mksnapshot.exe : fatal error LNK1120: 7 unresolved externals [D:\a\v8-cmake\build\mksnapshot.vcxproj]

Honorable mention for whoever fixes that and gets the CI green!

@bnoordhuis bnoordhuis added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Mar 21, 2020
@gengjiawen
Copy link
Collaborator

I suspect it's related to this file, https://github.com/bnoordhuis/v8-cmake/blob/master/v8/src/heap/third-party/heap-api.h.

But I have not find proper way to fix this.

@gengjiawen
Copy link
Collaborator

Looks like windows enable V8_ENABLE_THIRD_PARTY_HEAP by default somehow.

@bnoordhuis
Copy link
Owner Author

I tried removing that in #3 (8c4e2fc) but it made no difference. :-/

@gengjiawen
Copy link
Collaborator

I kind of figure out why the problem. It's visual studio compiler aggressively evalate expression never got executed (See L203 for example).

if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
allocation = tp_heap_->Allocate(size_in_bytes, type, alignment);
} else {
if (AllocationType::kYoung == type) {
if (large_object) {
if (FLAG_young_generation_large_objects) {

I am not sure visual studio compiler has flag to disable this.

@gengjiawen
Copy link
Collaborator

Also after I resolved related code (comment related code), windows build still failed with

LINK : fatal error LNK1181: ????????"CMakeFiles\v8_snapshot.dir\embedded.S.obj"

bnoordhuis added a commit that referenced this issue Apr 15, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: #10
@bnoordhuis
Copy link
Owner Author

Ah, that sounds plausible! I arrive at the opposite conclusion though: VS doesn't eliminate dead code as aggressively as clang and gcc. :-)

I updated #3 with a stub implementation of third_party_heap::Heap, let's see how far we get this time.

@gengjiawen
Copy link
Collaborator

I also try to figure it the flags used by v8 official team. But turned out they are using clang on windows, so I guess we have to fix msvc on our own.

@gengjiawen
Copy link
Collaborator

stub implementation

This is brilliant idea :). Much better than my original plan.

bnoordhuis added a commit that referenced this issue Apr 15, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: #10
@petebannister
Copy link

I've also had 3 days of hell trying to get this to build in a conan recipe... I came across your cmake effort during my journey as coming up against the same problem..

It does indeed appear to be the perplexing decision to use:
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL)
instead of
#ifdef V8_ENABLE_THIRD_PARTY_HEAP

My release builds were successfully linking mksnapshot.exe -- but debug build was failing for the same reason as yours.

My solution in the end was to just optimize the debug build by specifying v8_optimized_debug=true to v8gen.py. Its already slow as hell anyway due to having to specify enable_iterator_debugging=true for the debug build... Otherwise any projects linking to debug lib MUST also use SECURE_SCL=0. And all static library dependencies. Otherwise it will randomly crash if it does manage to link.

I'm still waiting on the full build to finish to be sure that resolves it and I can still link to v8_monolith! Hopefully that will occur today.

I reported to v8 team:
https://bugs.chromium.org/p/v8/issues/detail?id=10427

This was referenced Apr 17, 2020
@bnoordhuis
Copy link
Owner Author

Fixed by #18!

bnoordhuis added a commit that referenced this issue Apr 21, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: #10
bnoordhuis pushed a commit that referenced this issue Apr 21, 2020
Fixes: #10
PR-URL: #18
Reviewed-By: Ben Noordhuis <[email protected]>
@bnoordhuis
Copy link
Owner Author

It does indeed appear to be the perplexing decision to use: [..]

I can see why they did that though: it means the code gets checked by the compiler, regardless of the platform. You don't get that when it's fenced off by #ifdefs.

I'll try to upstream the patch we're currently carrying, that should hopefully also resolve your issue.

bnoordhuis added a commit that referenced this issue Apr 21, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: #10
bnoordhuis pushed a commit that referenced this issue Apr 21, 2020
Fixes: #10
PR-URL: #18
Reviewed-By: Ben Noordhuis <[email protected]>
bnoordhuis added a commit that referenced this issue Apr 21, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: #10
bnoordhuis pushed a commit that referenced this issue Apr 21, 2020
Fixes: #10
PR-URL: #18
Reviewed-By: Ben Noordhuis <[email protected]>
pull bot pushed a commit to p-g-krish/v8 that referenced this issue Apr 22, 2020
Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

cl.exe in debug mode seems to eliminate dead code not as aggressively
as clang or gcc, resulting in references to `third_party_heap::Heap`
remaining in unreachable code paths.

Refs: bnoordhuis/v8-cmake#10
Bug: v8:10427
Change-Id: I61fde11697adc663b182f60c132eda435a7f11bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2159490
Commit-Queue: Ben Noordhuis <[email protected]>
Commit-Queue: Ulan Degenbaev <[email protected]>
Auto-Submit: Ben Noordhuis <[email protected]>
Reviewed-by: Ulan Degenbaev <[email protected]>
Cr-Commit-Position: refs/heads/master@{#67293}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants