lib: silence LibreSSL collision warning on non-MSVC Windows

LibreSSL headers emit this warning because we included `wincrypt.h`
before them. We have to include `wincrypt.h` before OpenSSL headers
to avoid symbol collisions when using other forks. LibreSSL 3.8.2+
offers a macro to silence its warnings to avoid this issue. This patch
sets it.

This allows to stop setting this macro in curl-for-win builds.

Warnings seen with MinGW with cmake non-unity (also unity batch=30):
```
[156/219] Building C object lib/CMakeFiles/libcurl_object.dir/vtls/openssl.c.obj
In file included from lib/vtls/openssl.h:35,
                 from lib/vtls/openssl.c:53:
dep/libressl-win-x64/include/openssl/ossl_typ.h:90:2: warning: #warning overriding WinCrypt defines [-Wcpp]
   90 | #warning overriding WinCrypt defines
      |  ^~~~~~~
In file included from dep/libressl-win-x64/include/openssl/pem.h:71,
                 from dep/libressl-win-x64/include/openssl/ssl.h:151,
                 from lib/vtls/openssl.h:36:
dep/libressl-win-x64/include/openssl/x509.h:108:2: warning: #warning overriding WinCrypt defines [-Wcpp]
  108 | #warning overriding WinCrypt defines
      |  ^~~~~~~
In file included from dep/libressl-win-x64/include/openssl/x509.h:319:
dep/libressl-win-x64/include/openssl/pkcs7.h:77:2: warning: #warning overriding WinCrypt defines [-Wcpp]
   77 | #warning overriding WinCrypt defines
      |  ^~~~~~~
```

Ref: https://github.com/libressl/portable/issues/910
Ref: https://github.com/libressl/portable/pull/924
Ref: e7fe6caab2
Ref: 760ccfcc91

Closes #16273
This commit is contained in:
Viktor Szakats 2025-02-09 02:35:07 +01:00
parent 89ed161f56
commit e6ea56b9d9
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -985,10 +985,16 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
# endif
#endif
#ifdef USE_OPENSSL
/* OpenSSLv3 marks DES, MD5 and ENGINE functions deprecated but we have no
replacements (yet) so tell the compiler to not warn for them. */
#ifdef USE_OPENSSL
#define OPENSSL_SUPPRESS_DEPRECATED
# define OPENSSL_SUPPRESS_DEPRECATED
# ifdef _WIN32
/* Silence LibreSSL warnings about wincrypt.h collision. Works in 3.8.2+ */
# ifndef LIBRESSL_DISABLE_OVERRIDE_WINCRYPT_DEFINES_WARNING
# define LIBRESSL_DISABLE_OVERRIDE_WINCRYPT_DEFINES_WARNING
# endif
# endif
#endif
#if defined(CURL_INLINE)