Skip to content

Commit d12f4f9

Browse files
committed
unix: don't redefine HMAC symbols when using LibreSSL
This works around a redefinition of symbols exported by LibreSSL's libcrypto. I filed https://bugs.python.org/issue41949 upstream to track this.
1 parent b76b31f commit d12f4f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cpython-unix/build-cpython.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,27 @@ EOF
218218
sed s/__APPLE__/USE_LIBEDIT/g Modules/readline-libedit.c > tmp
219219
mv tmp Modules/readline-libedit.c
220220

221+
# Modules/_hashopenssl.c redefines some libcrypto symbols on Python 3.9 and
222+
# this makes the linker unhappy. So rename the symbols to work around.
223+
# https://bugs.python.org/issue41949.
224+
if [ "${PYTHON_MAJMIN_VERSION}" = "3.9" ]; then
225+
patch -p1 <<EOF
226+
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
227+
index adc8653773..fc9070fc21 100644
228+
--- a/Modules/_hashopenssl.c
229+
+++ b/Modules/_hashopenssl.c
230+
@@ -32,7 +32,7 @@
231+
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
232+
#endif
233+
234+
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
235+
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
236+
/* OpenSSL < 1.1.0 */
237+
#define EVP_MD_CTX_new EVP_MD_CTX_create
238+
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
239+
EOF
240+
fi
241+
221242
# Most bits look at CFLAGS. But setup.py only looks at CPPFLAGS.
222243
# So we need to set both.
223244
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC -I${TOOLS_PATH}/deps/include -I${TOOLS_PATH}/deps/include/ncursesw"

0 commit comments

Comments
 (0)