From 024261313b1bb28b27872d78916e66a7a425e9e6 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 18 Aug 2026 15:16:36 +0200 Subject: [PATCH 1/3] build: add `--shared-perfetto` flag Signed-off-by: Antoine du Hamel --- .github/workflows/test-shared.yml | 2 ++ Makefile | 1 + configure.py | 33 +++++++++++++++++++++++++++++++ deps/perfetto/perfetto.gyp | 25 +++++++++++++++-------- node.gyp | 13 ++++++++---- shell.nix | 4 ++++ tools/nix/sharedLibDeps.nix | 4 ++++ tools/nix/v8.nix | 7 ++++--- tools/v8_gypfiles/v8.gyp | 26 +++++++++++++++--------- 9 files changed, 91 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 96e862c35916..f7483103016f 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -29,6 +29,7 @@ on: - deps/nghttp2/** - deps/ngtcp2/** - deps/openssl/*/** + - deps/perfetto/** - deps/simdjson/** - deps/sqlite/** - deps/uv/** @@ -84,6 +85,7 @@ on: - deps/nghttp2/** - deps/ngtcp2/** - deps/openssl/*/** + - deps/perfetto/** - deps/simdjson/** - deps/sqlite/** - deps/uv/** diff --git a/Makefile b/Makefile index f0d453cf6213..d1f8ba3e5330 100644 --- a/Makefile +++ b/Makefile @@ -1318,6 +1318,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1) $(RM) -r $(TARNAME)/deps/ngtcp2 find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} + find $(TARNAME)/deps/openssl -mindepth 1 -maxdepth 1 -type d -exec $(RM) -r {} + + $(RM) -r $(TARNAME)/deps/perfetto $(RM) -r $(TARNAME)/deps/simdjson $(RM) -r $(TARNAME)/deps/sqlite $(RM) -r $(TARNAME)/deps/uv diff --git a/configure.py b/configure.py index 99ce9326dc93..2d7e8f06cf48 100755 --- a/configure.py +++ b/configure.py @@ -546,6 +546,29 @@ dest='shared_openssl_libpath', help='a directory to search for the shared OpenSSL DLLs') +shared_optgroup.add_argument('--shared-perfetto', + action='store_true', + dest='shared_perfetto', + default=None, + help='link to a shared perfetto SDK instead of the one in deps/perfetto ' + '(requires --with-perfetto)') + +shared_optgroup.add_argument('--shared-perfetto-includes', + action='store', + dest='shared_perfetto_includes', + help='directory containing perfetto header files') + +shared_optgroup.add_argument('--shared-perfetto-libname', + action='store', + dest='shared_perfetto_libname', + default='perfetto', + help='alternative lib name to link to [default: %(default)s]') + +shared_optgroup.add_argument('--shared-perfetto-libpath', + action='store', + dest='shared_perfetto_libpath', + help='a directory to search for the shared perfetto DLL') + shared_optgroup.add_argument('--shared-uvwasi', action='store_true', dest='shared_uvwasi', @@ -2362,6 +2385,15 @@ def configure_lief(o): configure_library('lief', o, pkgname='LIEF') +def configure_perfetto(o): + if not options.with_perfetto: + if options.shared_perfetto: + error('--shared-perfetto requires --with-perfetto') + o['variables']['node_shared_perfetto'] = b(False) + return + + configure_library('perfetto', o) + def configure_sqlite(o): o['variables']['node_use_sqlite'] = b(not options.without_sqlite) if options.without_sqlite: @@ -2937,6 +2969,7 @@ def make_bin_override(): configure_library('nghttp3', output, pkgname='libnghttp3') configure_library('ngtcp2', output, pkgname='libngtcp2') configure_lief(output); +configure_perfetto(output); configure_sqlite(output); configure_ffi(output); configure_library('temporal_capi', output) diff --git a/deps/perfetto/perfetto.gyp b/deps/perfetto/perfetto.gyp index 083d0b386dd2..8dbccabd4b75 100644 --- a/deps/perfetto/perfetto.gyp +++ b/deps/perfetto/perfetto.gyp @@ -1,5 +1,6 @@ { 'variables': { + 'node_shared_perfetto%': 'false', 'perfetto_sdk_sources': [ 'sdk/perfetto.cc', 'sdk/perfetto.h', @@ -8,15 +9,23 @@ 'targets': [ { 'target_name': 'perfetto_sdk', - 'type': 'static_library', 'toolsets': ['host', 'target'], - 'include_dirs': [ 'sdk' ], - 'direct_dependent_settings': { - # Use like `#include "perfetto.h"` - 'include_dirs': [ 'sdk' ], - }, - 'sources': [ - '<@(perfetto_sdk_sources)', + 'conditions': [ + ['node_shared_perfetto=="true"', { + # The SDK comes from the system, `include_dirs` and `libraries` are + # provided by the configure script. + 'type': 'none', + }, { + 'type': 'static_library', + 'include_dirs': [ 'sdk' ], + 'direct_dependent_settings': { + # Use like `#include "perfetto.h"` + 'include_dirs': [ 'sdk' ], + }, + 'sources': [ + '<@(perfetto_sdk_sources)', + ], + }], ], }, ] diff --git a/node.gyp b/node.gyp index 7e1e4f212cad..52f421f3181c 100644 --- a/node.gyp +++ b/node.gyp @@ -28,6 +28,7 @@ 'node_shared_nbytes%': 'false', 'node_shared_nghttp2%': 'false', 'node_shared_openssl%': 'false', + 'node_shared_perfetto%': 'false', 'node_shared_sqlite%': 'false', 'node_shared_ffi%': 'false', 'node_shared_temporal_capi%': 'false', @@ -942,8 +943,12 @@ 'sources': [ '<@(node_tracing_perfetto_sources)', ], - 'dependencies': [ - 'deps/perfetto/perfetto.gyp:perfetto_sdk', + 'conditions': [ + ['node_shared_perfetto=="false"', { + 'dependencies': [ + 'deps/perfetto/perfetto.gyp:perfetto_sdk', + ], + }], ], }, { 'sources': [ @@ -1401,7 +1406,7 @@ }, { 'sources!': [ '<@(node_cctest_quic_sources)' ], }], - [ 'v8_use_perfetto==1', { + [ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', { 'dependencies': [ 'deps/perfetto/perfetto.gyp:perfetto_sdk', ], @@ -1731,7 +1736,7 @@ 'NODE_USE_NODE_CODE_CACHE=1', ], }], - [ 'v8_use_perfetto==1', { + [ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', { 'dependencies': [ 'deps/perfetto/perfetto.gyp:perfetto_sdk', ], diff --git a/shell.nix b/shell.nix index 0bc13ec5c2f1..b19d2ba67389 100644 --- a/shell.nix +++ b/shell.nix @@ -29,6 +29,7 @@ withSQLite withFFI withSSL + withPerfetto withTemporal ; } @@ -52,6 +53,7 @@ let useSharedAda = builtins.hasAttr "ada" sharedLibDeps; useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps; + useSharedPerfetto = builtins.hasAttr "perfetto" sharedLibDeps; useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps; needsRustCompiler = withTemporal && !useSharedTemporal; @@ -65,6 +67,7 @@ let pkgs.lib.optional useSharedICU icu ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil ++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) sharedLibDeps.highway + ++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto ++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi; # Put here only the configure flags that affect the V8 build @@ -79,6 +82,7 @@ let ] ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil" ++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) "--shared-highway" + ++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto" ++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi" ++ pkgs.lib.optional withPerfetto "--with-perfetto"; in diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index c28c56acc6b5..d57ceb4918bb 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -5,6 +5,7 @@ withSQLite ? true, withSSL ? true, withFFI ? true, + withPerfetto ? false, withTemporal ? false, }: { @@ -46,6 +47,9 @@ // (pkgs.lib.optionalAttrs withSSL ({ inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl; })) +// (pkgs.lib.optionalAttrs withPerfetto { + perfetto = pkgs.perfetto.sdk; +}) // (pkgs.lib.optionalAttrs withTemporal { inherit (pkgs) temporal_capi; }) diff --git a/tools/nix/v8.nix b/tools/nix/v8.nix index 98df8b769c2a..3c3c3ab47347 100644 --- a/tools/nix/v8.nix +++ b/tools/nix/v8.nix @@ -47,9 +47,10 @@ let ] ++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp ++ lib.optional (!useSharedHighway) ../../tools/v8_gypfiles/highway.gyp - ++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [ - ../../deps/perfetto - ] + ++ lib.optional ( + builtins.elem "--with-perfetto" configureFlags + && !(builtins.elem "--shared-perfetto" configureFlags) + ) ../../deps/perfetto ++ lib.optionals (icu != null) [ ../../tools/icu/icu_versions.json ../../tools/icu/icu-system.gyp diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index a976148ddab0..7e005ab9d1df 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -293,7 +293,7 @@ '<(V8_ROOT)/src/init/setup-isolate-full.cc', ], 'conditions': [ - ['v8_use_perfetto==1', { + ['v8_use_perfetto==1 and node_shared_perfetto=="false"', { 'dependencies': [ '<(perfetto_gyp_file):perfetto_sdk', ], @@ -321,7 +321,7 @@ ' Date: Fri, 4 Sep 2026 16:17:33 +0200 Subject: [PATCH 2/3] tools: add GHA workflow to test vendored Perfetto Signed-off-by: Antoine du Hamel --- .github/workflows/test-linux-perfetto.yml | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/test-linux-perfetto.yml diff --git a/.github/workflows/test-linux-perfetto.yml b/.github/workflows/test-linux-perfetto.yml new file mode 100644 index 000000000000..70a92202c1c7 --- /dev/null +++ b/.github/workflows/test-linux-perfetto.yml @@ -0,0 +1,70 @@ +name: Test Linux (with Perfetto) + +on: + workflow_dispatch: + pull_request: + # Only targeting paths specific to the vendored version of Perfetto, `test-shared` + # is taking care of rest of the coverage. + paths: + - .github/workflows/test-linux-perfetto.yml + - common.gypi + - configure.py + - deps/perfetto/** + - node.gyp + - node.gypi + - tools/v8_gypfiles/v8.gyp + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + PYTHON_VERSION: '3.14' + FLAKY_TESTS: keep_retrying + CLANG_VERSION: '19' + CC: ${{ (github.base_ref == 'main' || github.ref_name == 'main') && 'sccache' || '' }} clang-19 + CXX: ${{ (github.base_ref == 'main' || github.ref_name == 'main') && 'sccache' || '' }} clang++-19 + SCCACHE_GHA_ENABLED: ${{ github.base_ref == 'main' || github.ref_name == 'main' }} + SCCACHE_IDLE_TIMEOUT: '0' + RUSTC_VERSION: '1.86' + +permissions: + contents: read + +jobs: + test-perfetto: + if: github.event.pull_request.draft == false + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + path: node + - name: Install Clang ${{ env.CLANG_VERSION }} + uses: ./node/.github/actions/install-clang + with: + clang-version: ${{ env.CLANG_VERSION }} + - name: Install Rust ${{ env.RUSTC_VERSION }} + run: | + rustup override set "$RUSTC_VERSION" + rustup --version + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + allow-prereleases: true + - name: Set up sccache + if: github.base_ref == 'main' || github.ref_name == 'main' + uses: Mozilla-Actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 + with: + version: v0.17.0 + - name: Build + working-directory: node + run: make build-ci -j4 V=1 CONFIG_FLAGS="--error-on-warn --v8-enable-temporal-support --with-perfetto" + - name: Test + working-directory: node + run: make test-ci -j1 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9" + - name: Ensure running tests did not cause any change in the tree + working-directory: node + run: git add -A && git diff --name-only --exit-code --staged From 94a72bd4a274125277f9e1d199ec668d6ade8cbe Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 4 Sep 2026 19:15:59 +0200 Subject: [PATCH 3/3] fixup! tools: add GHA workflow to test vendored Perfetto --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2a7ce3337021..9277cdf090f0 100644 --- a/.gitignore +++ b/.gitignore @@ -121,6 +121,7 @@ tools/*/*.i.tmp /*.xml /v8*-tap.json /node_trace.*.log +/node_trace.*.pftrace # coverage related /gcovr /build