zeromq / libzmq

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

When libzmq is cross-compiled with CMake, the threads name and affinity cannot be set. #4513

Closed guill-delacourt closed 1 year ago

guill-delacourt commented 1 year ago

Issue description

I have noticed a difference between the autotools build and the CMake build when computing the definitions concerning the thread name and affinities (ZMQ_HAVE_PTHREAD_SETNAME_1, ZMQ_HAVE_PTHREAD_SETNAME_2, ZMQ_HAVE_PTHREAD_SETNAME_3, ZMQ_HAVE_PTHREAD_SET_NAME, ZMQ_HAVE_PTHREAD_SET_AFFINITY).

When using the autotools build, a compilation test is done to set the definitions. When using the CMake build, an execution test is done to set those same definitions. This has an incidence when libzmq is cross-compiled as compilation tests can be done, but not execution tests. So, when cross-compiling with autotools, those definitions are set if the target system has the capabilities, but not when cross-compiling with CMake.

Environment

Minimal test code / Steps to reproduce the issue

  1. Cross-compile libzmq for a target that have the non-portable functions to set the name and affinity (ex. compiling for Linux aarch64 from Linux x86_64), with autotools
  2. Do the same thing, but with CMake

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

Undefined symbols pthread_setaffinity_np and pthread_setname_np are present in the library libzmq.so built by autotools, indicating those functions are called by libzmq. Undefined symbols pthread_setaffinity_np and pthread_setname_np are not present in the library libzmq.so built by CMake, indicating those functions are not called by libzmq.

What's the expected result?

Undefined symbols pthread_setaffinity_np and pthread_setname_np are present in the library libzmq.so built by autotools and CMake.

bluca commented 1 year ago

https://github.com/zeromq/libzmq/pull/4559