Skip to content

Commit

Permalink
unix: don't redefine HMAC symbols when using LibreSSL
Browse files Browse the repository at this point in the history
This works around a redefinition of symbols exported by LibreSSL's
libcrypto. I filed https://bugs.python.org/issue41949 upstream to
track this.
  • Loading branch information
indygreg committed Oct 6, 2020
1 parent b76b31f commit d12f4f9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ EOF
sed s/__APPLE__/USE_LIBEDIT/g Modules/readline-libedit.c > tmp
mv tmp Modules/readline-libedit.c

# Modules/_hashopenssl.c redefines some libcrypto symbols on Python 3.9 and
# this makes the linker unhappy. So rename the symbols to work around.
# https://bugs.python.org/issue41949.
if [ "${PYTHON_MAJMIN_VERSION}" = "3.9" ]; then
patch -p1 <<EOF
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index adc8653773..fc9070fc21 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -32,7 +32,7 @@
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
#endif
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
/* OpenSSL < 1.1.0 */
#define EVP_MD_CTX_new EVP_MD_CTX_create
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
EOF
fi

# Most bits look at CFLAGS. But setup.py only looks at CPPFLAGS.
# So we need to set both.
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC -I${TOOLS_PATH}/deps/include -I${TOOLS_PATH}/deps/include/ncursesw"
Expand Down

0 comments on commit d12f4f9

Please sign in to comment.