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") { ...@@ -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. # This config should be applied to code using the cppgc_base.
config("cppgc_base_config") { config("cppgc_base_config") {
defines = [] defines = []
...@@ -472,6 +476,9 @@ config("cppgc_base_config") { ...@@ -472,6 +476,9 @@ config("cppgc_base_config") {
if (cppgc_enable_young_generation) { if (cppgc_enable_young_generation) {
defines += [ "CPPGC_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. # This config should be applied to code using the libsampler.
...@@ -3825,8 +3832,6 @@ v8_source_set("v8_base_without_compiler") { ...@@ -3825,8 +3832,6 @@ v8_source_set("v8_base_without_compiler") {
":cppgc_base_config", ":cppgc_base_config",
] ]
defines = [ "CPPGC_BUILD_IN_V8" ]
deps = [ deps = [
":cppgc_base", ":cppgc_base",
":torque_generated_definitions", ":torque_generated_definitions",
...@@ -4427,7 +4432,6 @@ v8_source_set("cppgc_base") { ...@@ -4427,7 +4432,6 @@ v8_source_set("cppgc_base") {
visibility = [ ":*" ] visibility = [ ":*" ]
sources = [ sources = [
"//base/trace_event/common/trace_event_common.h",
"include/cppgc/allocation.h", "include/cppgc/allocation.h",
"include/cppgc/common.h", "include/cppgc/common.h",
"include/cppgc/custom-space.h", "include/cppgc/custom-space.h",
...@@ -4531,6 +4535,10 @@ v8_source_set("cppgc_base") { ...@@ -4531,6 +4535,10 @@ v8_source_set("cppgc_base") {
"src/heap/cppgc/write-barrier.cc", "src/heap/cppgc/write-barrier.cc",
] ]
if (cppgc_is_standalone) {
sources += [ "//base/trace_event/common/trace_event_common.h" ]
}
if (cppgc_enable_caged_heap) { if (cppgc_enable_caged_heap) {
sources += [ sources += [
"include/cppgc/internal/caged-heap-local-data.h", "include/cppgc/internal/caged-heap-local-data.h",
...@@ -4905,9 +4913,14 @@ if (is_component_build) { ...@@ -4905,9 +4913,14 @@ if (is_component_build) {
configs = [ ":internal_config" ] configs = [ ":internal_config" ]
if (!cppgc_is_standalone) {
deps = [ ":v8" ]
}
public_configs = [ ":external_config" ] public_configs = [ ":external_config" ]
} }
if (cppgc_is_standalone) {
v8_component("cppgc_for_testing") { v8_component("cppgc_for_testing") {
testonly = true testonly = true
...@@ -4916,6 +4929,7 @@ if (is_component_build) { ...@@ -4916,6 +4929,7 @@ if (is_component_build) {
configs = [ ":internal_config" ] configs = [ ":internal_config" ]
public_configs = [ ":external_config" ] public_configs = [ ":external_config" ]
} }
}
v8_component("v8_cppgc_shared_for_testing") { v8_component("v8_cppgc_shared_for_testing") {
testonly = true testonly = true
...@@ -4952,9 +4966,14 @@ if (is_component_build) { ...@@ -4952,9 +4966,14 @@ if (is_component_build) {
group("cppgc") { group("cppgc") {
public_deps = [ ":cppgc_base" ] public_deps = [ ":cppgc_base" ]
if (!cppgc_is_standalone) {
deps = [ ":v8" ]
}
public_configs = [ ":external_config" ] public_configs = [ ":external_config" ]
} }
if (cppgc_is_standalone) {
group("cppgc_for_testing") { group("cppgc_for_testing") {
testonly = true testonly = true
...@@ -4962,6 +4981,7 @@ if (is_component_build) { ...@@ -4962,6 +4981,7 @@ if (is_component_build) {
public_configs = [ ":external_config" ] public_configs = [ ":external_config" ]
} }
}
group("v8_cppgc_shared_for_testing") { group("v8_cppgc_shared_for_testing") {
testonly = true testonly = true
...@@ -5082,8 +5102,9 @@ if (want_v8_shell) { ...@@ -5082,8 +5102,9 @@ if (want_v8_shell) {
} }
} }
v8_executable("cppgc_for_v8_embedders") { if (cppgc_is_standalone) {
sources = [ "samples/cppgc/cppgc-for-v8-embedders.cc" ] v8_executable("cppgc_standalone") {
sources = [ "samples/cppgc/cppgc-standalone.cc" ]
configs = [ configs = [
# Note: don't use :internal_config here because this target will get # Note: don't use :internal_config here because this target will get
...@@ -5092,15 +5113,11 @@ v8_executable("cppgc_for_v8_embedders") { ...@@ -5092,15 +5113,11 @@ v8_executable("cppgc_for_v8_embedders") {
":internal_config_base", ":internal_config_base",
] ]
deps = [ deps = [ ":cppgc" ]
":cppgc", }
":v8_libplatform", } else {
"//build/win:default_exe_manifest", v8_executable("cppgc_for_v8_embedders") {
] sources = [ "samples/cppgc/cppgc-for-v8-embedders.cc" ]
}
v8_executable("cppgc_standalone") {
sources = [ "samples/cppgc/cppgc-standalone.cc" ]
configs = [ configs = [
# Note: don't use :internal_config here because this target will get # Note: don't use :internal_config here because this target will get
...@@ -5109,7 +5126,12 @@ v8_executable("cppgc_standalone") { ...@@ -5109,7 +5126,12 @@ v8_executable("cppgc_standalone") {
":internal_config_base", ":internal_config_base",
] ]
deps = [ ":cppgc" ] deps = [
":v8",
":v8_libplatform",
"//build/win:default_exe_manifest",
]
}
} }
template("v8_fuzzer") { template("v8_fuzzer") {
......
...@@ -71,6 +71,8 @@ declare_args() { ...@@ -71,6 +71,8 @@ declare_args() {
v8_enable_conservative_stack_scanning = false v8_enable_conservative_stack_scanning = false
v8_enable_google_benchmark = checkout_google_benchmark v8_enable_google_benchmark = checkout_google_benchmark
cppgc_is_standalone = false
} }
if (v8_use_external_startup_data == "") { if (v8_use_external_startup_data == "") {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#if CPPGC_BUILD_IN_V8 #if CPPGC_BUILD_IN_V8
#include "src/tracing/trace-event.h" #include "src/tracing/trace-event.h"
using ConvertableToTraceFormat = v8::ConvertableToTraceFormat;
#else #else
// This is a subset of stc/tracing/trace-event.h required to support // This is a subset of stc/tracing/trace-event.h required to support
// tracing in the cppgc standalone library using TracingController. // tracing in the cppgc standalone library using TracingController.
......
...@@ -28,10 +28,12 @@ if (v8_enable_google_benchmark) { ...@@ -28,10 +28,12 @@ if (v8_enable_google_benchmark) {
"../../../../test/unittests/heap/cppgc/test-platform.h", "../../../../test/unittests/heap/cppgc/test-platform.h",
"utils.h", "utils.h",
] ]
deps = [ deps = [ "//third_party/google_benchmark:benchmark_main" ]
"../../../..:cppgc_for_testing", if (cppgc_is_standalone) {
"//third_party/google_benchmark:benchmark_main", deps += [ "../../../..:cppgc_for_testing" ]
] } else {
deps += [ "../../../..:v8_for_testing" ]
}
} }
v8_executable("cppgc_basic_benchmarks") { v8_executable("cppgc_basic_benchmarks") {
...@@ -48,8 +50,12 @@ if (v8_enable_google_benchmark) { ...@@ -48,8 +50,12 @@ if (v8_enable_google_benchmark) {
] ]
deps = [ deps = [
":cppgc_benchmark_support", ":cppgc_benchmark_support",
"../../../..:cppgc_for_testing",
"//third_party/google_benchmark:benchmark_main", "//third_party/google_benchmark:benchmark_main",
] ]
if (cppgc_is_standalone) {
deps += [ "../../../..:cppgc_for_testing" ]
} else {
deps += [ "../../../..:v8_for_testing" ]
}
} }
} }
...@@ -57,7 +57,8 @@ v8_source_set("v8_cppgc_shared_unittests_sources") { ...@@ -57,7 +57,8 @@ v8_source_set("v8_cppgc_shared_unittests_sources") {
# Stand-alone target for C++ GC unittests. This is used to ensure that it # 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 # builds without V8 as well. They are also included in the regular unittests
# target for simplicity. # target for simplicity.
v8_executable("cppgc_unittests") { if (cppgc_is_standalone) {
v8_executable("cppgc_unittests") {
testonly = true testonly = true
configs = [ configs = [
...@@ -74,6 +75,7 @@ v8_executable("cppgc_unittests") { ...@@ -74,6 +75,7 @@ v8_executable("cppgc_unittests") {
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
] ]
}
} }
v8_source_set("cppgc_unittests_sources") { v8_source_set("cppgc_unittests_sources") {
...@@ -142,7 +144,6 @@ v8_executable("unittests") { ...@@ -142,7 +144,6 @@ v8_executable("unittests") {
#}], #}],
deps = [ deps = [
":cppgc_unittests_sources",
":unittests_sources", ":unittests_sources",
":v8_cppgc_shared_unittests_sources", ":v8_cppgc_shared_unittests_sources",
"../..:v8_for_testing", "../..:v8_for_testing",
...@@ -153,6 +154,10 @@ v8_executable("unittests") { ...@@ -153,6 +154,10 @@ v8_executable("unittests") {
"//testing/gtest", "//testing/gtest",
] ]
if (!cppgc_is_standalone) {
deps += [ ":cppgc_unittests_sources" ]
}
data_deps = [ "../../tools:v8_testrunner" ] data_deps = [ "../../tools:v8_testrunner" ]
data = [ data = [
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#if !CPPGC_BUILD_IN_V8
#include "src/heap/cppgc/stats-collector.h" #include "src/heap/cppgc/stats-collector.h"
#include "test/unittests/heap/cppgc/tests.h" #include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -300,3 +302,5 @@ TEST_F(CppgcTracingScopesTest, TestIndividualConcurrentScopes) { ...@@ -300,3 +302,5 @@ TEST_F(CppgcTracingScopesTest, TestIndividualConcurrentScopes) {
} // namespace internal } // namespace internal
} // namespace cppgc } // 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