From ce1ef3661309a9ab462c184787e95e9d9dd29041 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:00:42 +0200 Subject: [PATCH] Build fixes --- .github/workflows/c-cpp.yml | 8 +++-- .../src/common/sanitizer/asan_interface.h | 2 ++ patches/boringssl/win7.patch | 27 +++++++------- patches/protobuf/protobuf.patch | 35 +++++++++++++++++++ scripts/release/macos_aarch64/Dockerfile | 2 +- .../macos_aarch64/p2pool_macos_aarch64.sh | 2 -- scripts/release/macos_aarch64/zutil.patch | 10 ------ scripts/release/macos_x64/Dockerfile | 2 +- scripts/release/macos_x64/p2pool_macos_x64.sh | 2 -- scripts/release/macos_x64/zutil.patch | 10 ------ .../release/windows_x64/p2pool_windows_x64.sh | 2 +- tests/src/check_win7.py | 2 ++ 12 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 patches/protobuf/protobuf.patch delete mode 100644 scripts/release/macos_aarch64/zutil.patch delete mode 100644 scripts/release/macos_x64/zutil.patch diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index e5d761f..7d164b3 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -433,8 +433,8 @@ jobs: strategy: matrix: config: - - {c: "gcc", cxx: "g++", flags: "-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes"} - - {c: "clang", cxx: "clang++", flags: "-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled"} + - {c: "gcc", cxx: "g++", flags: "-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes -Wno-unknown-attributes"} + - {c: "clang", cxx: "clang++", flags: "-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled -Wno-unknown-attributes"} defaults: run: @@ -452,6 +452,10 @@ jobs: update: true install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang mingw-w64-x86_64-lld mingw-w64-x86_64-cmake make git + - name: Apply patch + run: | + git apply --verbose --ignore-whitespace --directory=external/src/grpc/third_party/protobuf patches/protobuf/protobuf.patch + - name: Build libcurl run: | cd external/src/curl diff --git a/external/src/common/sanitizer/asan_interface.h b/external/src/common/sanitizer/asan_interface.h index ac2e3d7..0375927 100644 --- a/external/src/common/sanitizer/asan_interface.h +++ b/external/src/common/sanitizer/asan_interface.h @@ -9,4 +9,6 @@ #define ASAN_UNPOISON_MEMORY_REGION(addr, size) __asan_unpoison_memory_region((addr), (size)) #endif +#define __asan_address_is_poisoned(addr) false + #endif // P2POOL_EXTERNAL_SRC_COMMON_SANITIZER_ASAN_INTERFACE_H diff --git a/patches/boringssl/win7.patch b/patches/boringssl/win7.patch index 8632dd9..5073323 100644 --- a/patches/boringssl/win7.patch +++ b/patches/boringssl/win7.patch @@ -1,16 +1,16 @@ -diff --git a/src/crypto/rand_extra/windows.c b/src/crypto/rand_extra/windows.c -index a44774d23..09cf10942 100644 ---- a/src/crypto/rand_extra/windows.c -+++ b/src/crypto/rand_extra/windows.c -@@ -26,6 +26,7 @@ - OPENSSL_MSVC_PRAGMA(warning(push, 3)) +diff --git a/src/crypto/rand/windows.cc b/src/crypto/rand/windows.cc +index 59df467e7..aa5ac076c 100644 +--- a/src/crypto/rand/windows.cc ++++ b/src/crypto/rand/windows.cc +@@ -24,6 +24,7 @@ + #include #include +#include #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -@@ -61,16 +62,40 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) { +@@ -57,16 +58,40 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) { // See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData); static ProcessPrngFunction g_processprng_fn = NULL; @@ -25,21 +25,22 @@ index a44774d23..09cf10942 100644 HMODULE hmod = LoadLibraryW(L"bcryptprimitives"); - if (hmod == NULL) { - abort(); +- } +- g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng"); +- if (g_processprng_fn == NULL) { +- abort(); + + if (hmod) { + g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng"); + if (g_processprng_fn) { + return; + } - } -- g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng"); -- if (g_processprng_fn == NULL) { -- abort(); ++ } + + if (CryptAcquireContext(&g_hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) { + g_processprng_fn = &wrapper_CryptGenRandom; + return; -+ } + } + + DWORD err = GetLastError(); + if (err == NTE_BAD_KEYSET) { @@ -50,7 +51,7 @@ index a44774d23..09cf10942 100644 + else { + err = GetLastError(); + } - } ++ } + + abort(); } diff --git a/patches/protobuf/protobuf.patch b/patches/protobuf/protobuf.patch new file mode 100644 index 0000000..af481ca --- /dev/null +++ b/patches/protobuf/protobuf.patch @@ -0,0 +1,35 @@ +diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc +index 5758c1602..e425d6715 100644 +--- a/src/google/protobuf/generated_message_tctable_lite.cc ++++ b/src/google/protobuf/generated_message_tctable_lite.cc +@@ -406,7 +406,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) { + if (entry == nullptr) { + if (export_called_function) *test_out = {table->fallback, tag}; + data.data = tag; +- PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS); ++ return table->fallback(PROTOBUF_TC_PARAM_PASS); + } + + // The handler may need the tag and the entry to resolve fallback logic. Both +@@ -468,7 +468,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) { + TailCallParseFunc parse_fn = kMiniParseTable[field_type]; + if (export_called_function) *test_out = {parse_fn, tag, entry}; + +- PROTOBUF_MUSTTAIL return parse_fn(PROTOBUF_TC_PARAM_PASS); ++ return parse_fn(PROTOBUF_TC_PARAM_PASS); + } + + PROTOBUF_NOINLINE const char* TcParser::MiniParse( +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc +index edd6d5122..da894d384 100644 +--- a/src/google/protobuf/port_def.inc ++++ b/src/google/protobuf/port_def.inc +@@ -506,7 +506,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), + #error PROTOBUF_ATTRIBUTE_WEAK was previously defined + #endif + #if ABSL_HAVE_ATTRIBUTE(weak) && !defined(__APPLE__) && \ +- (!defined(_WIN32) || __clang_major__ < 9) && !defined(__MINGW32__) ++ (!defined(_WIN32) || (defined(__clang_major__) && (__clang_major__ < 9))) && !defined(__MINGW32__) + #define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak)) + #define PROTOBUF_HAVE_ATTRIBUTE_WEAK 1 + #else diff --git a/scripts/release/macos_aarch64/Dockerfile b/scripts/release/macos_aarch64/Dockerfile index 873e488..55372d6 100644 --- a/scripts/release/macos_aarch64/Dockerfile +++ b/scripts/release/macos_aarch64/Dockerfile @@ -1,4 +1,4 @@ FROM p2pool_build_ubuntu ARG P2POOL_VERSION -ADD p2pool_macos_aarch64.sh zutil.patch /p2pool/ +ADD p2pool_macos_aarch64.sh /p2pool/ RUN /p2pool/p2pool_macos_aarch64.sh p2pool-${P2POOL_VERSION}-macos-aarch64 ${P2POOL_VERSION} diff --git a/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh b/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh index 7936b5a..b3d6ade 100755 --- a/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh +++ b/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh @@ -19,8 +19,6 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T flags_libs="-Os -flto -w $flags_size $flags_datetime" flags_p2pool="$flags_size $flags_datetime" -patch -u /p2pool/external/src/grpc/third_party/zlib/zutil.h -i /p2pool/zutil.patch - cd /p2pool/external/src/curl cmake . -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=../../../cmake/macos_aarch64_toolchain_clang.cmake -DCMAKE_C_FLAGS="$flags_libs" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include make -j$(nproc) diff --git a/scripts/release/macos_aarch64/zutil.patch b/scripts/release/macos_aarch64/zutil.patch deleted file mode 100644 index 1661d49..0000000 --- a/scripts/release/macos_aarch64/zutil.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- zutil.h -+++ zutil.h -@@ -144,7 +144,6 @@ - # include /* for fdopen */ - # else - # ifndef fdopen --# define fdopen(fd,mode) NULL /* No fdopen() */ - # endif - # endif - # endif diff --git a/scripts/release/macos_x64/Dockerfile b/scripts/release/macos_x64/Dockerfile index aa39010..0a70859 100644 --- a/scripts/release/macos_x64/Dockerfile +++ b/scripts/release/macos_x64/Dockerfile @@ -1,4 +1,4 @@ FROM p2pool_build_ubuntu ARG P2POOL_VERSION -ADD p2pool_macos_x64.sh zutil.patch /p2pool/ +ADD p2pool_macos_x64.sh /p2pool/ RUN /p2pool/p2pool_macos_x64.sh p2pool-${P2POOL_VERSION}-macos-x64 ${P2POOL_VERSION} diff --git a/scripts/release/macos_x64/p2pool_macos_x64.sh b/scripts/release/macos_x64/p2pool_macos_x64.sh index 0904254..84ed9c1 100755 --- a/scripts/release/macos_x64/p2pool_macos_x64.sh +++ b/scripts/release/macos_x64/p2pool_macos_x64.sh @@ -19,8 +19,6 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T flags_libs="-Os -flto -w $flags_size $flags_datetime" flags_p2pool="$flags_size $flags_datetime" -patch -u /p2pool/external/src/grpc/third_party/zlib/zutil.h -i /p2pool/zutil.patch - cd /p2pool/external/src/curl cmake . -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=../../../cmake/macos_x86_64_toolchain_clang.cmake -DCMAKE_C_FLAGS="$flags_libs" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include make -j$(nproc) diff --git a/scripts/release/macos_x64/zutil.patch b/scripts/release/macos_x64/zutil.patch deleted file mode 100644 index 1661d49..0000000 --- a/scripts/release/macos_x64/zutil.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- zutil.h -+++ zutil.h -@@ -144,7 +144,6 @@ - # include /* for fdopen */ - # else - # ifndef fdopen --# define fdopen(fd,mode) NULL /* No fdopen() */ - # endif - # endif - # endif diff --git a/scripts/release/windows_x64/p2pool_windows_x64.sh b/scripts/release/windows_x64/p2pool_windows_x64.sh index 72fb0d5..5566626 100755 --- a/scripts/release/windows_x64/p2pool_windows_x64.sh +++ b/scripts/release/windows_x64/p2pool_windows_x64.sh @@ -18,7 +18,7 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T flags_libs="--target=x86_64-pc-windows-gnu -Os -flto -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -w $flags_size $flags_datetime" -flags_p2pool="--target=x86_64-pc-windows-gnu -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -femulated-tls -Wno-unused-command-line-argument $flags_size $flags_datetime" +flags_p2pool="--target=x86_64-pc-windows-gnu -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -femulated-tls -Wno-unused-command-line-argument -Wno-unknown-attributes $flags_size $flags_datetime" flags_cxx_headers="-isystem /usr/local/x86_64-w64-mingw32/include/c++ -isystem /usr/local/x86_64-w64-mingw32/include/c++/15.1.0 -isystem /usr/local/x86_64-w64-mingw32/include" cd /p2pool diff --git a/tests/src/check_win7.py b/tests/src/check_win7.py index 9e4b9bf..480225e 100644 --- a/tests/src/check_win7.py +++ b/tests/src/check_win7.py @@ -299,6 +299,8 @@ allowedAPIs = { "GetUserProfileDirectoryW", "GetUserNameW", "GetEnvironmentVariableW", + "RtlCaptureStackBackTrace", + "GetDynamicTimeZoneInformation", } f = open(sys.argv[1], 'r')