void conflict with boringssl

This commit is contained in:
Xuan Son Nguyen
2026-08-17 20:02:56 +02:00
parent 9ae5bba0fe
commit 15eeceabcb
5 changed files with 51 additions and 7 deletions
+4 -1
View File
@@ -18,13 +18,16 @@ extern "C" {
#endif
#include "xxhash/xxhash.h"
#include "sha1/sha1.h"
#include "sha256/sha256.h"
#ifdef __cplusplus
}
#endif
// sha1 is compiled as C++ and lives in a namespace, see scripts/sync_vendor.py
#include "sha1/sha1.h"
using namespace vendor_hash;
// uuid.uuid5(uuid.NAMESPACE_URL, 'en.wikipedia.org/wiki/Llama.cpp')
#define UUID_NAMESPACE_LLAMA_CPP "ef001206-dadc-5f6d-a15f-3359e577d4e5"
+38
View File
@@ -56,6 +56,44 @@ patches = {
' && (defined(_MSC_VER) && (_MSC_VER >= 1000) || !defined(_MSC_VER)) /* >= C11 */\n'
)],
# sha1 exports a bare "SHA1" symbol, which clashes with the boringssl one at link time.
# we compile it as C++ (see vendor/hash/CMakeLists.txt) and put it in a namespace.
"vendor/hash/sha1/sha1.h": [
(
'#if defined(__cplusplus)\n'
'extern "C" {\n'
'#endif\n',
'namespace vendor_hash {\n'
),
(
'#if defined(__cplusplus)\n'
'}\n'
'#endif\n',
'} // namespace vendor_hash\n'
),
],
"vendor/hash/sha1/sha1.c": [
(
'#include "sha1.h"\n',
'#include "sha1.h"\n'
'\n'
'namespace vendor_hash {\n'
),
(
' SHA1Final((unsigned char *)hash_out, &ctx);\n'
'}\n',
' SHA1Final((unsigned char *)hash_out, &ctx);\n'
'}\n'
'\n'
'} // namespace vendor_hash\n'
),
],
# silence a maybe-uninitialized warning
"vendor/hash/sha256/sha256.c": [(
" uint32_t W[16];\n",
+3
View File
@@ -26,5 +26,8 @@ else()
endif()
set_source_files_properties(${VENDOR_SRCS} PROPERTIES COMPILE_OPTIONS ${NO_WARN_FLAG})
# sha1 lives in a namespace to avoid a clash with boringssl, see scripts/sync_vendor.py
set_source_files_properties(sha1/sha1.c PROPERTIES LANGUAGE CXX)
# sha256.c includes "rotate-bits/rotate-bits.h", so consumers get this dir too
target_include_directories(${TARGET} PUBLIC .)
+4
View File
@@ -25,6 +25,8 @@ A million repetitions of "a"
#include "sha1.h"
namespace vendor_hash {
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
@@ -293,3 +295,5 @@ void SHA1(
SHA1Final((unsigned char *)hash_out, &ctx);
}
} // namespace vendor_hash
+2 -6
View File
@@ -9,9 +9,7 @@
#include "stdint.h"
#if defined(__cplusplus)
extern "C" {
#endif
namespace vendor_hash {
typedef struct
{
@@ -45,8 +43,6 @@ void SHA1(
const char *str,
uint32_t len);
#if defined(__cplusplus)
}
#endif
} // namespace vendor_hash
#endif /* SHA1_H */