Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbedTLS: Add patch to fix build errors with some MSVC versions #90535

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ File extracted from upstream release tarball:
- The `LICENSE` file (edited to keep only the Apache 2.0 variant)
- Applied the patch `no-flexible-arrays.diff` to fix Windows build (see
upstream GH-9020)
- Applied the patch `msvc-redeclaration-bug.diff` to fix a compilation error
with some MSVC versions
- Added 2 files `godot_core_mbedtls_platform.c` and `godot_core_mbedtls_config.h`
providing configuration for light bundling with core
- Added the file `godot_module_mbedtls_config.h` to customize the build
Expand Down
14 changes: 14 additions & 0 deletions thirdparty/mbedtls/include/psa/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ psa_status_t psa_crypto_init(void);

/** Return an initial value for a key attributes structure.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_attributes_t psa_key_attributes_init(void);
#endif

/** Declare a key as persistent and set its key identifier.
*
Expand Down Expand Up @@ -333,7 +335,9 @@ static void psa_set_key_bits(psa_key_attributes_t *attributes,
*
* \return The key type stored in the attribute structure.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes);
#endif

/** Retrieve the key size from key attributes.
*
Expand Down Expand Up @@ -936,7 +940,9 @@ typedef struct psa_hash_operation_s psa_hash_operation_t;

/** Return an initial value for a hash operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_hash_operation_t psa_hash_operation_init(void);
#endif

/** Set up a multipart hash operation.
*
Expand Down Expand Up @@ -1295,7 +1301,9 @@ typedef struct psa_mac_operation_s psa_mac_operation_t;

/** Return an initial value for a MAC operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_mac_operation_t psa_mac_operation_init(void);
#endif

/** Set up a multipart MAC calculation operation.
*
Expand Down Expand Up @@ -1708,7 +1716,9 @@ typedef struct psa_cipher_operation_s psa_cipher_operation_t;

/** Return an initial value for a cipher operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_cipher_operation_t psa_cipher_operation_init(void);
#endif

/** Set the key for a multipart symmetric encryption operation.
*
Expand Down Expand Up @@ -2226,7 +2236,9 @@ typedef struct psa_aead_operation_s psa_aead_operation_t;

/** Return an initial value for an AEAD operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_aead_operation_t psa_aead_operation_init(void);
#endif

/** Set the key for a multipart authenticated encryption operation.
*
Expand Down Expand Up @@ -3213,7 +3225,9 @@ typedef struct psa_key_derivation_s psa_key_derivation_operation_t;

/** Return an initial value for a key derivation operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
#endif

/** Set up a key derivation operation.
*
Expand Down
4 changes: 4 additions & 0 deletions thirdparty/mbedtls/include/psa/crypto_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,9 @@ typedef struct psa_pake_cipher_suite_s psa_pake_cipher_suite_t;

/** Return an initial value for a PAKE cipher suite object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_pake_cipher_suite_t psa_pake_cipher_suite_init(void);
#endif

/** Retrieve the PAKE algorithm from a PAKE cipher suite.
*
Expand Down Expand Up @@ -1048,7 +1050,9 @@ typedef struct psa_jpake_computation_stage_s psa_jpake_computation_stage_t;

/** Return an initial value for a PAKE operation object.
*/
#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_pake_operation_t psa_pake_operation_init(void);
#endif

/** Get the length of the password in bytes from given inputs.
*
Expand Down
98 changes: 98 additions & 0 deletions thirdparty/mbedtls/patches/msvc-redeclaration-bug.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
diff --git a/thirdparty/mbedtls/include/psa/crypto.h b/thirdparty/mbedtls/include/psa/crypto.h
index 92f9c824e9..1cc2e7e729 100644
--- a/thirdparty/mbedtls/include/psa/crypto.h
+++ b/thirdparty/mbedtls/include/psa/crypto.h
@@ -107,7 +107,9 @@ psa_status_t psa_crypto_init(void);

/** Return an initial value for a key attributes structure.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_attributes_t psa_key_attributes_init(void);
+#endif

/** Declare a key as persistent and set its key identifier.
*
@@ -333,7 +335,9 @@ static void psa_set_key_bits(psa_key_attributes_t *attributes,
*
* \return The key type stored in the attribute structure.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes);
+#endif

/** Retrieve the key size from key attributes.
*
@@ -936,7 +940,9 @@ typedef struct psa_hash_operation_s psa_hash_operation_t;

/** Return an initial value for a hash operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_hash_operation_t psa_hash_operation_init(void);
+#endif

/** Set up a multipart hash operation.
*
@@ -1295,7 +1301,9 @@ typedef struct psa_mac_operation_s psa_mac_operation_t;

/** Return an initial value for a MAC operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_mac_operation_t psa_mac_operation_init(void);
+#endif

/** Set up a multipart MAC calculation operation.
*
@@ -1708,7 +1716,9 @@ typedef struct psa_cipher_operation_s psa_cipher_operation_t;

/** Return an initial value for a cipher operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_cipher_operation_t psa_cipher_operation_init(void);
+#endif

/** Set the key for a multipart symmetric encryption operation.
*
@@ -2226,7 +2236,9 @@ typedef struct psa_aead_operation_s psa_aead_operation_t;

/** Return an initial value for an AEAD operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_aead_operation_t psa_aead_operation_init(void);
+#endif

/** Set the key for a multipart authenticated encryption operation.
*
@@ -3213,7 +3225,9 @@ typedef struct psa_key_derivation_s psa_key_derivation_operation_t;

/** Return an initial value for a key derivation operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
+#endif

/** Set up a key derivation operation.
*
diff --git a/thirdparty/mbedtls/include/psa/crypto_extra.h b/thirdparty/mbedtls/include/psa/crypto_extra.h
index 6ed1f6c43a..2686b9d74d 100644
--- a/thirdparty/mbedtls/include/psa/crypto_extra.h
+++ b/thirdparty/mbedtls/include/psa/crypto_extra.h
@@ -915,7 +915,9 @@ typedef struct psa_pake_cipher_suite_s psa_pake_cipher_suite_t;

/** Return an initial value for a PAKE cipher suite object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_pake_cipher_suite_t psa_pake_cipher_suite_init(void);
+#endif

/** Retrieve the PAKE algorithm from a PAKE cipher suite.
*
@@ -1048,7 +1050,9 @@ typedef struct psa_jpake_computation_stage_s psa_jpake_computation_stage_t;

/** Return an initial value for a PAKE operation object.
*/
+#if !(defined(__cplusplus) && defined(_MSC_VER))
static psa_pake_operation_t psa_pake_operation_init(void);
+#endif

/** Get the length of the password in bytes from given inputs.
*
Loading