SChernykh / p2pool

Decentralized pool for Monero mining
GNU General Public License v3.0
1.07k stars 128 forks source link

P2Pool 4.0 Fails to build due to atomics #312

Closed adapt-L closed 2 months ago

adapt-L commented 2 months ago

It looks like my compiler is complaining about the way your code uses atomics. Here is the error from cmake:

[6/2703] /usr/bin/x86_64-pc-linux-gnu-g++ -DCARES_STATICLIB -DHAVE_BUILTIN_CLZLL -DHAVE_RES_QUERY -DHAVE_SCHED -DMINIUPNP_STATICLIB -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DWITH_GRPC -DWITH_UPNP -DZMQ_STATIC -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/abseil-cpp -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/protobuf/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/crypto -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/cryptonote -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/cppzmq -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/rapidjson/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/robin-hood-hashing/src/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/miniupnp/miniupnpc/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/re2 -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0_build/external/src/grpc/third_party/cares/cares -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/cares/cares -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/cares/cares/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/boringssl-with-bazel/src/include  -O2 -pipe -march=alderlake -mabm -mno-cldemote -mno-kl -mno-pconfig -mno-sgx -mno-widekl -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=12288 -pthread -std=c++14 -MD -MT CMakeFiles/p2pool.dir/src/block_template.cpp.o -MF CMakeFiles/p2pool.dir/src/block_template.cpp.o.d -o CMakeFiles/p2pool.dir/src/block_template.cpp.o -c /var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/block_template.cpp
FAILED: CMakeFiles/p2pool.dir/src/block_template.cpp.o 
/usr/bin/x86_64-pc-linux-gnu-g++ -DCARES_STATICLIB -DHAVE_BUILTIN_CLZLL -DHAVE_RES_QUERY -DHAVE_SCHED -DMINIUPNP_STATICLIB -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DWITH_GRPC -DWITH_UPNP -DZMQ_STATIC -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/abseil-cpp -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/protobuf/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/crypto -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/cryptonote -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/cppzmq -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/rapidjson/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/robin-hood-hashing/src/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/miniupnp/miniupnpc/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/re2 -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0_build/external/src/grpc/third_party/cares/cares -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/cares/cares -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/cares/cares/include -I/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/external/src/grpc/third_party/boringssl-with-bazel/src/include  -O2 -pipe -march=alderlake -mabm -mno-cldemote -mno-kl -mno-pconfig -mno-sgx -mno-widekl -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=12288 -pthread -std=c++14 -MD -MT CMakeFiles/p2pool.dir/src/block_template.cpp.o -MF CMakeFiles/p2pool.dir/src/block_template.cpp.o.d -o CMakeFiles/p2pool.dir/src/block_template.cpp.o -c /var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/block_template.cpp
/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/block_template.cpp: In member function ‘uint32_t p2pool::BlockTemplate::get_hashing_blobs(uint32_t, uint32_t, std::vector<unsigned char>&, uint64_t&, p2pool::difficulty_type&, p2pool::difficulty_type&, p2pool::difficulty_type&, p2pool::hash&, size_t&, uint32_t&) const’:
/var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/block_template.cpp:1312:49: error: use of deleted function ‘std::atomic<unsigned int>::atomic(const std::atomic<unsigned int>&)’
 1312 |                 std::atomic<uint32_t> counter = 1;
      |                                                 ^
In file included from /var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/common.h:57,
                 from /var/tmp/portage/net-p2p/p2pool-4.0/work/p2pool-4.0/src/block_template.cpp:21:
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/atomic:852:7: note: declared here
  852 |       atomic(const atomic&) = delete;
      |       ^~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13/atomic:856:17: note:   after user-defined conversion: ‘constexpr std::atomic<unsigned int>::atomic(__integral_type)’
  856 |       constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
      |                 ^~~~~~
SChernykh commented 2 months ago

What is your compiler version?

https://github.com/SChernykh/p2pool?tab=readme-ov-file#prerequisites

C++ compiler with C++17 support. GCC-8, Clang-13 and MSVC-2019 have been tested and confirmed to work, older compilers may fail to build P2Pool.

~If you can try to build with -DWITH_GRPC=OFF in cmake command line (clean the build folder before trying again).~ No, it won't work because you get an error in another file that's compiled always.

SChernykh commented 2 months ago

GCC 8.4.0, 11.4.0, 12.3.0, 13.2.1, 14.1.0 and clang 13.0.0, 15.0.7, 17.0.6, 18.1.8 all compile this code without errors.

adapt-L commented 2 months ago

My bad, it appears that it was due to my configuration setting std=c++14 from an older build script. I've fixed it now. I was using GCC 13.2.1 20240210 btw.