Skip to content

Commit

Permalink
addpkg: p2pool(fix compilation error caused by cast-align and cast-qual)
Browse files Browse the repository at this point in the history
  • Loading branch information
LithiumTins committed Oct 9, 2023
1 parent 6caf561 commit ffe3ed7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions p2pool/riscv64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--- PKGBUILD
+++ PKGBUILD
@@ -22,7 +22,55 @@ prepare() {
}

build() {
- cd ${pkgname}/build
+ cd ${pkgname}
+ # the package use -Wcast-align flag, it seems casting from 'uint8_t *' to 'uint32_t *' doesn't cause warning on x86_64, but it does on riscv64
+ # with -Werror, it causes build failure. So the following code add #pragma GCC diagnostic ignored "-Wcast-align" to ignore the warning temporarily
+ # patch src/common.h
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/common.h
+ sed -i '$ a\#pragma GCC diagnostic pop' src/common.h
+ # patch src/block_cache.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/block_cache.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/block_cache.cpp
+ # patch src/keccak.h
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/keccak.h
+ sed -i '$ a\#pragma GCC diagnostic pop' src/keccak.h
+ # patch src/keccak.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/keccak.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/keccak.cpp
+ # patch src/p2p_server.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/p2p_server.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/p2p_server.cpp
+ # patch src/pool_block.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/pool_block.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/pool_block.cpp
+ # patch src/tcp_server.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/tcp_server.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/tcp_server.cpp
+ # patch src/util.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/util.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/util.cpp
+ # patch src/side_chain.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/side_chain.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/side_chain.cpp
+ # patch src/stratum_server.cpp
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' src/stratum_server.cpp
+ sed -i '$ a\#pragma GCC diagnostic pop' src/stratum_server.cpp
+ # patch external/src/RandomX/src/intrin_portable.h
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' external/src/RandomX/src/intrin_portable.h
+ sed -i '$ a\#pragma GCC diagnostic pop' external/src/RandomX/src/intrin_portable.h
+ # patch external/src/rapidjson/include/rapidjson/internal/stack.h
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' external/src/rapidjson/include/rapidjson/internal/stack.h
+ sed -i '$ a\#pragma GCC diagnostic pop' external/src/rapidjson/include/rapidjson/internal/stack.h
+ # patch external/src/rapidjson/include/rapidjson/allocators.h
+ sed -i '1 i\#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored "-Wcast-align"' external/src/rapidjson/include/rapidjson/allocators.h
+ sed -i '$ a\#pragma GCC diagnostic pop' external/src/rapidjson/include/rapidjson/allocators.h
+
+ # the package build failed with -Werror=cast-qual, because it remove const qualifier while casting which seems not necessary
+ # see https://github.com/tevador/RandomX/issues/277
+ # patch external/src/RandomX/src/intrin_portable.h (add const qualifier)
+ sed -Ei 's/(load32\(\()(uint8_t\*)/\1const \2/g' external/src/RandomX/src/intrin_portable.h
+ cd build
+
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
}

0 comments on commit ffe3ed7

Please sign in to comment.