libzmq: Problem: The addition of sha1 sources breaks static linking

Please use this template for reporting suspected bugs or requests for help.

Issue description

I encountered a zyre REGRESSION error when I was trying to update vcpkg’s zeromq to lastest: https://github.com/microsoft/vcpkg/pull/8119 In https://github.com/zeromq/libzmq/pull/3579, external/sha1/sha1.h and external/sha1/sha1.c are added. However, czmq also has its own copy of these two files: https://github.com/zeromq/czmq/tree/master/src/foreign/sha1

If both libzmq and czmq are built as static libraries, then the compiler will be unhappy:

/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a(sha1.c.o):/ci/myagent/_work/1/s/buildtrees/zeromq/src/407c1e69ad-6a0d86f40e/external/sha1/sha1.c:225: first defined here
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libczmq.a(zdigest.c.o): In function `sha1_pad':
/ci/myagent/_work/1/s/buildtrees/czmq/src/ff5f9b6893-f1fd59e8c7/src/foreign/sha1/sha1.inc_c:235: multiple definition of `sha1_pad'
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a(sha1.c.o):/ci/myagent/_work/1/s/buildtrees/zeromq/src/407c1e69ad-6a0d86f40e/external/sha1/sha1.c:236: first defined here
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libczmq.a(zdigest.c.o): In function `sha1_loop':
/ci/myagent/_work/1/s/buildtrees/czmq/src/ff5f9b6893-f1fd59e8c7/src/foreign/sha1/sha1.inc_c:278: multiple definition of `sha1_loop'
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a(sha1.c.o):/ci/myagent/_work/1/s/buildtrees/zeromq/src/407c1e69ad-6a0d86f40e/external/sha1/sha1.c:279: first defined here
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libczmq.a(zdigest.c.o): In function `sha1_result':
/ci/myagent/_work/1/s/buildtrees/czmq/src/ff5f9b6893-f1fd59e8c7/src/foreign/sha1/sha1.inc_c:306: multiple definition of `sha1_result'
/ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a(sha1.c.o):/ci/myagent/_work/1/s/buildtrees/zeromq/src/407c1e69ad-6a0d86f40e/external/sha1/sha1.c:307: first defined here
collect2: error: ld returned 1 exit status
[19/25] : && /usr/bin/c++  -fPIC -g  -rdynamic CMakeFiles/ztester_gossip.dir/src/ztester_gossip.c.o  -o ztester_gossip  libzyre.a /ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a /ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libczmq.a /ci/myagent/_work/1/s/installed/x64-linux/debug/lib/libzmq.a -lrt -lpthread && :
FAILED: ztester_gossip 

Environment

  • libzmq version (e756743a12468fabe0141f979aa2da407c1e69ad):
  • OS: Ubuntu 19.04

Minimal test code / Steps to reproduce the issue

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

What’s the expected result?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (21 by maintainers)

Most upvoted comments

I have added a new feature in zeromq’s control file: websockets-sha1:

./vcpkg install zeromq[websockets-sha1]

will build zeromq with sha1 sources and enable WebSocket transport support.

./vcpkg install zeromq

will exclude sha1 sources and disable WebSocket support.

@myd7349 following PR should allow to build with external library (NSS): https://github.com/zeromq/libzmq/pull/3677

Supporting both cmake and autotools.

I’m not sure how to make vcpkg use the external library or disable websocket transport so the build will succeed.

I will use NSS, working on it