zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.75k stars 2.36k forks source link

WITH_LIBSODIUM_STATIC option doesn't fully link libsodium statically #4484

Open aminya opened 1 year ago

aminya commented 1 year ago

Issue description

In Zeromq.js, the libsodium is built statically, but the built library still tries to link to the dynamic libraries. I expect the built binary to include llibsodium and not rely on its dynamic libraries.

See https://github.com/zeromq/zeromq.js/issues/529#issuecomment-1370696934

Environment

Minimal test code / Steps to reproduce the issue

What's the actual result? (include assertion message & call stack if applicable)

dlopen(/Users/xxx/code/test/node_modules/.pnpm/zeromq@6.0.0-beta.16/node_modules/zeromq/prebuilds/darwin-x64/node.napi.glibc.node, 0x0001): Library not loaded: /usr/local/opt/libsodium/lib/libsodium.23.dylib

What's the expected result?

The built binary should not need the dynamic libraries

bluca commented 1 year ago

it's up to the caller to use the appropriate compiler flags for these niche use cases

aminya commented 1 year ago

@bluca This is not a niche use case, it is a bug in CMake. The current CMake file is not doing what it promised to do. WITH_LIBSODIUM_STATIC says it links libsodium statically, but it doesn't

Bartel-C8 commented 1 year ago

Maybe libzmq can use the official Findsodium.cmake file, provided by libsodium? It does support linking statically.

https://github.com/jedisct1/libsodium/blob/stable/contrib/Findsodium.cmake

aminya commented 1 year ago

@zeromq/core could someone reopen this issue? It is blocking for ZeromqJS. VsCode (used by millions) has been using the old version of zermqjs because of this.

sphaero commented 1 year ago

I

Maybe libzmq can use the official Findsodium.cmake file, provided by libsodium? It does support linking statically.

https://github.com/jedisct1/libsodium/blob/stable/contrib/Findsodium.cmake

If this is a working fix can someone create a PR?

ptitjes commented 1 year ago

@bluca Would you mind reopening this please? See these comments above: https://github.com/zeromq/libzmq/issues/4484#issuecomment-1372885784 https://github.com/zeromq/libzmq/issues/4484#issuecomment-1373452630

sphaero commented 1 year ago

I've reopened it but as long as nobody comes up with a PR it is to no avail?

aminya commented 1 year ago

Made #4562 to fix this issue.