When using the native compiler (in my case, its xlC 8.0 but later versions will have the same problem), the build tools are using the wrong flags to xlC to indicate to create a shared library.
`configure` is generating libtool to use the "-bM:SRE" flag to indicate "create a shared object" as part of .libs/libzmq.so.3 target. This should be changed to the -qmkshrobj flag.
Without -qmkshrobj, the C++ compiler does not detect the static members of classes correctly, and thus does not run any constructors needed before main() begins. In the case of zmq, this includes: zmq::atomic_counter_t zmq::ctx_t::max_socket_id in ctx.cpp. The atomic_counter_t isn't created, nor is the mutex inside initialized. The first time any part of zmq tries to lock this mutex it fails miserably due to not being initialized (failure is in mutex.hpp)
I realize this is likely an issue to take up with autoconf/libtool, but it does affect the correct building on AIX with native tools. At the very least I wanted to log the issue so other AIX users could benefit.
If you create a static library only (ie, with --disable-shared --enable-static), ZMQ works fine with the native compilers.
With GCC on AIX, both shared and static build and test fine.
When using the native compiler (in my case, its xlC 8.0 but later versions will have the same problem), the build tools are using the wrong flags to xlC to indicate to create a shared library.
`configure` is generating libtool to use the "-bM:SRE" flag to indicate "create a shared object" as part of .libs/libzmq.so.3 target. This should be changed to the -qmkshrobj flag.
Without -qmkshrobj, the C++ compiler does not detect the static members of classes correctly, and thus does not run any constructors needed before main() begins. In the case of zmq, this includes:
zmq::atomic_counter_t zmq::ctx_t::max_socket_id in ctx.cpp. The atomic_counter_t isn't created, nor is the mutex inside initialized. The first time any part of zmq tries to lock this mutex it fails miserably due to not being initialized (failure is in mutex.hpp)
I realize this is likely an issue to take up with autoconf/libtool, but it does affect the correct building on AIX with native tools. At the very least I wanted to log the issue so other AIX users could benefit.
If you create a static library only (ie, with --disable-shared --enable-static), ZMQ works fine with the native compilers.
With GCC on AIX, both shared and static build and test fine.