From ca3d4e0cd31eb05c96ff49fdcaf11aadb44b04ff Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 26 Jan 2026 16:08:45 +0100 Subject: [PATCH] build: add `--shared-lief` configure flag PR-URL: https://github.com/nodejs/node/pull/61536 Reviewed-By: Chengzhong Wu Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung --- .github/workflows/test-shared.yml | 2 +- Makefile | 1 + configure.py | 31 +++++++++++++++++++++++++++++++ node.gyp | 6 +++++- shell.nix | 3 +++ tools/nix/sharedLibDeps.nix | 4 ++++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-shared.yml b/.github/workflows/test-shared.yml index 310640538414ab..7c2a7ab3a1db64 100644 --- a/.github/workflows/test-shared.yml +++ b/.github/workflows/test-shared.yml @@ -198,7 +198,7 @@ jobs: --arg ccache '(import {}).sccache' \ --arg devTools '[]' \ --arg benchmarkTools '[]' \ - ${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }} + ${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withLief false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }} --run ' make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS" ' diff --git a/Makefile b/Makefile index 71f12062dd92e9..cad6fb029387d0 100644 --- a/Makefile +++ b/Makefile @@ -1239,6 +1239,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1) $(RM) -r $(TARNAME)/deps/histogram $(RM) -r $(TARNAME)/deps/icu-small $(RM) -r $(TARNAME)/deps/icu-tmp + $(RM) -r $(TARNAME)/deps/LIEF $(RM) -r $(TARNAME)/deps/llhttp $(RM) -r $(TARNAME)/deps/nbytes $(RM) -r $(TARNAME)/deps/nghttp2 diff --git a/configure.py b/configure.py index 558a8298f11eaf..c9397f1c496880 100755 --- a/configure.py +++ b/configure.py @@ -355,6 +355,28 @@ dest='shared_libuv_libpath', help='a directory to search for the shared libuv DLL') +shared_optgroup.add_argument('--shared-lief', + action='store_true', + dest='shared_lief', + default=None, + help='link to a shared lief DLL instead of static linking') + +shared_optgroup.add_argument('--shared-lief-includes', + action='store', + dest='shared_lief_includes', + help='directory containing lief header files') + +shared_optgroup.add_argument('--shared-lief-libname', + action='store', + dest='shared_lief_libname', + default='LIEF', + help='alternative lib name to link to [default: %(default)s]') + +shared_optgroup.add_argument('--shared-lief-libpath', + action='store', + dest='shared_lief_libpath', + help='a directory to search for the shared lief DLL') + shared_optgroup.add_argument('--shared-nbytes', action='store_true', dest='shared_nbytes', @@ -2120,6 +2142,14 @@ def without_ssl_error(option): o['variables']['openssl_version'] = get_openssl_version(o) +def configure_lief(o): + if options.without_lief: + if options.shared_lief: + error('--without-lief is incompatible with --shared-lief') + return + + configure_library('lief', o, pkgname='LIEF') + def configure_sqlite(o): o['variables']['node_use_sqlite'] = b(not options.without_sqlite) if options.without_sqlite: @@ -2582,6 +2612,7 @@ def make_bin_override(): configure_library('nghttp2', output, pkgname='libnghttp2') configure_library('nghttp3', output, pkgname='libnghttp3') configure_library('ngtcp2', output, pkgname='libngtcp2') +configure_lief(output); configure_sqlite(output); configure_library('temporal_capi', output) configure_library('uvwasi', output) diff --git a/node.gyp b/node.gyp index d4ca5b12857e9e..83351d1d82627e 100644 --- a/node.gyp +++ b/node.gyp @@ -18,6 +18,7 @@ 'node_shared_hdr_histogram%': 'false', 'node_shared_http_parser%': 'false', 'node_shared_libuv%': 'false', + 'node_shared_lief%': 'false', 'node_shared_nbytes%': 'false', 'node_shared_nghttp2%': 'false', 'node_shared_openssl%': 'false', @@ -1001,10 +1002,13 @@ 'deps/ncrypto/ncrypto.gyp:ncrypto', ], }], - [ 'node_use_lief=="true"', { + [ 'node_use_lief=="true" and node_shared_lief=="false"', { 'defines': [ 'HAVE_LIEF=1' ], 'dependencies': [ 'deps/LIEF/lief.gyp:liblief' ], }], + [ 'node_use_lief=="true" and node_shared_lief=="true"', { + 'defines': [ 'HAVE_LIEF=1' ], + }], [ 'node_use_sqlite=="true"', { 'sources': [ '<@(node_sqlite_sources)', diff --git a/shell.nix b/shell.nix index b96363f468fdf2..4a9f71b0372787 100644 --- a/shell.nix +++ b/shell.nix @@ -12,6 +12,7 @@ # Build options icu ? pkgs.icu, withAmaro ? true, + withLief ? true, withQuic ? false, withSQLite ? true, withSSL ? true, @@ -19,6 +20,7 @@ sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix { inherit pkgs + withLief withQuic withSQLite withSSL @@ -82,6 +84,7 @@ pkgs.mkShell { ] ++ extraConfigFlags ++ pkgs.lib.optional (!withAmaro) "--without-amaro" + ++ pkgs.lib.optional (!withLief) "--without-lief" ++ pkgs.lib.optional withQuic "--experimental-quic" ++ pkgs.lib.optional (!withSQLite) "--without-sqlite" ++ pkgs.lib.optional (!withSSL) "--without-ssl" diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index 9f133d08cc6852..d59b179103dda4 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -1,5 +1,6 @@ { pkgs ? import ./pkgs.nix { }, + withLief ? true, withQuic ? false, withSQLite ? true, withSSL ? true, @@ -32,6 +33,9 @@ ]; }; } +// (pkgs.lib.optionalAttrs withLief { + inherit (pkgs) lief; +}) // (pkgs.lib.optionalAttrs withQuic { inherit (pkgs) nghttp3