Commit 0e0d1b0d authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Fix cppgc build

The CPPGC_BUILD_IN_V8 define (used for tracing) isn't propagated from
v8_base_without_compiler to cppgc_base, which breaks build with
perfetto. Instead use a gn args to specify standalone builds (defaulted
to false) and use that to choose the right tracing implementation.

Bug: chromium:1056170
Change-Id: I70bce819d45fb133b6f932a50a5d027e39f3e5b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555007
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71356}
parent 21f001e8
......@@ -460,6 +460,10 @@ config("libbase_config") {
}
}
# Standalone cppgc cannot be built within chrome or with perfetto.
assert(!cppgc_is_standalone || !build_with_chromium)
assert(!cppgc_is_standalone || !v8_use_perfetto)
# This config should be applied to code using the cppgc_base.
config("cppgc_base_config") {
defines = []
......@@ -472,6 +476,9 @@ config("cppgc_base_config") {
if (cppgc_enable_young_generation) {
defines += [ "CPPGC_YOUNG_GENERATION" ]
}
if (!cppgc_is_standalone) {
defines += [ "CPPGC_BUILD_IN_V8" ]
}
}
# This config should be applied to code using the libsampler.
......@@ -3825,8 +3832,6 @@ v8_source_set("v8_base_without_compiler") {
":cppgc_base_config",
]
defines = [ "CPPGC_BUILD_IN_V8" ]
deps = [
":cppgc_base",
":torque_generated_definitions",
......@@ -4427,7 +4432,6 @@ v8_source_set("cppgc_base") {
visibility = [ ":*" ]
sources = [
"//base/trace_event/common/trace_event_common.h",
"include/cppgc/allocation.h",
"include/cppgc/common.h",
"include/cppgc/custom-space.h",
......@@ -4531,6 +4535,10 @@ v8_source_set("cppgc_base") {
"src/heap/cppgc/write-barrier.cc",
]
if (cppgc_is_standalone) {
sources += [ "//base/trace_event/common/trace_event_common.h" ]
}
if (cppgc_enable_caged_heap) {
sources += [
"include/cppgc/internal/caged-heap-local-data.h",
......@@ -4905,16 +4913,22 @@ if (is_component_build) {
configs = [ ":internal_config" ]
if (!cppgc_is_standalone) {
deps = [ ":v8" ]
}
public_configs = [ ":external_config" ]
}
v8_component("cppgc_for_testing") {
testonly = true
if (cppgc_is_standalone) {
v8_component("cppgc_for_testing") {
testonly = true
public_deps = [ ":cppgc_base" ]
public_deps = [ ":cppgc_base" ]
configs = [ ":internal_config" ]
public_configs = [ ":external_config" ]
configs = [ ":internal_config" ]
public_configs = [ ":external_config" ]
}
}
v8_component("v8_cppgc_shared_for_testing") {
......@@ -4952,15 +4966,21 @@ if (is_component_build) {
group("cppgc") {
public_deps = [ ":cppgc_base" ]
if (!cppgc_is_standalone) {
deps = [ ":v8" ]
}
public_configs = [ ":external_config" ]
}
group("cppgc_for_testing") {
testonly = true
if (cppgc_is_standalone) {
group("cppgc_for_testing") {
testonly = true
public_deps = [ ":cppgc_base" ]
public_deps = [ ":cppgc_base" ]
public_configs = [ ":external_config" ]
public_configs = [ ":external_config" ]
}
}
group("v8_cppgc_shared_for_testing") {
......@@ -5082,34 +5102,36 @@ if (want_v8_shell) {
}
}
v8_executable("cppgc_for_v8_embedders") {
sources = [ "samples/cppgc/cppgc-for-v8-embedders.cc" ]
if (cppgc_is_standalone) {
v8_executable("cppgc_standalone") {
sources = [ "samples/cppgc/cppgc-standalone.cc" ]
configs = [
# Note: don't use :internal_config here because this target will get
# the :external_config applied to it by virtue of depending on :cppgc, and
# you can't have both applied to the same target.
":internal_config_base",
]
deps = [
":cppgc",
":v8_libplatform",
"//build/win:default_exe_manifest",
]
}
configs = [
# Note: don't use :internal_config here because this target will get
# the :external_config applied to it by virtue of depending on :cppgc, and
# you can't have both applied to the same target.
":internal_config_base",
]
v8_executable("cppgc_standalone") {
sources = [ "samples/cppgc/cppgc-standalone.cc" ]
deps = [ ":cppgc" ]
}
} else {
v8_executable("cppgc_for_v8_embedders") {
sources = [ "samples/cppgc/cppgc-for-v8-embedders.cc" ]
configs = [
# Note: don't use :internal_config here because this target will get
# the :external_config applied to it by virtue of depending on :cppgc, and
# you can't have both applied to the same target.
":internal_config_base",
]
configs = [
# Note: don't use :internal_config here because this target will get
# the :external_config applied to it by virtue of depending on :cppgc, and
# you can't have both applied to the same target.
":internal_config_base",
]
deps = [ ":cppgc" ]
deps = [
":v8",
":v8_libplatform",
"//build/win:default_exe_manifest",
]
}
}
template("v8_fuzzer") {
......
......@@ -71,6 +71,8 @@ declare_args() {
v8_enable_conservative_stack_scanning = false
v8_enable_google_benchmark = checkout_google_benchmark
cppgc_is_standalone = false
}
if (v8_use_external_startup_data == "") {
......
......@@ -7,6 +7,7 @@
#if CPPGC_BUILD_IN_V8
#include "src/tracing/trace-event.h"
using ConvertableToTraceFormat = v8::ConvertableToTraceFormat;
#else
// This is a subset of stc/tracing/trace-event.h required to support
// tracing in the cppgc standalone library using TracingController.
......
......@@ -28,10 +28,12 @@ if (v8_enable_google_benchmark) {
"../../../../test/unittests/heap/cppgc/test-platform.h",
"utils.h",
]
deps = [
"../../../..:cppgc_for_testing",
"//third_party/google_benchmark:benchmark_main",
]
deps = [ "//third_party/google_benchmark:benchmark_main" ]
if (cppgc_is_standalone) {
deps += [ "../../../..:cppgc_for_testing" ]
} else {
deps += [ "../../../..:v8_for_testing" ]
}
}
v8_executable("cppgc_basic_benchmarks") {
......@@ -48,8 +50,12 @@ if (v8_enable_google_benchmark) {
]
deps = [
":cppgc_benchmark_support",
"../../../..:cppgc_for_testing",
"//third_party/google_benchmark:benchmark_main",
]
if (cppgc_is_standalone) {
deps += [ "../../../..:cppgc_for_testing" ]
} else {
deps += [ "../../../..:v8_for_testing" ]
}
}
}
......@@ -57,23 +57,25 @@ v8_source_set("v8_cppgc_shared_unittests_sources") {
# Stand-alone target for C++ GC unittests. This is used to ensure that it
# builds without V8 as well. They are also included in the regular unittests
# target for simplicity.
v8_executable("cppgc_unittests") {
testonly = true
if (cppgc_is_standalone) {
v8_executable("cppgc_unittests") {
testonly = true
configs = [
"../..:external_config",
"../..:internal_config_base",
]
configs = [
"../..:external_config",
"../..:internal_config_base",
]
sources = [ "heap/cppgc/run-all-unittests.cc" ]
sources = [ "heap/cppgc/run-all-unittests.cc" ]
deps = [
":cppgc_unittests_sources",
":v8_cppgc_shared_unittests_sources",
"../..:cppgc_for_testing",
"//testing/gmock",
"//testing/gtest",
]
deps = [
":cppgc_unittests_sources",
":v8_cppgc_shared_unittests_sources",
"../..:cppgc_for_testing",
"//testing/gmock",
"//testing/gtest",
]
}
}
v8_source_set("cppgc_unittests_sources") {
......@@ -142,7 +144,6 @@ v8_executable("unittests") {
#}],
deps = [
":cppgc_unittests_sources",
":unittests_sources",
":v8_cppgc_shared_unittests_sources",
"../..:v8_for_testing",
......@@ -153,6 +154,10 @@ v8_executable("unittests") {
"//testing/gtest",
]
if (!cppgc_is_standalone) {
deps += [ ":cppgc_unittests_sources" ]
}
data_deps = [ "../../tools:v8_testrunner" ]
data = [
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if !CPPGC_BUILD_IN_V8
#include "src/heap/cppgc/stats-collector.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -300,3 +302,5 @@ TEST_F(CppgcTracingScopesTest, TestIndividualConcurrentScopes) {
} // namespace internal
} // namespace cppgc
#endif // !CPPGC_BUILD_IN_V8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment