diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 8a04fe4d74fc..e075456d0fe1 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/** @@ -82,6 +83,7 @@ on: - deps/nghttp2/** - deps/ngtcp2/** - deps/openssl/*/** + - deps/perfetto/** - deps/simdjson/** - deps/sqlite/** - deps/uv/** diff --git a/Makefile b/Makefile index ed049893a243..3727c7e6d5aa 100644 --- a/Makefile +++ b/Makefile @@ -1312,6 +1312,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 b11c4e3284d0..de7fe7c2aaa9 100755 --- a/configure.py +++ b/configure.py @@ -502,6 +502,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', @@ -2318,6 +2341,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: @@ -2827,6 +2859,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 b99755575020..da00bf9f3aa7 100644 --- a/node.gyp +++ b/node.gyp @@ -26,6 +26,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', @@ -936,8 +937,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': [ @@ -1395,7 +1400,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', ], @@ -1725,7 +1730,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 96fcccbc1914..33a9448a7403 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; @@ -63,6 +65,7 @@ let ]; buildInputs = pkgs.lib.optional useSharedICU icu + ++ 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 @@ -75,6 +78,7 @@ let ) "--v8-${if withTemporal then "enable" else "disable"}-temporal-support" ] + ++ 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/test/parallel/test-trace-events-category-used.js b/test/parallel/test-trace-events-category-used.js index 3d584b1f2a85..bc6ec76b3826 100644 --- a/test/parallel/test-trace-events-category-used.js +++ b/test/parallel/test-trace-events-category-used.js @@ -29,7 +29,7 @@ let procEnabledOutput = ''; procEnabled.stdout.on('data', (data) => procEnabledOutput += data); procEnabled.stderr.pipe(process.stderr); procEnabled.once('close', common.mustCall(() => { - assert.strictEqual(procEnabledOutput, 'true\n'); + assert.strictEqual(procEnabledOutput, `${!process.config.variables.v8_use_perfetto}\n`); })); const procDisabled = cp.spawn( diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index 788e9efedeb8..37105ca3417a 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, }: { @@ -50,6 +51,13 @@ // (pkgs.lib.optionalAttrs withSSL ({ inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl; })) +// (pkgs.lib.optionalAttrs withPerfetto { + perfetto = + (pkgs.callPackage (builtins.fetchurl { + url = "https://github.com/NixOS/nixpkgs/raw/34ee2404466d25c6255a3ea1f710c80a9420d284/pkgs/by-name/pe/perfetto/package.nix"; + sha256 = "0wc4p96kwxpqr8g2a6lmlfjsffrm3dc824m7hiy0q21r2papc0ik"; + }) { }).sdk; +}) // (pkgs.lib.optionalAttrs withTemporal { inherit (pkgs) temporal_capi; }) diff --git a/tools/nix/v8.nix b/tools/nix/v8.nix index 90dadd336c8d..4793b3cebaa7 100644 --- a/tools/nix/v8.nix +++ b/tools/nix/v8.nix @@ -44,9 +44,10 @@ let ../../tools/v8_gypfiles/toolchain.gypi ../../tools/v8_gypfiles/v8.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 32fc99e2af9f..b229e18bb7ae 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -294,7 +294,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', ], @@ -320,7 +320,7 @@ '