From 0c492892a01380a3376795cfc1f8b39b82a815e1 Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Fri, 1 Nov 2024 16:14:53 +0100 Subject: [PATCH] build libuv as shared --- .github/workflows/build.yml | 4 ++ build-windows.bat | 2 +- patches/libuv_shared.patch | 88 +++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 patches/libuv_shared.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ea8d97f..4c83f3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,7 +83,11 @@ jobs: ${{ github.workspace }}/libnode-Windows-x64/libnode22.dll ${{ github.workspace }}/libnode-Windows-x64/libnode22.lib ${{ github.workspace }}/libnode-Windows-x64/libnode22.pdb + ${{ github.workspace }}/libnode-Windows-x64/libuv.dll + ${{ github.workspace }}/libnode-Windows-x64/libuv.lib + ${{ github.workspace }}/libnode-Windows-x64/libuv.pdb ${{ github.workspace }}/libnode-Linux-x64/libnode22.so + ${{ github.workspace }}/libnode-Linux-x64/libuv.so - name: Delete artifacts uses: geekyeggo/delete-artifact@v5 diff --git a/build-windows.bat b/build-windows.bat index 78360cc..ef5681e 100644 --- a/build-windows.bat +++ b/build-windows.bat @@ -6,4 +6,4 @@ for %%f in (../patches/*.patch) do ( git apply --reject --whitespace=fix "../patches/%%f" ) -vcbuild.bat release x64 dll no-cctest clang-cl nonpm +vcbuild.bat release x64 dll no-cctest clang-cl nonpm \ No newline at end of file diff --git a/patches/libuv_shared.patch b/patches/libuv_shared.patch new file mode 100644 index 0000000..a295d7d --- /dev/null +++ b/patches/libuv_shared.patch @@ -0,0 +1,88 @@ +diff --git a/common.gypi b/common.gypi +index de83a56672..1f5c1781bb 100644 +--- a/common.gypi ++++ b/common.gypi +@@ -23,7 +23,7 @@ + 'node_shared_openssl%': 'false', + + 'node_tag%': '', +- 'uv_library%': 'static_library', ++ 'uv_library%': 'shared_library', + + 'clang%': 0, + 'error_on_warn%': 'false', +diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp +index 6c86c3fa50..006596e86a 100644 +--- a/deps/uv/uv.gyp ++++ b/deps/uv/uv.gyp +@@ -150,7 +150,21 @@ + ], + }, + +- 'targets': [ ++ 'targets': [ { ++ 'target_name': 'libuv_postbuild', ++ 'type': 'none', ++ 'dependencies': ['libuv'], ++ 'conditions': [ ++ ['OS=="win"', { ++ 'copies': [{ ++ 'destination': '<(PRODUCT_DIR)/lib', ++ 'files': [ ++ '<(PRODUCT_DIR)/libuv<(STATIC_LIB_SUFFIX)', ++ ], ++ }], ++ }], ++ ], ++ }, + { + 'target_name': 'libuv', + 'toolsets': ['host', 'target'], +@@ -246,7 +260,7 @@ + # This will cause gyp to set soname + # Must correspond with UV_VERSION_MAJOR + # in include/uv/version.h +- 'product_extension': 'so.1', ++ 'product_extension': 'so', + }], + ], + }], +diff --git a/node.gyp b/node.gyp +index 11474953b1..a45c909938 100644 +--- a/node.gyp ++++ b/node.gyp +@@ -19,7 +19,7 @@ + 'node_shared_zlib%': 'false', + 'node_shared_http_parser%': 'false', + 'node_shared_cares%': 'false', +- 'node_shared_libuv%': 'false', ++ 'node_shared_libuv%': 'true', + 'node_shared_sqlite%': 'false', + 'node_shared_uvwasi%': 'false', + 'node_shared_nghttp2%': 'false', +@@ -863,6 +863,7 @@ + 'deps/ada/ada.gyp:ada', + 'deps/nbytes/nbytes.gyp:nbytes', + 'node_js2c#host', ++ 'deps/uv/uv.gyp:libuv_postbuild', + ], + + 'sources': [ +diff --git a/node.gypi b/node.gypi +index 44780fe3b1..10346730bf 100644 +--- a/node.gypi ++++ b/node.gypi +@@ -188,13 +188,6 @@ + '-Wl,-force_load,<(PRODUCT_DIR)/libuv<(STATIC_LIB_SUFFIX)', + ], + }, +- 'msvs_settings': { +- 'VCLinkerTool': { +- 'AdditionalOptions': [ +- '/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/libuv<(STATIC_LIB_SUFFIX)', +- ], +- }, +- }, + 'conditions': [ + ['OS!="aix" and OS!="os400" and OS!="ios" and node_shared=="false"', { + 'ldflags': [