I tried to build p2pool on RISCV64 ArchLinux but failed. The errors are like:
/build/p2pool/src/p2pool/src/common.h: In member function ‘bool p2pool::raw_ip::operator==(const p2pool::raw_ip&) const’:
/build/p2pool/src/p2pool/src/common.h:443:37: error: cast from ‘const uint8_t*’ {aka ‘const unsigned char*’} to ‘const uint64_t*’ {aka ‘const long unsigned int*’} increases required alignment of target type [-Werror=cast-align]
443 | const uint64_t* a = reinterpret_cast<const uint64_t*>(data);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It seems the warning is caused by cast from uint8_t* to uint64_t* increases the alignment, and with -Wcast-align and -Werror the compilation is terminated.
I've carefully looked into this problem and found that:
The compiler doesn't give out warnings on x86_64 no matter whether the alignment is increased and is well treated. However, it gives out warnings on RISCV64 when the alignment is increased even when the operand has been aligned as target type. For example, in the following code data is well-aligned and the warning above is still caused(the line number doesn't match):
https://github.com/SChernykh/p2pool/blob/5988acb12b767f7237650840a8bc7e47114a4684/src/common.h#L426-L439
Due to the reasons above, the compile flag -Wcast-align actually help nothing because the project indeed use casts that increase the alignment , while it does stop p2pool to build on RISCV64. Thus I suggest remove this compile flag.
I tried to build p2pool on
RISCV64 ArchLinux
but failed. The errors are like:It seems the warning is caused by cast from
uint8_t*
touint64_t*
increases the alignment, and with-Wcast-align
and-Werror
the compilation is terminated.I've carefully looked into this problem and found that:
x86_64
no matter whether the alignment is increased and is well treated. However, it gives out warnings onRISCV64
when the alignment is increased even when the operand has been aligned as target type. For example, in the following codedata
is well-aligned and the warning above is still caused(the line number doesn't match): https://github.com/SChernykh/p2pool/blob/5988acb12b767f7237650840a8bc7e47114a4684/src/common.h#L426-L439read_unaligned()
insrc\util.h
, but I think it's ok because they do intend touse the pointer as an unaligned one. Here is one example: https://github.com/SChernykh/p2pool/blob/5988acb12b767f7237650840a8bc7e47114a4684/src/p2p_server.cpp#L1600-L1604Due to the reasons above, the compile flag
-Wcast-align
actually help nothing because the project indeed use casts that increase the alignment , while it does stop p2pool to build on RISCV64. Thus I suggest remove this compile flag.