diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 8a04fe4d74fc..5269bd8a546f 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -29,10 +29,12 @@ on: - deps/nghttp2/** - deps/ngtcp2/** - deps/openssl/*/** + - deps/perfetto/** - deps/simdjson/** - deps/sqlite/** - deps/uv/** - deps/uvwasi/** + - deps/v8/third_party/abseil-cpp/** - deps/zlib/** - deps/zstd/** - doc/** @@ -82,10 +84,12 @@ on: - deps/nghttp2/** - deps/ngtcp2/** - deps/openssl/*/** + - deps/perfetto/** - deps/simdjson/** - deps/sqlite/** - deps/uv/** - deps/uvwasi/** + - deps/v8/third_party/abseil-cpp/** - deps/zlib/** - deps/zstd/** - doc/** diff --git a/Makefile b/Makefile index ed049893a243..b9c79d198774 100644 --- a/Makefile +++ b/Makefile @@ -1312,10 +1312,12 @@ 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 $(RM) -r $(TARNAME)/deps/uvwasi + $(RM) -r $(TARNAME)/deps/v8/third_party/abseil-cpp $(RM) -r $(TARNAME)/deps/zlib $(RM) -r $(TARNAME)/deps/zstd else diff --git a/configure.py b/configure.py index b11c4e3284d0..fd6dcdacd616 100755 --- a/configure.py +++ b/configure.py @@ -282,6 +282,28 @@ help='Use the specified path to system CA (PEM format) in addition to ' 'the OpenSSL supplied CA store or compiled-in Mozilla CA copy.') +shared_optgroup.add_argument('--shared-abseil', + action='store_true', + dest='shared_abseil', + default=None, + help='link to a shared Abseil DLL instead of static linking') + +shared_optgroup.add_argument('--shared-abseil-includes', + action='store', + dest='shared_abseil_includes', + help='directory containing Abseil header files') + +shared_optgroup.add_argument('--shared-abseil-libname', + action='store', + dest='shared_abseil_libname', + default=None, + help='alternative lib name to link to [default: %(default)s]') + +shared_optgroup.add_argument('--shared-abseil-libpath', + action='store', + dest='shared_abseil_libpath', + help='a directory to search for the shared Abseil DLL') + shared_optgroup.add_argument('--shared-gtest', action='store_true', dest='shared_gtest', @@ -502,6 +524,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 +2363,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: @@ -2814,6 +2868,71 @@ def make_bin_override(): configure_library('zlib', output) configure_library('http_parser', output, pkgname='libllhttp') configure_library('libuv', output) +configure_library('abseil', output, pkgname=[ + 'absl_absl_check', + 'absl_absl_log', + 'absl_absl_vlog_is_on', + 'absl_algorithm_container', + 'absl_algorithm', + 'absl_any_invocable', + 'absl_base', + 'absl_bind_front', + 'absl_bits', + 'absl_btree', + 'absl_charset', + 'absl_cleanup', + 'absl_config', + 'absl_cord', + 'absl_core_headers', + 'absl_die_if_null', + 'absl_dynamic_annotations', + 'absl_failure_signal_handler', + 'absl_fast_type_id', + 'absl_fixed_array', + 'absl_flat_hash_map', + 'absl_flat_hash_set', + 'absl_function_ref', + 'absl_has_ostream_operator', + 'absl_hash_container_defaults', + 'absl_hash', + 'absl_inlined_vector', + 'absl_int128', + 'absl_layout', + 'absl_leak_check', + 'absl_linked_hash_map', + 'absl_linked_hash_set', + 'absl_log_entry', + 'absl_log_globals', + 'absl_log_initialize', + 'absl_log_severity', + 'absl_log_sink_registry', + 'absl_log_sink', + 'absl_memory', + 'absl_no_destructor', + 'absl_node_hash_map', + 'absl_node_hash_set', + 'absl_nullability', + 'absl_optional', + 'absl_overload', + 'absl_prefetch', + 'absl_random_bit_gen_ref', + 'absl_random_distributions', + 'absl_random_random', + 'absl_raw_logging_internal', + 'absl_span', + 'absl_stacktrace', + 'absl_status', + 'absl_statusor', + 'absl_str_format', + 'absl_string_view', + 'absl_strings', + 'absl_symbolize', + 'absl_synchronization', + 'absl_time', + 'absl_type_traits', + 'absl_utility', + 'absl_variant', +]) configure_library('ada', output) configure_library('simdjson', output) configure_library('simdutf', output) @@ -2827,6 +2946,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 8cf405215249..7b2208cf8c05 100644 --- a/node.gyp +++ b/node.gyp @@ -15,6 +15,7 @@ 'node_lib_target_name%': 'libnode', 'node_module_version%': '', 'node_no_browser_globals%': 'false', + 'node_shared_abseil%': 'false', 'node_shared_brotli%': 'false', 'node_shared_cares%': 'false', 'node_shared_gtest%': 'false', @@ -26,6 +27,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', @@ -899,7 +901,7 @@ [ 'node_builtin_modules_path!=""', { 'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ], }], - [ 'node_use_bundled_v8!="false"', { + [ 'node_use_bundled_v8!="false" and node_shared_abseil=="false"', { 'dependencies': [ 'tools/v8_gypfiles/abseil.gyp:abseil' ], }], [ 'node_shared_gtest=="false"', { @@ -938,8 +940,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': [ @@ -1367,7 +1373,7 @@ [ 'node_shared_gtest=="true"', { 'libraries': [ '-lgtest_main' ], }], - [ 'node_use_bundled_v8!="false"', { + [ 'node_use_bundled_v8!="false" and node_shared_abseil=="false"', { 'dependencies': [ 'tools/v8_gypfiles/abseil.gyp:abseil' ], }], [ 'node_shared_hdr_histogram=="false"', { @@ -1397,7 +1403,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', ], @@ -1727,7 +1733,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..33ed3e800d04 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,8 @@ let ]; buildInputs = pkgs.lib.optional useSharedICU icu + ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil + ++ 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 +79,8 @@ let ) "--v8-${if withTemporal then "enable" else "disable"}-temporal-support" ] + ++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil" + ++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto" ++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi" ++ pkgs.lib.optional withPerfetto "--with-perfetto"; in @@ -132,6 +138,7 @@ pkgs.mkShell { builtins.attrNames ( if (useSeparateDerivationForV8 != false) then builtins.removeAttrs sharedLibDeps [ + "abseil" "simdutf" "temporal_capi" ] diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index 788e9efedeb8..59dec2cd7d19 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, }: { @@ -21,6 +22,7 @@ zlib zstd ; + abseil = pkgs.abseil-cpp; cares = pkgs.c-ares; hdr-histogram = pkgs.hdrhistogram_c; http-parser = pkgs.llhttp; @@ -50,6 +52,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 90dadd336c8d..4099d06fa55a 100644 --- a/tools/nix/v8.nix +++ b/tools/nix/v8.nix @@ -23,6 +23,7 @@ }: let + useSharedAbseil = builtins.elem "--shared-abseil" configureFlags; src = let inherit (lib) fileset; @@ -35,7 +36,6 @@ let ../../node.gypi ../../tools/gyp/pylib ../../tools/gyp_node.py - ../../tools/v8_gypfiles/abseil.gyp ../../tools/v8_gypfiles/features.gypi ../../tools/v8_gypfiles/ForEachFormat.py ../../tools/v8_gypfiles/ForEachReplace.py @@ -44,9 +44,11 @@ let ../../tools/v8_gypfiles/toolchain.gypi ../../tools/v8_gypfiles/v8.gyp ] - ++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [ - ../../deps/perfetto - ] + ++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp + ++ 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 @@ -63,12 +65,15 @@ let potentiallyAlreadyRemovedFiles = # Files that are removed in the release tarball (see Makefile $(TARBALL) target) [ (fileset.difference ../../deps/v8/test ../../deps/v8/test/torque) ] - ++ (builtins.filter builtins.pathExists [ - ../../deps/v8/samples - ../../deps/v8/tools/profviz - ../../deps/v8/tools/run-tests.py - ../../deps/v8/third_party/ittapi - ]); + ++ (builtins.filter builtins.pathExists ( + [ + ../../deps/v8/samples + ../../deps/v8/tools/profviz + ../../deps/v8/tools/run-tests.py + ../../deps/v8/third_party/ittapi + ] + ++ lib.optional useSharedAbseil ../../deps/v8/third_party/abseil-cpp + )); trackedFiles = ({ # This line is being modified by Makefile $(TARBALL) target, any change to it should be sync @@ -197,9 +202,11 @@ stdenv.mkDerivation (finalAttrs: { find deps/v8/include -name '*.h' -print0 | while read -r -d "" file; do install -Dm644 "$file" -T "$out/include/''${file#deps/v8/include/}" done - find deps/v8/third_party/abseil-cpp/absl -name '*.h' -print0 | while read -r -d "" file; do - install -Dm644 "$file" -T "$out/include/''${file#deps/v8/third_party/abseil-cpp/}" - done + ${lib.optionalString (!useSharedAbseil) '' + find deps/v8/third_party/abseil-cpp/absl -name '*.h' -print0 | while read -r -d "" file; do + install -Dm644 "$file" -T "$out/include/''${file#deps/v8/third_party/abseil-cpp/}" + done + ''} mkdir -p $out/lib/pkgconfig cat -> $out/lib/pkgconfig/v8.pc << EOF diff --git a/tools/v8_gypfiles/d8.gyp b/tools/v8_gypfiles/d8.gyp index 5b47ebf180dd..f59a155b169c 100644 --- a/tools/v8_gypfiles/d8.gyp +++ b/tools/v8_gypfiles/d8.gyp @@ -16,7 +16,6 @@ 'target_name': 'd8', 'type': 'executable', 'dependencies': [ - 'abseil.gyp:abseil', 'v8.gyp:v8', 'v8.gyp:v8_libbase', 'v8.gyp:v8_libplatform', @@ -77,6 +76,9 @@ }, }, }], + ['node_shared_abseil=="false"', { + 'dependencies': ['abseil.gyp:abseil'], + }], ], }, ], diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 32fc99e2af9f..6c225c93e706 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -288,17 +288,19 @@ 'v8_base_without_compiler', 'v8_initializers', 'v8_maybe_icu', - 'abseil.gyp:abseil', ], 'sources': [ '<(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', ], }], + ['node_shared_abseil=="false"', { + 'dependencies': ['abseil.gyp:abseil'], + }], ], }, # v8_init { @@ -310,7 +312,6 @@ 'v8_base_without_compiler', 'v8_shared_internal_headers', 'v8_pch', - 'abseil.gyp:abseil', ], 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)', @@ -320,7 +321,7 @@ '