Skip to content

Commit d1938db

Browse files
committed
build: add --shared-abseil configure flag
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #65682 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 43d0442 commit d1938db

10 files changed

Lines changed: 168 additions & 29 deletions

File tree

.github/workflows/test-shared.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ on:
3333
- deps/sqlite/**
3434
- deps/uv/**
3535
- deps/uvwasi/**
36+
- deps/v8/third_party/abseil-cpp/**
3637
- deps/zlib/**
3738
- deps/zstd/**
3839
- doc/**
@@ -86,6 +87,7 @@ on:
8687
- deps/sqlite/**
8788
- deps/uv/**
8889
- deps/uvwasi/**
90+
- deps/v8/third_party/abseil-cpp/**
8991
- deps/zlib/**
9092
- deps/zstd/**
9193
- doc/**

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1)
13221322
$(RM) -r $(TARNAME)/deps/sqlite
13231323
$(RM) -r $(TARNAME)/deps/uv
13241324
$(RM) -r $(TARNAME)/deps/uvwasi
1325+
$(RM) -r $(TARNAME)/deps/v8/third_party/abseil-cpp
13251326
$(RM) -r $(TARNAME)/deps/zlib
13261327
$(RM) -r $(TARNAME)/deps/zstd
13271328
else

configure.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,28 @@
282282
help='Use the specified path to system CA (PEM format) in addition to '
283283
'the OpenSSL supplied CA store or compiled-in Mozilla CA copy.')
284284

285+
shared_optgroup.add_argument('--shared-abseil',
286+
action='store_true',
287+
dest='shared_abseil',
288+
default=None,
289+
help='link to a shared Abseil DLL instead of static linking')
290+
291+
shared_optgroup.add_argument('--shared-abseil-includes',
292+
action='store',
293+
dest='shared_abseil_includes',
294+
help='directory containing Abseil header files')
295+
296+
shared_optgroup.add_argument('--shared-abseil-libname',
297+
action='store',
298+
dest='shared_abseil_libname',
299+
default=None,
300+
help='alternative lib name to link to [default: %(default)s]')
301+
302+
shared_optgroup.add_argument('--shared-abseil-libpath',
303+
action='store',
304+
dest='shared_abseil_libpath',
305+
help='a directory to search for the shared Abseil DLL')
306+
285307
shared_optgroup.add_argument('--shared-gtest',
286308
action='store_true',
287309
dest='shared_gtest',
@@ -2814,6 +2836,71 @@ def make_bin_override():
28142836
configure_library('zlib', output)
28152837
configure_library('http_parser', output, pkgname='libllhttp')
28162838
configure_library('libuv', output)
2839+
configure_library('abseil', output, pkgname=[
2840+
'absl_absl_check',
2841+
'absl_absl_log',
2842+
'absl_absl_vlog_is_on',
2843+
'absl_algorithm_container',
2844+
'absl_algorithm',
2845+
'absl_any_invocable',
2846+
'absl_base',
2847+
'absl_bind_front',
2848+
'absl_bits',
2849+
'absl_btree',
2850+
'absl_charset',
2851+
'absl_cleanup',
2852+
'absl_config',
2853+
'absl_cord',
2854+
'absl_core_headers',
2855+
'absl_die_if_null',
2856+
'absl_dynamic_annotations',
2857+
'absl_failure_signal_handler',
2858+
'absl_fast_type_id',
2859+
'absl_fixed_array',
2860+
'absl_flat_hash_map',
2861+
'absl_flat_hash_set',
2862+
'absl_function_ref',
2863+
'absl_has_ostream_operator',
2864+
'absl_hash_container_defaults',
2865+
'absl_hash',
2866+
'absl_inlined_vector',
2867+
'absl_int128',
2868+
'absl_layout',
2869+
'absl_leak_check',
2870+
'absl_linked_hash_map',
2871+
'absl_linked_hash_set',
2872+
'absl_log_entry',
2873+
'absl_log_globals',
2874+
'absl_log_initialize',
2875+
'absl_log_severity',
2876+
'absl_log_sink_registry',
2877+
'absl_log_sink',
2878+
'absl_memory',
2879+
'absl_no_destructor',
2880+
'absl_node_hash_map',
2881+
'absl_node_hash_set',
2882+
'absl_nullability',
2883+
'absl_optional',
2884+
'absl_overload',
2885+
'absl_prefetch',
2886+
'absl_random_bit_gen_ref',
2887+
'absl_random_distributions',
2888+
'absl_random_random',
2889+
'absl_raw_logging_internal',
2890+
'absl_span',
2891+
'absl_stacktrace',
2892+
'absl_status',
2893+
'absl_statusor',
2894+
'absl_str_format',
2895+
'absl_string_view',
2896+
'absl_strings',
2897+
'absl_symbolize',
2898+
'absl_synchronization',
2899+
'absl_time',
2900+
'absl_type_traits',
2901+
'absl_utility',
2902+
'absl_variant',
2903+
])
28172904
configure_library('ada', output)
28182905
configure_library('simdjson', output)
28192906
configure_library('simdutf', output)

node.gyp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'node_lib_target_name%': 'libnode',
1616
'node_module_version%': '',
1717
'node_no_browser_globals%': 'false',
18+
'node_shared_abseil%': 'false',
1819
'node_shared_brotli%': 'false',
1920
'node_shared_cares%': 'false',
2021
'node_shared_gtest%': 'false',
@@ -901,7 +902,7 @@
901902
[ 'node_builtin_modules_path!=""', {
902903
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ],
903904
}],
904-
[ 'node_use_bundled_v8!="false"', {
905+
[ 'node_use_bundled_v8!="false" and node_shared_abseil=="false"', {
905906
'dependencies': [ 'tools/v8_gypfiles/abseil.gyp:abseil' ],
906907
}],
907908
[ 'node_shared_gtest=="false"', {
@@ -1369,7 +1370,7 @@
13691370
[ 'node_shared_gtest=="true"', {
13701371
'libraries': [ '-lgtest_main' ],
13711372
}],
1372-
[ 'node_use_bundled_v8!="false"', {
1373+
[ 'node_use_bundled_v8!="false" and node_shared_abseil=="false"', {
13731374
'dependencies': [ 'tools/v8_gypfiles/abseil.gyp:abseil' ],
13741375
}],
13751376
[ 'node_shared_hdr_histogram=="false"', {

shell.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ let
6363
];
6464
buildInputs =
6565
pkgs.lib.optional useSharedICU icu
66+
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil
6667
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
6768

6869
# Put here only the configure flags that affect the V8 build
@@ -75,6 +76,7 @@ let
7576
)
7677
"--v8-${if withTemporal then "enable" else "disable"}-temporal-support"
7778
]
79+
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil"
7880
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
7981
++ pkgs.lib.optional withPerfetto "--with-perfetto";
8082
in
@@ -132,6 +134,7 @@ pkgs.mkShell {
132134
builtins.attrNames (
133135
if (useSeparateDerivationForV8 != false) then
134136
builtins.removeAttrs sharedLibDeps [
137+
"abseil"
135138
"simdutf"
136139
"temporal_capi"
137140
]

tools/nix/sharedLibDeps.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
zlib
2222
zstd
2323
;
24+
abseil = pkgs.abseil-cpp;
2425
cares = pkgs.c-ares;
2526
hdr-histogram = pkgs.hdrhistogram_c;
2627
http-parser = pkgs.llhttp;

tools/nix/v8.nix

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
}:
2424

2525
let
26+
useSharedAbseil = builtins.elem "--shared-abseil" configureFlags;
2627
src =
2728
let
2829
inherit (lib) fileset;
@@ -35,7 +36,6 @@ let
3536
../../node.gypi
3637
../../tools/gyp/pylib
3738
../../tools/gyp_node.py
38-
../../tools/v8_gypfiles/abseil.gyp
3939
../../tools/v8_gypfiles/features.gypi
4040
../../tools/v8_gypfiles/ForEachFormat.py
4141
../../tools/v8_gypfiles/ForEachReplace.py
@@ -44,6 +44,7 @@ let
4444
../../tools/v8_gypfiles/toolchain.gypi
4545
../../tools/v8_gypfiles/v8.gyp
4646
]
47+
++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp
4748
++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [
4849
../../deps/perfetto
4950
]
@@ -63,12 +64,15 @@ let
6364
potentiallyAlreadyRemovedFiles =
6465
# Files that are removed in the release tarball (see Makefile $(TARBALL) target)
6566
[ (fileset.difference ../../deps/v8/test ../../deps/v8/test/torque) ]
66-
++ (builtins.filter builtins.pathExists [
67-
../../deps/v8/samples
68-
../../deps/v8/tools/profviz
69-
../../deps/v8/tools/run-tests.py
70-
../../deps/v8/third_party/ittapi
71-
]);
67+
++ (builtins.filter builtins.pathExists (
68+
[
69+
../../deps/v8/samples
70+
../../deps/v8/tools/profviz
71+
../../deps/v8/tools/run-tests.py
72+
../../deps/v8/third_party/ittapi
73+
]
74+
++ lib.optional useSharedAbseil ../../deps/v8/third_party/abseil-cpp
75+
));
7276
trackedFiles =
7377
({
7478
# This line is being modified by Makefile $(TARBALL) target, any change to it should be sync
@@ -197,9 +201,11 @@ stdenv.mkDerivation (finalAttrs: {
197201
find deps/v8/include -name '*.h' -print0 | while read -r -d "" file; do
198202
install -Dm644 "$file" -T "$out/include/''${file#deps/v8/include/}"
199203
done
200-
find deps/v8/third_party/abseil-cpp/absl -name '*.h' -print0 | while read -r -d "" file; do
201-
install -Dm644 "$file" -T "$out/include/''${file#deps/v8/third_party/abseil-cpp/}"
202-
done
204+
${lib.optionalString (!useSharedAbseil) ''
205+
find deps/v8/third_party/abseil-cpp/absl -name '*.h' -print0 | while read -r -d "" file; do
206+
install -Dm644 "$file" -T "$out/include/''${file#deps/v8/third_party/abseil-cpp/}"
207+
done
208+
''}
203209
204210
mkdir -p $out/lib/pkgconfig
205211
cat -> $out/lib/pkgconfig/v8.pc << EOF

tools/v8_gypfiles/d8.gyp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'target_name': 'd8',
1717
'type': 'executable',
1818
'dependencies': [
19-
'abseil.gyp:abseil',
2019
'v8.gyp:v8',
2120
'v8.gyp:v8_libbase',
2221
'v8.gyp:v8_libplatform',
@@ -77,6 +76,9 @@
7776
},
7877
},
7978
}],
79+
['node_shared_abseil=="false"', {
80+
'dependencies': ['abseil.gyp:abseil'],
81+
}],
8082
],
8183
},
8284
],

0 commit comments

Comments
 (0)