Skip to content

Commit 7c55af6

Browse files
committed
unix: remove support for building with LibreSSL
Python 3.10 goes all in on requiring OpenSSL 1.1.1 and it requires some patches to build with LibreSSL due to newer functionality from 1.1.1 not yet present in LibreSSL. The main reason we introduced support for LibreSSL in the first place was because we couldn't get an older version to compile against musl libc. It appears the latest OpenSSL now compiles fine. We were only using LibreSSL on the musl builds: everything else was using OpenSSL. (Way back when we shipped LibreSSL as the default SSL implementation but reverted this when it was clear CPython really wanted OpenSSL.) So the practical impact of this change is musl libc distributions switch from LibreSSL to OpenSSL.
1 parent b97b31e commit 7c55af6

File tree

12 files changed

+22
-266
lines changed

12 files changed

+22
-266
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,7 @@ jobs:
298298

299299
- name: Build
300300
run: |
301-
if [ "${{ matrix.build.target_triple }}" = "x86_64-unknown-linux-musl" ]; then
302-
EXTRA_ARGS=--libressl
303-
else
304-
EXTRA_ARGS=
305-
fi
306-
307-
./build-linux.py --skip-toolchain --target-triple ${{ matrix.build.target_triple }} --python ${{ matrix.build.py }} --optimizations ${{ matrix.build.optimizations }} ${EXTRA_ARGS}
301+
./build-linux.py --skip-toolchain --target-triple ${{ matrix.build.target_triple }} --python ${{ matrix.build.py }} --optimizations ${{ matrix.build.optimizations }}
308302
309303
- name: Validate Distribution
310304
run: |

LICENSE.libressl.txt

Lines changed: 0 additions & 132 deletions
This file was deleted.

cpython-unix/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ LIBEDIT_DEPENDS = \
184184
$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar: $(LIBEDIT_DEPENDS)
185185
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) libedit
186186

187-
$(OUTDIR)/libressl-$(LIBRESSL_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-libressl.sh
188-
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) libressl
189-
190187
$(OUTDIR)/patchelf-$(PATCHELF_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-patchelf.sh
191188
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) patchelf
192189

@@ -258,7 +255,6 @@ PYTHON_DEPENDS := \
258255
$(if $(NEED_GETTEXT),$(OUTDIR)/gettext-$(GETTEXT_VERSION)-$(PACKAGE_SUFFIX).tar) \
259256
$(if $(NEED_LIBEDIT),$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar) \
260257
$(if $(NEED_LIBFFI),$(OUTDIR)/libffi-$(LIBFFI_VERSION)-$(PACKAGE_SUFFIX).tar) \
261-
$(if $(NEED_LIBRESSL),$(OUTDIR)/libressl-$(LIBRESSL_VERSION)-$(PACKAGE_SUFFIX).tar) \
262258
$(if $(NEED_NCURSES),$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PACKAGE_SUFFIX).tar) \
263259
$(if $(NEED_OPENSSL),$(OUTDIR)/openssl-$(OPENSSL_VERSION)-$(PACKAGE_SUFFIX).tar) \
264260
$(if $(NEED_PATCHELF),$(OUTDIR)/patchelf-$(PATCHELF_VERSION)-$(PACKAGE_SUFFIX).tar) \

cpython-unix/build-cpython.sh

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

539-
# Modules/_hashopenssl.c redefines some libcrypto symbols on Python 3.9 and
540-
# this makes the linker unhappy. So rename the symbols to work around.
541-
# https://bugs.python.org/issue41949.
542-
if [ "${PYTHON_MAJMIN_VERSION}" = "3.9" ]; then
543-
patch -p1 <<EOF
544-
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
545-
index adc8653773..fc9070fc21 100644
546-
--- a/Modules/_hashopenssl.c
547-
+++ b/Modules/_hashopenssl.c
548-
@@ -32,7 +32,7 @@
549-
# error "OPENSSL_THREADS is not defined, Python requires thread-safe OpenSSL"
550-
#endif
551-
552-
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
553-
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
554-
/* OpenSSL < 1.1.0 */
555-
#define EVP_MD_CTX_new EVP_MD_CTX_create
556-
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
557-
EOF
558-
fi
559-
560539
# iOS doesn't have system(). Teach posixmodule.c about that.
561540
if [ "${PYTHON_MAJMIN_VERSION}" != "3.8" ]; then
562541
patch -p1 <<EOF

cpython-unix/build-libressl.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

cpython-unix/build-main.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ def main():
5858
default="noopt",
5959
help="Optimizations to apply when compiling Python",
6060
)
61-
62-
parser.add_argument(
63-
"--libressl", action="store_true", help="Build LibreSSL instead of OpenSSL"
64-
)
6561
parser.add_argument(
6662
"--python",
6763
choices={"cpython-3.8", "cpython-3.9", "cpython-3.10"},
@@ -113,8 +109,6 @@ def main():
113109
env["PYBUILD_HOST_PLATFORM"] = host_platform
114110
env["PYBUILD_TARGET_TRIPLE"] = target_triple
115111
env["PYBUILD_OPTIMIZATIONS"] = args.optimizations
116-
if args.libressl or musl:
117-
env["PYBUILD_LIBRESSL"] = "1"
118112
if musl:
119113
env["PYBUILD_MUSL"] = "1"
120114
if args.break_on_failure:

cpython-unix/build.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ def python_build_info(
499499
config_c_in,
500500
setup_dist,
501501
setup_local,
502-
libressl=False,
503502
):
504503
"""Obtain build metadata for the Python distribution."""
505504

@@ -626,12 +625,7 @@ def process_setup_line(line, variant=None):
626625
"variant": d["variant"],
627626
}
628627

629-
if libressl:
630-
ignore_keys = {"openssl"}
631-
else:
632-
ignore_keys = {"libressl"}
633-
634-
add_licenses_to_extension_entry(entry, ignore_keys=ignore_keys)
628+
add_licenses_to_extension_entry(entry)
635629

636630
bi["extensions"].setdefault(extension, []).append(entry)
637631

@@ -713,7 +707,6 @@ def build_cpython(
713707
target_triple,
714708
optimizations,
715709
dest_archive,
716-
libressl=False,
717710
version=None,
718711
):
719712
"""Build CPython in a Docker image'"""
@@ -867,7 +860,6 @@ def build_cpython(
867860
config_c_in,
868861
setup_dist_content,
869862
setup_local_content,
870-
libressl=libressl,
871863
),
872864
"licenses": entry["licenses"],
873865
"license_path": "licenses/LICENSE.cpython.txt",
@@ -1046,7 +1038,6 @@ def main():
10461038
"kbproto",
10471039
"libffi",
10481040
"libpthread-stubs",
1049-
"libressl",
10501041
"ncurses",
10511042
"openssl",
10521043
"patchelf",
@@ -1180,7 +1171,6 @@ def main():
11801171
target_triple=target_triple,
11811172
optimizations=optimizations,
11821173
dest_archive=dest_archive,
1183-
libressl="PYBUILD_LIBRESSL" in os.environ,
11841174
version=action.split("-")[1],
11851175
)
11861176

0 commit comments

Comments
 (0)