Repository: bitcoin/bitcoin (language: cpp)

Issue:
build: Native ./depends build fails on s390x
Steps to reproduce on a fresh s390x machine:

```
make NO_QT=1 NO_WALLET=1 NO_UPNP=1 NO_NATPMP=1 -j $(nproc)
```

(Cross-compilation to s390x works)


Output:

```
Building zeromq...
make[1]: Entering directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[2]: Entering directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[3]: Entering directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[3]: Leaving directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[3]: Entering directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
[  1%] Building CXX object CMakeFiles/objects.dir/src/address.cpp.o
In file included from /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/precompiled.hpp:16,
                 from /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/address.cpp:3:
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build/platform.hpp:22:28: error: 'undefined' was not declared in this scope
   22 | #define ZMQ_CACHELINE_SIZE undefined
      |                            ^~~~~~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/command.hpp:191:26: note: in expansion of macro 'ZMQ_CACHELINE_SIZE'
  191 | __attribute__ ((aligned (ZMQ_CACHELINE_SIZE)))
      |                          ^~~~~~~~~~~~~~~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build/platform.hpp:22:28: error: 'undefined' was not declared in this scope
   22 | #define ZMQ_CACHELINE_SIZE undefined
      |                            ^~~~~~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/yqueue.hpp:34:45: note: in expansion of macro 'ZMQ_CACHELINE_SIZE'
   34 | template <typename T, int N, size_t ALIGN = ZMQ_CACHELINE_SIZE> class yqueue_t
      |                                             ^~~~~~~~~~~~~~~~~~
In file included from /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/mailbox.hpp:12,
                 from /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ctx.hpp:11,
                 from /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/address.cpp:6:
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:155:18: error: template argument 3 is invalid
  155 |     yqueue_t<T, N> _queue;
      |                  ^
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In constructor 'zmq::ypipe_t<T, N>::ypipe_t()':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:26:16: error: request for member 'push' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   26 |         _queue.push ();
      |                ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:30:32: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   30 |         _r = _w = _f = &_queue.back ();
      |                                ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:31:25: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   31 |         _c.set (&_queue.back ());
      |                         ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In member function 'void zmq::ypipe_t<T, N>::write(const T&, bool)':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:50:16: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   50 |         _queue.back () = value_;
      |                ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:51:16: error: request for member 'push' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   51 |         _queue.push ();
      |                ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:55:26: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   55 |             _f = &_queue.back ();
      |                          ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In member function 'bool zmq::ypipe_t<T, N>::unwrite(T*)':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:66:27: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   66 |         if (_f == &_queue.back ())
      |                           ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:68:16: error: request for member 'unpush' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   68 |         _queue.unpush ();
      |                ^~~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:69:26: error: request for member 'back' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
   69 |         *value_ = _queue.back ();
      |                          ^~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In member function 'bool zmq::ypipe_t<T, N>::check_read()':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:104:21: error: request for member 'front' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  104 |         if (&_queue.front () != _r && _r)
      |                     ^~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:111:30: error: request for member 'front' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  111 |         _r = _c.cas (&_queue.front (), NULL);
      |                              ^~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:117:21: error: request for member 'front' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  117 |         if (&_queue.front () == _r || !_r)
      |                     ^~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In member function 'bool zmq::ypipe_t<T, N>::read(T*)':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:134:26: error: request for member 'front' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  134 |         *value_ = _queue.front ();
      |                          ^~~~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:135:16: error: request for member 'pop' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  135 |         _queue.pop ();
      |                ^~~
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp: In member function 'bool zmq::ypipe_t<T, N>::probe(bool (*)(const T&))':
/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/src/ypipe.hpp:147:31: error: request for member 'front' in '((zmq::ypipe_t<T, N>*)this)->zmq::ypipe_t<T, N>::_queue', which is of non-class type 'int'
  147 |         return (*fn_) (_queue.front ());
      |                               ^~~~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-tautological-constant-compare' may have been intended to silence earlier diagnostics
make[3]: *** [CMakeFiles/objects.dir/build.make:90: CMakeFiles/objects.dir/src/address.cpp.o] Error 1
make[3]: Leaving directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[2]: *** [CMakeFiles/Makefile2:88: CMakeFiles/objects.dir/all] Error 2
make[2]: Leaving directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make[1]: *** [Makefile:136: all] Error 2
make[1]: Leaving directory '/b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build'
make: *** [funcs.mk:301: /b-c/depends/work/build/s390x-ibm-linux-gnu/zeromq/4.3.5-be763aa3d4e/build/.stamp_built] Error 2
```




Discussion / hints:

Fix patch:
diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk
index 7620df5477727..df018a1032247 100644
--- a/depends/packages/zeromq.mk
+++ b/depends/packages/zeromq.mk
@@ -10,6 +10,7 @@ $(package)_patches += builtin_sha1.patch
 $(package)_patches += fix_have_windows.patch
 $(package)_patches += openbsd_kqueue_headers.patch
 $(package)_patches += cmake_minimum.patch
+$(package)_patches += cacheline_undefined.patch
 $(package)_patches += no_librt.patch
 
 define $(package)_set_vars
@@ -25,6 +26,7 @@ define $(package)_preprocess_cmds
   patch -p1 < $($(package)_patch_dir)/remove_libstd_link.patch && \
   patch -p1 < $($(package)_patch_dir)/macos_mktemp_check.patch && \
   patch -p1 < $($(package)_patch_dir)/builtin_sha1.patch && \
+  patch -p1 < $($(package)_patch_dir)/cacheline_undefined.patch && \
   patch -p1 < $($(package)_patch_dir)/fix_have_windows.patch && \
   patch -p1 < $($(package)_patch_dir)/openbsd_kqueue_headers.patch && \
   patch -p1 < $($(package)_patch_dir)/cmake_minimum.patch && \
diff --git a/depends/patches/zeromq/cacheline_undefined.patch b/depends/patches/zeromq/cacheline_undefined.patch
new file mode 100644
index 0000000000000..02bd2a5fe5d5a
--- /dev/null
+++ b/depends/patches/zeromq/cacheline_undefined.patch
@@ -0,0 +1,15 @@
+Use proper STREQUAL instead of EQUAL to compare strings.txt
+
+See: https://github.com/zeromq/libzmq/pull/4711.
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -476,7 +476,7 @@ execute_process(
+ if(CACHELINE_SIZE STREQUAL ""
+    OR CACHELINE_SIZE EQUAL 0
+    OR CACHELINE_SIZE EQUAL -1
+-   OR CACHELINE_SIZE EQUAL "undefined")
++   OR CACHELINE_SIZE STREQUAL "undefined")
+   set(ZMQ_CACHELINE_SIZE 64)
+ else()
+   set(ZMQ_CACHELINE_SIZE ${CACHELINE_SIZE})


Test patch: