libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

WITH_LIBSODIUM_STATIC option doesn't fully link libsodium statically

Open aminya opened this issue 2 years ago • 8 comments

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

  • libzmq version (commit hash if unreleased): 20de92ac0a2b2b9a1869782a429df68f93c3625e
  • OS: MacOS and Linux

Minimal test code / Steps to reproduce the issue

  • Clone https://github.com/zeromq/zeromq.js
  • Run pnpm install

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

dlopen(/Users/xxx/code/test/node_modules/.pnpm/[email protected]/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

aminya avatar Jan 05 '23 20:01 aminya

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

bluca avatar Jan 05 '23 22:01 bluca

@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

aminya avatar Jan 05 '23 22:01 aminya

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

Bartel-C8 avatar Jan 06 '23 10:01 Bartel-C8

@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.

aminya avatar Jan 25 '23 08:01 aminya

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?

sphaero avatar Jan 25 '23 11:01 sphaero

@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

ptitjes avatar Feb 06 '23 08:02 ptitjes

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

sphaero avatar Feb 06 '23 10:02 sphaero

Made #4562 to fix this issue.

aminya avatar Jun 15 '23 06:06 aminya