Skip to content

Commit df608e0

Browse files
legendecasaduh95
authored andcommitted
build: perfetto-sdk
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: #64565 Refs: nodejs/diagnostics#654 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ryuhei Shima <shimaryuhei@gmail.com>
1 parent 8eeae28 commit df608e0

5 files changed

Lines changed: 81 additions & 6 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
'v8_enable_external_code_space%': 0,
8888
'v8_enable_sandbox%': 0,
8989
'v8_enable_v8_checks%': 0,
90-
'v8_use_perfetto': 0,
90+
'v8_use_perfetto%': 0,
9191
'tsan%': 0,
9292

9393
##### end V8 defaults #####

configure.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,12 @@
11171117
default=None,
11181118
help='disable the V8 inspector protocol')
11191119

1120+
parser.add_argument('--with-perfetto',
1121+
action='store_true',
1122+
dest='with_perfetto',
1123+
default=None,
1124+
help='enable perfetto support')
1125+
11201126
parser.add_argument('--shared',
11211127
action='store_true',
11221128
dest='shared',
@@ -2217,6 +2223,7 @@ def configure_v8(o, configs):
22172223
options.v8_disable_temporal_support = True
22182224
o['variables']['v8_enable_temporal_support'] = 0 if options.v8_disable_temporal_support else 1
22192225
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0
2226+
o['variables']['v8_use_perfetto'] = 1 if options.with_perfetto else 0
22202227
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
22212228
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
22222229
o['variables']['force_dynamic_crt'] = 1 if options.shared else 0

node.gyp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,14 @@
14431443
}, {
14441444
'sources!': [ '<@(node_cctest_quic_sources)' ],
14451445
}],
1446+
[ 'v8_use_perfetto==1', {
1447+
'defines': [
1448+
'PERFETTO_ENABLE_LEGACY_TRACE_EVENTS=1'
1449+
],
1450+
'dependencies': [
1451+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
1452+
],
1453+
}],
14461454
['v8_enable_inspector==1', {
14471455
'defines': [
14481456
'HAVE_INSPECTOR=1',
@@ -1764,6 +1772,14 @@
17641772
'NODE_USE_NODE_CODE_CACHE=1',
17651773
],
17661774
}],
1775+
[ 'v8_use_perfetto==1', {
1776+
'defines': [
1777+
'PERFETTO_ENABLE_LEGACY_TRACE_EVENTS=1'
1778+
],
1779+
'dependencies': [
1780+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
1781+
],
1782+
}],
17671783
['v8_enable_inspector==1', {
17681784
'defines': [
17691785
'HAVE_INSPECTOR=1',

tools/v8_gypfiles/features.gypi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@
200200
# Enable seeded array index hash.
201201
'v8_enable_seeded_array_index_hash%': 1,
202202

203-
# Use Perfetto (https://perfetto.dev) as the default TracingController. Not
204-
# currently implemented.
203+
# Use Perfetto (https://perfetto.dev) as the default TracingController.
205204
'v8_use_perfetto%': 0,
206205

207206
# Enable map packing & unpacking (sets -dV8_MAP_PACKING).
@@ -463,7 +462,10 @@
463462
'defines': ['ENABLE_VERIFY_CSA',],
464463
}],
465464
['v8_use_perfetto==1', {
466-
'defines': ['V8_USE_PERFETTO',],
465+
'defines': [
466+
'V8_USE_PERFETTO',
467+
'V8_USE_PERFETTO_SDK',
468+
],
467469
}],
468470
['v8_enable_map_packing==1', {
469471
'defines': ['V8_MAP_PACKING',],

tools/v8_gypfiles/v8.gyp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
],
3939
}],
4040
],
41+
'perfetto_gyp_file': '../../deps/perfetto/perfetto.gyp',
4142
},
4243
'includes': ['toolchain.gypi', 'features.gypi'],
4344
'target_defaults': {
@@ -292,6 +293,13 @@
292293
'sources': [
293294
'<(V8_ROOT)/src/init/setup-isolate-full.cc',
294295
],
296+
'conditions': [
297+
['v8_use_perfetto==1', {
298+
'dependencies': [
299+
'<(perfetto_gyp_file):perfetto_sdk',
300+
],
301+
}],
302+
],
295303
}, # v8_init
296304
{
297305
'target_name': 'v8_initializers',
@@ -312,6 +320,11 @@
312320
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?sources = ")',
313321
],
314322
'conditions': [
323+
['v8_use_perfetto==1', {
324+
'dependencies': [
325+
'<(perfetto_gyp_file):perfetto_sdk',
326+
],
327+
}],
315328
['v8_enable_webassembly==1', {
316329
'sources': [
317330
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?v8_enable_webassembly.*?sources \\+= ")',
@@ -479,6 +492,11 @@
479492
},
480493
],
481494
'conditions': [
495+
['v8_use_perfetto==1', {
496+
'dependencies': [
497+
'<(perfetto_gyp_file):perfetto_sdk',
498+
],
499+
}],
482500
['want_separate_host_toolset', {
483501
'dependencies': [
484502
'generate_bytecode_builtins_list',
@@ -678,6 +696,14 @@
678696
}],
679697
],
680698
}],
699+
['v8_use_perfetto==1', {
700+
'sources!': [
701+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_use_perfetto.*?sources \\-= ")',
702+
],
703+
'sources': [
704+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_use_perfetto.*?sources \\+= ")',
705+
],
706+
}],
681707
['v8_enable_webassembly==1', {
682708
'sources': [
683709
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?v8_enable_webassembly.*?sources \\+= ")',
@@ -960,6 +986,11 @@
960986
'abseil.gyp:abseil',
961987
],
962988
'conditions': [
989+
['v8_use_perfetto==1', {
990+
'dependencies': [
991+
'<(perfetto_gyp_file):perfetto_sdk',
992+
],
993+
}],
963994
['v8_enable_maglev==0', {
964995
'sources': [
965996
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_header_set.\\"v8_internal_headers\\".*?!v8_enable_maglev.*?sources \\+= ")',
@@ -1090,6 +1121,14 @@
10901121
'<@(inspector_all_sources)',
10911122
],
10921123
'conditions': [
1124+
['v8_use_perfetto==1', {
1125+
'sources': [
1126+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_use_perfetto.*?sources \\+= ")',
1127+
],
1128+
'dependencies': [
1129+
'<(perfetto_gyp_file):perfetto_sdk',
1130+
],
1131+
}],
10931132
['v8_enable_snapshot_compression==1', {
10941133
'sources': [
10951134
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_snapshot_compression.*?sources \\+= ")',
@@ -1707,8 +1746,7 @@
17071746
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_libplatform.*?v8_use_perfetto.*?sources += ")',
17081747
],
17091748
'dependencies': [
1710-
'<(V8_ROOT)/third_party/perfetto:libperfetto',
1711-
'<(V8_ROOT)/third_party/perfetto/protos/perfetto/trace:lite',
1749+
'<(perfetto_gyp_file):perfetto_sdk',
17121750
],
17131751
}],
17141752
['v8_enable_system_instrumentation==1 and is_win', {
@@ -1818,6 +1856,11 @@
18181856
},
18191857
},
18201858
'conditions': [
1859+
['v8_use_perfetto==1', {
1860+
'dependencies': [
1861+
'<(perfetto_gyp_file):perfetto_sdk',
1862+
],
1863+
}],
18211864
['want_separate_host_toolset', {
18221865
'toolsets': ['host'],
18231866
}],
@@ -2028,6 +2071,13 @@
20282071
'sources': [
20292072
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_source_set.\\"cppgc_base.*?sources = ")',
20302073
],
2074+
'conditions': [
2075+
['v8_use_perfetto==1', {
2076+
'sources': [
2077+
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_source_set.\\"cppgc_base.*?if .v8_use_perfetto.*?sources \\+= ")',
2078+
],
2079+
}],
2080+
],
20312081
},
20322082
}, # cppgc_base
20332083
{

0 commit comments

Comments
 (0)