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 build on windows #18

Closed
wants to merge 18 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: v8-cmake

on:
push:
pull_request:
paths:
- 'CMakeLists.txt'
Expand All @@ -25,4 +26,10 @@ 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
10 changes: 7 additions & 3 deletions 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 @@ -54,7 +59,6 @@ string(CONCAT is-x64 $<OR:
>)

option(V8_ENABLE_CONCURRENT_MARKING "Enable concurrent marking" ON)
option(V8_ENABLE_THIRD_PARTY_HEAP "Enable third party HEAP library" OFF)
option(V8_ENABLE_I18N "Enable Internationalization support")

set(
Expand All @@ -69,7 +73,6 @@ set(
$<${is-win}:NOMINMAX>
$<$<OR:${is-win},${is-x64}>:V8_OS_WINX64>
$<$<BOOL:${V8_ENABLE_CONCURRENT_MARKING}>:V8_CONCURRENT_MARKING>
$<$<BOOL:${V8_ENABLE_THIRD_PARTY_HEAP}>:V8_ENABLE_THIRD_PARTY_HEAP>
$<${is-win}:V8_OS_WIN32>
)

Expand Down Expand Up @@ -165,7 +168,7 @@ file(GLOB handles-sources CONFIGURE_DEPENDS v8/src/handles/*.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 @@ -452,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
70 changes: 70 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,70 @@
From eba7aae41a74bab1aba7e26effbebf4c3e297c0d Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <[email protected]>
Date: Wed, 15 Apr 2020 11:11:44 +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 | 47 ++++++++++++++++++++++++
1 file changed, 47 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..3135aca
--- /dev/null
+++ b/v8/src/heap/third-party/heap-api-stub.cc
@@ -0,0 +1,47 @@
+// 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"
+
+namespace v8 {
+namespace internal {
+namespace third_party_heap {
+
+// Work around Visual Studio linker errors when V8_ENABLE_THIRD_PARTY_HEAP
+// is disabled.
+#ifndef V8_ENABLE_THIRD_PARTY_HEAP
+
+// static
+std::unique_ptr<Heap> Heap::New(v8::internal::Isolate*) { return nullptr; }
+
+// static
+v8::internal::Isolate* Heap::GetIsolate(Address) { return nullptr; }
+
+AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) {
+ return AllocationResult();
+}
+
+Address Heap::GetObjectFromInnerPointer(Address) { return 0; }
+
+const base::AddressRegion& Heap::GetCodeRange() {
+ static const base::AddressRegion no_region(0, 0);
+ return no_region;
+}
+
+// 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; }
+
+#endif // !defined(V8_ENABLE_THIRD_PARTY_HEAP)
+
+} // namespace third_party_heap
+} // namespace internal
+} // namespace v8
--
2.20.1

59 changes: 59 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,59 @@
// 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::internal::Isolate*) { return nullptr; }

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

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

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

const base::AddressRegion& Heap::GetCodeRange() {
static const base::AddressRegion no_region(0, 0);
return no_region;
}

// 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)