Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@
dest='shared_zlib_libpath',
help='a directory to search for the shared zlib DLL')

shared_optgroup.add_argument('--shared-v8-zlib',
action=argparse.BooleanOptionalAction,
dest='shared_v8_zlib',
default=None,
help='in addition to Node.js internals, link V8 to the shared zlib, '
'requires --shared-zlib, by default it follows --shared-zlib')

shared_optgroup.add_argument('--shared-simdjson',
action='store_true',
dest='shared_simdjson',
Expand Down Expand Up @@ -2301,6 +2308,13 @@ def configure_library(lib, output, pkgname=None, libraries_key='libraries', with
libraries += [f'-l{l}' for l in pkg] if isinstance(pkg, list) else f'-l${pkg}'


def configure_v8_zlib(o):
if options.shared_v8_zlib is None:
options.shared_v8_zlib = bool(options.shared_zlib)
elif options.shared_v8_zlib and not options.shared_zlib:
error('--shared-v8-zlib requires --shared-zlib')
o['variables']['node_shared_v8_zlib'] = b(options.shared_v8_zlib)

def configure_v8(o, configs):
set_configuration_variable(configs, 'v8_enable_v8_checks', release=0, debug=1)

Expand Down Expand Up @@ -2990,6 +3004,7 @@ def make_bin_override():
configure_node_cctest_sources(output)
configure_napi(output)
configure_library('zlib', output, with_separate_include_var=True)
configure_v8_zlib(output)
configure_library('http_parser', output, pkgname='libllhttp')
configure_library('libuv', output, with_separate_include_var=True)
configure_library('abseil', output, pkgname=[
Expand Down
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'node_shared_ffi%': 'false',
'node_shared_temporal_capi%': 'false',
'node_shared_uvwasi%': 'false',
'node_shared_v8_zlib%': 'false',
'node_shared_zlib%': 'false',
'node_shared_zstd%': 'false',
'node_shared%': 'false',
Expand Down
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ let
"perfetto"
"simdutf"
"temporal_capi"
"zlib"
]);

nativeBuildInputs =
Expand Down
1 change: 0 additions & 1 deletion tools/nix/non-v8-deps-mock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

let
sharedLibsToMock = {
zlib = [ "zlib" ];
http-parser = [ "libllhttp" ];
libuv = [ "libuv" ];
ada = [ "ada" ];
Expand Down
2 changes: 2 additions & 0 deletions tools/nix/v8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let
useSharedPerfetto = builtins.elem "--shared-perfetto" configureFlags;
useSharedSimdutf = builtins.elem "--shared-simdutf" configureFlags;
useSharedTemporal = builtins.elem "--shared-temporal_capi" configureFlags;
useSharedZlib = builtins.elem "--shared-zlib" configureFlags;

src =
let
Expand All @@ -50,6 +51,7 @@ let
++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp
++ lib.optional (!useSharedHighway) ../../tools/v8_gypfiles/highway.gyp
++ lib.optional (!useSharedSimdutf) ../../tools/v8_gypfiles/simdutf.gyp
++ lib.optional useSharedZlib ../../tools/v8_gypfiles/shared_zlib
++ lib.optional (
if useSharedTemporal then
icu == null
Expand Down
4 changes: 4 additions & 0 deletions tools/v8_gypfiles/shared_zlib/third_party/zlib/zlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// In V8 zlib is included as "third_party/zlib/zlib.h", which
// resolves under <(V8_ROOT). When zlib is shared, use the shim
// to forward to external zlib headers like the rest of Node.js.
#include <zlib.h>
123 changes: 70 additions & 53 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
}
},
'conditions': [
# In V8 zlib is included as "third_party/zlib/zlib.h", which
# resolves under <(V8_ROOT). When zlib is shared, the shim directory
# that forwards to the external header should come first.
['node_shared_v8_zlib=="true"', {
'include_dirs+': ['shared_zlib'],
}],
# Build with -fvisibility=hidden and -fvisibility-inlines-hidden to avoid
# including unnecessary internal symbols, which may lead to run-time fixups.
# This is not done on AIX where symbols are exported by tools/create_expfile.sh
Expand Down Expand Up @@ -2451,63 +2457,74 @@
'target_name': 'v8_zlib',
'type': 'static_library',
'toolsets': ['host', 'target'],
'conditions': [
['OS=="win"', {
'conditions': [
['"<(target_arch)"=="arm64" and _toolset=="target"', {
'defines': ['CPU_NO_SIMD']
}, {
'defines': ['X86_WINDOWS']
}]
]
}],
],
'direct_dependent_settings': {
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
],
},
'defines': [ 'ZLIB_IMPLEMENTATION' ],
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
],
'sources': [
'<(V8_ROOT)/third_party/zlib/adler32.c',
'<(V8_ROOT)/third_party/zlib/chromeconf.h',
'<(V8_ROOT)/third_party/zlib/compress.c',
'<(V8_ROOT)/third_party/zlib/contrib/optimizations/insert_string.h',
'<(V8_ROOT)/third_party/zlib/contrib/optimizations/insert_string.h',
'<(V8_ROOT)/third_party/zlib/cpu_features.c',
'<(V8_ROOT)/third_party/zlib/cpu_features.h',
'<(V8_ROOT)/third_party/zlib/crc32.c',
'<(V8_ROOT)/third_party/zlib/crc32.h',
'<(V8_ROOT)/third_party/zlib/deflate.c',
'<(V8_ROOT)/third_party/zlib/deflate.h',
'<(V8_ROOT)/third_party/zlib/gzclose.c',
'<(V8_ROOT)/third_party/zlib/gzguts.h',
'<(V8_ROOT)/third_party/zlib/gzlib.c',
'<(V8_ROOT)/third_party/zlib/gzread.c',
'<(V8_ROOT)/third_party/zlib/gzwrite.c',
'<(V8_ROOT)/third_party/zlib/infback.c',
'<(V8_ROOT)/third_party/zlib/inffast.c',
'<(V8_ROOT)/third_party/zlib/inffast.h',
'<(V8_ROOT)/third_party/zlib/inffixed.h',
'<(V8_ROOT)/third_party/zlib/inflate.c',
'<(V8_ROOT)/third_party/zlib/inflate.h',
'<(V8_ROOT)/third_party/zlib/inftrees.c',
'<(V8_ROOT)/third_party/zlib/inftrees.h',
'<(V8_ROOT)/third_party/zlib/trees.c',
'<(V8_ROOT)/third_party/zlib/trees.h',
'<(V8_ROOT)/third_party/zlib/uncompr.c',
'<(V8_ROOT)/third_party/zlib/zconf.h',
'<(V8_ROOT)/third_party/zlib/zlib.h',
'<(V8_ROOT)/third_party/zlib/zutil.c',
'<(V8_ROOT)/third_party/zlib/zutil.h',
'<(V8_ROOT)/third_party/zlib/google/compression_utils_portable.cc',
'<(V8_ROOT)/third_party/zlib/google/compression_utils_portable.h',
],
'conditions': [
['node_shared_v8_zlib=="false"', {
'conditions': [
['OS=="win"', {
'conditions': [
['"<(target_arch)"=="arm64" and _toolset=="target"', {
'defines': ['CPU_NO_SIMD']
}, {
'defines': ['X86_WINDOWS']
}]
]
}],
],
'direct_dependent_settings': {
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
],
},
'defines': [ 'ZLIB_IMPLEMENTATION' ],
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
],
'sources': [
'<(V8_ROOT)/third_party/zlib/adler32.c',
'<(V8_ROOT)/third_party/zlib/chromeconf.h',
'<(V8_ROOT)/third_party/zlib/compress.c',
'<(V8_ROOT)/third_party/zlib/contrib/optimizations/insert_string.h',
'<(V8_ROOT)/third_party/zlib/contrib/optimizations/insert_string.h',
'<(V8_ROOT)/third_party/zlib/cpu_features.c',
'<(V8_ROOT)/third_party/zlib/cpu_features.h',
'<(V8_ROOT)/third_party/zlib/crc32.c',
'<(V8_ROOT)/third_party/zlib/crc32.h',
'<(V8_ROOT)/third_party/zlib/deflate.c',
'<(V8_ROOT)/third_party/zlib/deflate.h',
'<(V8_ROOT)/third_party/zlib/gzclose.c',
'<(V8_ROOT)/third_party/zlib/gzguts.h',
'<(V8_ROOT)/third_party/zlib/gzlib.c',
'<(V8_ROOT)/third_party/zlib/gzread.c',
'<(V8_ROOT)/third_party/zlib/gzwrite.c',
'<(V8_ROOT)/third_party/zlib/infback.c',
'<(V8_ROOT)/third_party/zlib/inffast.c',
'<(V8_ROOT)/third_party/zlib/inffast.h',
'<(V8_ROOT)/third_party/zlib/inffixed.h',
'<(V8_ROOT)/third_party/zlib/inflate.c',
'<(V8_ROOT)/third_party/zlib/inflate.h',
'<(V8_ROOT)/third_party/zlib/inftrees.c',
'<(V8_ROOT)/third_party/zlib/inftrees.h',
'<(V8_ROOT)/third_party/zlib/trees.c',
'<(V8_ROOT)/third_party/zlib/trees.h',
'<(V8_ROOT)/third_party/zlib/uncompr.c',
'<(V8_ROOT)/third_party/zlib/zconf.h',
'<(V8_ROOT)/third_party/zlib/zlib.h',
'<(V8_ROOT)/third_party/zlib/zutil.c',
'<(V8_ROOT)/third_party/zlib/zutil.h',
],
}, {
# Only build the Chromium glue for zlib, so when zlib is shared,
# the include shim added in target_defaults forwards
# V8's "third_party/zlib/zlib.h" includes to the external headers.
'defines': [ 'USE_SYSTEM_ZLIB' ],
}],
],
}, # v8_zlib
{
'target_name': 'fp16',
Expand Down
Loading