Skip to content

Commit 796a83a

Browse files
committed
build: do not pass vendored headers when building against shared libs
And setup `test-shared.yml` so we can detect regressions. Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #66844 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent d15ccb7 commit 796a83a

33 files changed

Lines changed: 149 additions & 45 deletions

File tree

β€Ž.github/workflows/test-shared.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
id: v8-drv
200200
run: |
201201
V8_DRV=$(
202-
nix-instantiate -E "builtins.filter (p: p.pname == ''v8'') (import $TAR_DIR/tools/nix/ci-shell.nix {}).buildInputs"
202+
nix-instantiate -E "(import $TAR_DIR/tools/nix/ci-shell.nix {}).v8Derivation"
203203
)
204204
V8_STORE_PATH=$(nix-store -q --outputs "$V8_DRV")
205205
echo "V8_DRV=$V8_DRV" >> "$GITHUB_OUTPUT"

β€Žbenchmark/napi/make_callback/binding.gypβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
'targets': [
33
{
44
'target_name': 'binding',
5-
'sources': [ 'binding.cc' ]
5+
'sources': [ 'binding.cc' ],
6+
'include_dirs': [ '<@(node_shared_libuv_include_dirs)' ],
67
}
78
]
89
}

β€Žcommon.gypiβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@
2626
'node_module_version%': '',
2727
'node_with_ltcg%': '',
2828
'node_shared_openssl%': 'false',
29+
'node_shared_openssl_include_dirs%': [],
2930
'openssl_is_boringssl%': 'false',
3031

32+
'node_shared_libuv_include_dirs%': [],
33+
'node_shared_sqlite%': 'false',
34+
'node_shared_sqlite_include_dirs%': [],
35+
'node_shared_zlib_include_dirs%': [],
36+
3137
'node_tag%': '',
3238
'uv_library%': 'static_library',
3339

β€Žconfigure.pyβ€Ž

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,19 +2195,26 @@ def configure_napi(output):
21952195
version = getnapibuildversion.get_napi_version()
21962196
output['variables']['napi_build_version'] = version
21972197

2198-
def configure_library(lib, output, pkgname=None, libraries_key='libraries'):
2198+
def configure_library(lib, output, pkgname=None, libraries_key='libraries', with_separate_include_var=False):
21992199
shared_lib = 'shared_' + lib
22002200
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
2201+
22012202
libraries = output[libraries_key] if libraries_key in output else output['variables'][libraries_key]
22022203

2204+
include_dirs = []
2205+
if with_separate_include_var:
2206+
output['variables'][f'node_{shared_lib}_include_dirs'] = include_dirs
2207+
22032208
if getattr(options, shared_lib):
22042209
(pkg_libs, pkg_cflags, pkg_libpath, _) = pkg_config(pkgname or lib)
22052210

22062211
if options.__dict__[shared_lib + '_includes']:
2207-
output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
2212+
include_dirs += [options.__dict__[shared_lib + '_includes']]
22082213
elif pkg_cflags:
22092214
stripped_flags = [flag.strip() for flag in pkg_cflags.split('-I')]
2210-
output['include_dirs'] += [flag for flag in stripped_flags if flag]
2215+
include_dirs += [flag for flag in stripped_flags if flag]
2216+
2217+
output['include_dirs'] += include_dirs
22112218

22122219
# libpath needs to be provided ahead libraries
22132220
if options.__dict__[shared_lib + '_libpath']:
@@ -2376,7 +2383,7 @@ def without_ssl_error(option):
23762383
if options.openssl_is_fips and not options.shared_openssl:
23772384
variables['node_fipsinstall'] = b(True)
23782385

2379-
configure_library('openssl', o)
2386+
configure_library('openssl', o, with_separate_include_var=True)
23802387

23812388
o['variables']['openssl_version'] = get_openssl_version(o)
23822389
o['variables']['openssl_is_boringssl'] = get_openssl_is_boringssl(o)
@@ -2407,7 +2414,7 @@ def without_sqlite_error(option):
24072414
without_sqlite_error('--shared-sqlite')
24082415
return
24092416

2410-
configure_library('sqlite', o, pkgname='sqlite3')
2417+
configure_library('sqlite', o, pkgname='sqlite3', with_separate_include_var=True)
24112418

24122419
def bundled_ffi_supported(os_name, target_arch):
24132420
if target_arch == 'x86':
@@ -2905,9 +2912,9 @@ def make_bin_override():
29052912
configure_node_lib_files(output)
29062913
configure_node_cctest_sources(output)
29072914
configure_napi(output)
2908-
configure_library('zlib', output)
2915+
configure_library('zlib', output, with_separate_include_var=True)
29092916
configure_library('http_parser', output, pkgname='libllhttp')
2910-
configure_library('libuv', output)
2917+
configure_library('libuv', output, with_separate_include_var=True)
29112918
configure_library('abseil', output, pkgname=[
29122919
'absl_absl_check',
29132920
'absl_absl_log',

β€Žshell.nixβ€Ž

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ let
8888
]
8989
++ builtins.map (depName: "--shared-${depName}") sharedV8Deps
9090
++ pkgs.lib.optional withPerfetto "--with-perfetto";
91+
92+
v8Derivation =
93+
if useSeparateDerivationForV8 == true then
94+
let
95+
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
96+
in
97+
pkgs.callPackage ./tools/nix/v8.nix {
98+
inherit nativeBuildInputs icu;
99+
100+
configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
101+
buildInputs = buildInputs ++ [ sharedLibsToMock ];
102+
}
103+
else
104+
useSeparateDerivationForV8;
91105
in
92106
pkgs.mkShell {
93107
inherit nativeBuildInputs;
@@ -98,20 +112,7 @@ pkgs.mkShell {
98112
buildInputs =
99113
builtins.attrValues sharedLibDeps
100114
++ buildInputs
101-
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
102-
if useSeparateDerivationForV8 == true then
103-
let
104-
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
105-
in
106-
pkgs.callPackage ./tools/nix/v8.nix {
107-
inherit nativeBuildInputs icu;
108-
109-
configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
110-
buildInputs = buildInputs ++ [ sharedLibsToMock ];
111-
}
112-
else
113-
useSeparateDerivationForV8
114-
);
115+
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) v8Derivation;
115116

116117
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;
117118

@@ -120,6 +121,10 @@ pkgs.mkShell {
120121
export CXX="${pkgs.lib.getExe ccache} $CXX"
121122
'';
122123

124+
passthru = {
125+
inherit v8Derivation;
126+
};
127+
123128
env = {
124129
BUILD_WITH = if (ninja != null) then "ninja" else "make";
125130
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";

β€Žtest/addons/async-cleanup-hook/binding.gypβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'target_name': 'binding',
55
'sources': [ 'binding.cc' ],
66
'includes': ['../common.gypi'],
7+
'include_dirs': [ '<@(node_shared_libuv_include_dirs)' ],
78
}
89
]
910
}

β€Žtest/addons/async-hello-world/binding.gypβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'target_name': 'binding',
55
'sources': [ 'binding.cc' ],
66
'includes': ['../common.gypi'],
7+
'include_dirs': [ '<@(node_shared_libuv_include_dirs)' ],
78
}
89
]
910
}

β€Žtest/addons/callback-scope/binding.gypβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'target_name': 'binding',
55
'sources': [ 'binding.cc' ],
66
'includes': ['../common.gypi'],
7+
'include_dirs': ['<@(node_shared_libuv_include_dirs)'],
78
}
89
]
910
}

β€Žtest/addons/esm-export-default/binding.gypβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'target_name': 'binding-export-default',
55
'sources': [ 'binding-export-default.cc' ],
66
'includes': ['../common.gypi'],
7+
'include_dirs': [ '<@(node_shared_libuv_include_dirs)' ],
78
},
89
]
910
}

β€Žtest/addons/esm-export-primitive/binding.gypβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'target_name': 'binding-export-primitive',
55
'sources': [ 'binding-export-primitive.cc' ],
66
'includes': ['../common.gypi'],
7+
'include_dirs': [ '<@(node_shared_libuv_include_dirs)' ],
78
},
89
]
910
}

0 commit comments

Comments
Β (0)