Skip to content

Commit 6d17372

Browse files
legendecasnodejs-github-bot
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 c558c8e commit 6d17372

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
@@ -1123,6 +1123,12 @@
11231123
default=None,
11241124
help='disable the V8 inspector protocol')
11251125

1126+
parser.add_argument('--with-perfetto',
1127+
action='store_true',
1128+
dest='with_perfetto',
1129+
default=None,
1130+
help='enable perfetto support')
1131+
11261132
parser.add_argument('--shared',
11271133
action='store_true',
11281134
dest='shared',
@@ -2223,6 +2229,7 @@ def configure_v8(o, configs):
22232229
options.v8_disable_temporal_support = True
22242230
o['variables']['v8_enable_temporal_support'] = 0 if options.v8_disable_temporal_support else 1
22252231
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0
2232+
o['variables']['v8_use_perfetto'] = 1 if options.with_perfetto else 0
22262233
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
22272234
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
22282235
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
@@ -1462,6 +1462,14 @@
14621462
}, {
14631463
'sources!': [ '<@(node_cctest_quic_sources)' ],
14641464
}],
1465+
[ 'v8_use_perfetto==1', {
1466+
'defines': [
1467+
'PERFETTO_ENABLE_LEGACY_TRACE_EVENTS=1'
1468+
],
1469+
'dependencies': [
1470+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
1471+
],
1472+
}],
14651473
['v8_enable_inspector==1', {
14661474
'defines': [
14671475
'HAVE_INSPECTOR=1',
@@ -1783,6 +1791,14 @@
17831791
'NODE_USE_NODE_CODE_CACHE=1',
17841792
],
17851793
}],
1794+
[ 'v8_use_perfetto==1', {
1795+
'defines': [
1796+
'PERFETTO_ENABLE_LEGACY_TRACE_EVENTS=1'
1797+
],
1798+
'dependencies': [
1799+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
1800+
],
1801+
}],
17861802
['v8_enable_inspector==1', {
17871803
'defines': [
17881804
'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)