From 1191874c5ef51b8ac400928c7897f967c5813d1c Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 6 Apr 2025 14:47:50 +0200 Subject: [PATCH] Implemented workaround for QuicTLS "undefined reference to `gcm_gmult_4bit_*" bug on x86 platform. --- build.sh | 5 +++-- patch/quictls_x86_fix.diff | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 patch/quictls_x86_fix.diff diff --git a/build.sh b/build.sh index b4e8f0a..4876eb9 100644 --- a/build.sh +++ b/build.sh @@ -57,7 +57,7 @@ fi case "${CC_TARGET}" in i686-*) readonly MY_CPU=x86 - readonly MY_MARCH=pentium-mmx + readonly MY_MARCH=i586 readonly MY_MTUNE=generic ;; x86_64-*) @@ -194,7 +194,7 @@ CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I$ popd # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# OpenSSL +# OpenSSL / QuicTLS # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ printf "\n==================== OpenSSL ====================\n\n" readonly OSSL_DIR="${WORK_DIR}/openssl" @@ -203,6 +203,7 @@ tar -xvf "${PKGS_DIR}/openssl.tar.gz" --strip-components=1 -C "${OSSL_DIR}" [[ "${MY_CPU}" == "x64" ]] && readonly ossl_flag="no-sse2" || readonly ossl_flag="386" [[ "${MY_CPU}" == "x64" ]] && readonly ossl_mngw="mingw64" || readonly ossl_mngw="mingw" pushd "${OSSL_DIR}" +patch -p1 -b < "${BASE_DIR}/patch/quictls_x86_fix.diff" ./Configure no-hw no-shared no-engine no-capieng no-dso zlib ${ossl_flag} -static -march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I"${DEPS_DIR}/include" -L"${DEPS_DIR}/lib" --prefix="${DEPS_DIR}" --libdir="lib" ${ossl_mngw} make build_libs && make install_dev popd diff --git a/patch/quictls_x86_fix.diff b/patch/quictls_x86_fix.diff new file mode 100644 index 0000000..0978bfe --- /dev/null +++ b/patch/quictls_x86_fix.diff @@ -0,0 +1,28 @@ + crypto/modes/gcm128.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c +index b970209..d4983ce 100644 +--- a/crypto/modes/gcm128.c ++++ b/crypto/modes/gcm128.c +@@ -337,9 +337,9 @@ void gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp, + # endif + + #if defined(GHASH_ASM) || defined(OPENSSL_CPUID_OBJ) +-# if defined(__i386) || defined(__i386__) || \ ++# if defined(__i389) || defined(__i389__) || \ + defined(__x86_64) || defined(__x86_64__) || \ +- defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) ++ defined(_M_IX89) || defined(_M_AMD64) || defined(_M_X64) + # define GHASH_ASM_X86_OR_64 + + void gcm_init_clmul(u128 Htable[16], const u64 Xi[2]); +@@ -358,7 +358,7 @@ void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *inp, + size_t len); + # endif + +-# if defined(__i386) || defined(__i386__) || defined(_M_IX86) ++# if defined(__i389) || defined(__i389__) || defined(_M_IX89) + # define GHASH_ASM_X86 + void gcm_gmult_4bit_mmx(u64 Xi[2], const u128 Htable[16]); + void gcm_ghash_4bit_mmx(u64 Xi[2], const u128 Htable[16], const u8 *inp,