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

[8.1] Fix Windows build #21

Merged
merged 3 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ jobs:
- name: build
run: cmake --build ${{runner.workspace}}/build -j 2
- name: test
if: matrix.os != 'windows-latest'
run: ${{runner.workspace}}/build/d8 -e 42
- name: test-windows
if: matrix.os == 'windows-latest'
run: ${{runner.workspace}}/build/Debug/d8 -e 42
shell: powershell
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MSVC.cmake
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(V8 LANGUAGES CXX C ASM)

if(MSVC)
enable_language(ASM_MASM)
set_property(SOURCE ${PROJECT_BINARY_DIR}/embedded.S PROPERTY LANGUAGE ASM_MASM)
endif()

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(THREADS_PREFER_PTHREAD_FLAG ON)

Expand Down Expand Up @@ -164,7 +169,7 @@ file(GLOB extensions-sources CONFIGURE_DEPENDS v8/src/extensions/*.cc)
file(GLOB interpreter-sources CONFIGURE_DEPENDS v8/src/interpreter/*.cc)
file(GLOB json-sources CONFIGURE_DEPENDS v8/src/json/*.cc)
file(GLOB logging-sources CONFIGURE_DEPENDS v8/src/logging/*.cc)
file(GLOB heap-sources CONFIGURE_DEPENDS v8/src/heap/*.cc)
file(GLOB heap-sources CONFIGURE_DEPENDS v8/src/heap/*.cc v8/src/heap/third-party/*.cc)
file(GLOB numbers-sources CONFIGURE_DEPENDS v8/src/numbers/*.cc)
file(GLOB object-sources CONFIGURE_DEPENDS v8/src/objects/*.cc)
file(GLOB parsing-sources CONFIGURE_DEPENDS v8/src/parsing/*.cc)
Expand Down Expand Up @@ -450,6 +455,7 @@ add_custom_command(
$<${is-x64}:--target_arch=x64>
$<$<PLATFORM_ID:Darwin>:--target_os=mac>
$<$<PLATFORM_ID:Linux>:--target_os=linux>
$<$<PLATFORM_ID:Windows>:--target_os=win>
--turbo_instruction_scheduling
DEPENDS
mksnapshot
Expand Down
77 changes: 77 additions & 0 deletions patches/0002-Patch-v8-src-heap-third-party.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From 7491dcc78090a1f022481eadbbda754719bb2962 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <[email protected]>
Date: Tue, 21 Apr 2020 18:15:06 +0200
Subject: [PATCH] Patch v8/src/heap/third-party

Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

Refs: https://github.com/bnoordhuis/v8-cmake/issues/10
---
v8/src/heap/third-party/heap-api-stub.cc | 54 ++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 v8/src/heap/third-party/heap-api-stub.cc

diff --git a/v8/src/heap/third-party/heap-api-stub.cc b/v8/src/heap/third-party/heap-api-stub.cc
new file mode 100644
index 0000000..9d71468
--- /dev/null
+++ b/v8/src/heap/third-party/heap-api-stub.cc
@@ -0,0 +1,54 @@
+// Copyright 2020 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/heap/third-party/heap-api.h"
+#include "src/execution/isolate-utils-inl.h"
+#include "src/heap/heap-inl.h"
+
+// Work around Visual Studio linker errors when V8_ENABLE_THIRD_PARTY_HEAP
+// is disabled.
+#ifndef V8_ENABLE_THIRD_PARTY_HEAP
+
+namespace v8 {
+namespace internal {
+
+Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) {
+ return GetHeapFromWritableObject(object)->isolate();
+}
+
+} // namespace internal
+} // namespace v8
+
+namespace v8 {
+namespace internal {
+namespace third_party_heap {
+
+// static
+std::unique_ptr<Heap> Heap::New(v8::Isolate*) { return nullptr; }
+
+// static
+v8::Isolate* Heap::GetIsolate(Address) { return nullptr; }
+
+AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) {
+ return AllocationResult();
+}
+
+Address Heap::GetObjectFromInnerPointer(Address) { return 0; }
+
+// static
+bool Heap::InCodeSpace(Address) { return false; }
+
+// static
+bool Heap::InReadOnlySpace(Address) { return false; }
+
+// static
+bool Heap::IsValidHeapObject(HeapObject) { return false; }
+
+bool Heap::CollectGarbage() { return false; }
+
+} // namespace third_party_heap
+} // namespace internal
+} // namespace v8
+
+#endif // !defined(V8_ENABLE_THIRD_PARTY_HEAP)
--
2.20.1

54 changes: 54 additions & 0 deletions v8/src/heap/third-party/heap-api-stub.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/heap/third-party/heap-api.h"
#include "src/execution/isolate-utils-inl.h"
#include "src/heap/heap-inl.h"

// Work around Visual Studio linker errors when V8_ENABLE_THIRD_PARTY_HEAP
// is disabled.
#ifndef V8_ENABLE_THIRD_PARTY_HEAP

namespace v8 {
namespace internal {

Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) {
return GetHeapFromWritableObject(object)->isolate();
}

} // namespace internal
} // namespace v8

namespace v8 {
namespace internal {
namespace third_party_heap {

// static
std::unique_ptr<Heap> Heap::New(v8::Isolate*) { return nullptr; }

// static
v8::Isolate* Heap::GetIsolate(Address) { return nullptr; }

AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) {
return AllocationResult();
}

Address Heap::GetObjectFromInnerPointer(Address) { return 0; }

// static
bool Heap::InCodeSpace(Address) { return false; }

// static
bool Heap::InReadOnlySpace(Address) { return false; }

// static
bool Heap::IsValidHeapObject(HeapObject) { return false; }

bool Heap::CollectGarbage() { return false; }

} // namespace third_party_heap
} // namespace internal
} // namespace v8

#endif // !defined(V8_ENABLE_THIRD_PARTY_HEAP)