From 912fd1f83d143d7b6253bc391dbe186646e781c9 Mon Sep 17 00:00:00 2001 From: Tony Perrie Date: Thu, 20 Aug 2026 22:50:30 +0100 Subject: [PATCH] fix for msvc analyze, openssl build on vs2022 and zOS builds --- CMakeLists.txt | 1 + c/CMakeLists.txt | 6 +++++- c/src/ssl/openssl.c | 25 ++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 647b2a1e4..f1bfa30fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,6 +351,7 @@ macro(set_search_path result) endmacro() if (CMAKE_SYSTEM_NAME STREQUAL Windows) + add_definitions(-D_WIN32_WINNT=0x0601) # CMake uses semicolon as list separator. Change ';'->'\;' function(to_native_path path result) file (TO_NATIVE_PATH "${path}" path) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index 33930c3c3..f5911128b 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -151,7 +151,7 @@ endif() # Link in openssl if present if (SSL_IMPL STREQUAL openssl) set (pn_ssl_impl src/ssl/openssl.c) - set (SSL_LIB OpenSSL::SSL Threads::Threads) + set (SSL_LIB OpenSSL::SSL OpenSSL::Crypto Threads::Threads) elseif (SSL_IMPL STREQUAL schannel) set (pn_ssl_impl src/ssl/schannel.cpp) set (SSL_LIB Crypt32.lib Secur32.lib) @@ -389,6 +389,10 @@ endif() if (PROACTOR STREQUAL "libuv" OR (NOT PROACTOR AND NOT PROACTOR_OK)) find_package(Libuv) if (Libuv_FOUND) + if(TARGET libuv::uv AND NOT TARGET Libuv::Libuv) + add_library(Libuv::Libuv ALIAS libuv::uv) + endif() + set (PROACTOR_OK libuv) set (qpid-proton-proactor src/proactor/libuv.c ${qpid-proton-proactor-common}) set (PROACTOR_LIBS Libuv::Libuv) diff --git a/c/src/ssl/openssl.c b/c/src/ssl/openssl.c index 4c3a76c5d..7e1b89335 100644 --- a/c/src/ssl/openssl.c +++ b/c/src/ssl/openssl.c @@ -383,9 +383,11 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) return preverify_ok; } +#ifdef __GNUC__ // Temporary: PROTON-2544 for build. Next release: replace or remove DH_xxx() functions. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif // __GNUC__ // This was introduced in v1.1 #if OPENSSL_VERSION_NUMBER < 0x10100000 @@ -591,7 +593,9 @@ static bool pni_init_ssl_domain( pn_ssl_domain_t * domain, pn_ssl_mode_t mode ) } // PROTON-2544: see earlier related push. Temporary only. +#ifdef __GNUC__ #pragma GCC diagnostic pop +#endif // __GNUC__ pn_ssl_domain_t *pn_ssl_domain( pn_ssl_mode_t mode ) { @@ -1719,6 +1723,7 @@ static size_t buffered_output(pn_transport_t *transport) /* Thread-safe locking and initialization for POSIX and Windows */ +static void initialize(void); static bool init_ok = false; @@ -1730,9 +1735,25 @@ static inline void pni_mutex_lock(pni_mutex_t *m) { EnterCriticalSection(m); } static inline void pni_mutex_unlock(pni_mutex_t *m) { LeaveCriticalSection(m); } static inline unsigned long id_callback(void) { return (unsigned long)GetCurrentThreadId(); } INIT_ONCE initialize_once = INIT_ONCE_STATIC_INIT; + +static inline BOOL pni_init_once_fn(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) { + (void) InitOnce; + (void) Parameter; + (void) Context; + + initialize(); + + if (ERR_peek_error()) { + ssl_log_flush(NULL, PN_LEVEL_ERROR); + return false; + } + + return true; +} + static inline bool ensure_initialized(void) { void* dummy; - InitOnceExecuteOnce(&initialize_once, &initialize, NULL, &dummy); + InitOnceExecuteOnce(&initialize_once, &pni_init_once_fn, NULL, &dummy); return init_ok; } @@ -1740,8 +1761,6 @@ static inline bool ensure_initialized(void) { #include -static void initialize(void); - typedef pthread_mutex_t pni_mutex_t; static inline int pni_mutex_init(pni_mutex_t *m) { return pthread_mutex_init(m, NULL); } static inline int pni_mutex_lock(pni_mutex_t *m) { return pthread_mutex_lock(m); }