Skip to content

Commit f0abfc9

Browse files
zaniebGankra
andauthored
Enable free-threaded builds of Python 3.14 on musl (#571)
Extends #568 --------- Co-authored-by: Aria Desires <[email protected]>
1 parent a870b62 commit f0abfc9

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

ci-targets.yaml

+24-28
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,12 @@ linux:
264264
- debug
265265
- noopt
266266
- lto
267-
# freethreaded builds require mimalloc which is not available on musl yet
268-
# build_options_conditional:
269-
# - options:
270-
# - freethreaded+debug
271-
# - freethreaded+noopt
272-
# - freethreaded+lto
273-
# minimum-python-version: "3.13"
267+
build_options_conditional:
268+
- options:
269+
- freethreaded+debug
270+
- freethreaded+noopt
271+
- freethreaded+lto
272+
minimum-python-version: "3.13"
274273
run: true
275274

276275
x86_64_v2-unknown-linux-musl:
@@ -291,13 +290,12 @@ linux:
291290
- debug
292291
- noopt
293292
- lto
294-
# freethreaded builds require mimalloc which is not available on musl yet
295-
# build_options_conditional:
296-
# - options:
297-
# - freethreaded+debug
298-
# - freethreaded+noopt
299-
# - freethreaded+lto
300-
# minimum-python-version: "3.13"
293+
build_options_conditional:
294+
- options:
295+
- freethreaded+debug
296+
- freethreaded+noopt
297+
- freethreaded+lto
298+
minimum-python-version: "3.13"
301299
run: true
302300

303301
x86_64_v3-unknown-linux-musl:
@@ -318,13 +316,12 @@ linux:
318316
- debug
319317
- noopt
320318
- lto
321-
# freethreaded builds require mimalloc which is not available on musl yet
322-
# build_options_conditional:
323-
# - options:
324-
# - freethreaded+debug
325-
# - freethreaded+noopt
326-
# - freethreaded+lto
327-
# minimum-python-version: "3.13"
319+
build_options_conditional:
320+
- options:
321+
- freethreaded+debug
322+
- freethreaded+noopt
323+
- freethreaded+lto
324+
minimum-python-version: "3.13"
328325
run: true
329326

330327
x86_64_v4-unknown-linux-musl:
@@ -345,13 +342,12 @@ linux:
345342
- debug
346343
- noopt
347344
- lto
348-
# freethreaded builds require mimalloc which is not available on musl yet
349-
# build_options_conditional:
350-
# - options:
351-
# - freethreaded+debug
352-
# - freethreaded+noopt
353-
# - freethreaded+lto
354-
# minimum-python-version: "3.13"
345+
build_options_conditional:
346+
- options:
347+
- freethreaded+debug
348+
- freethreaded+noopt
349+
- freethreaded+lto
350+
minimum-python-version: "3.13"
355351
run: true
356352

357353
windows:

cpython-unix/build-cpython.sh

+18-2
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,22 @@ if [ "${CC}" = "musl-clang" ]; then
401401
done
402402
fi
403403

404+
# To enable mimalloc (which is hard requirement for free-threaded versions, but preferred in
405+
# general), we need `stdatomic.h` which is not provided by musl. It's a part of the include files
406+
# that are part of clang. But musl-clang eliminates them from the default include path. So copy it
407+
# into place.
408+
if [[ "${CC}" = "musl-clang" && -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]]; then
409+
for h in /tools/${TOOLCHAIN}/lib/clang/*/include/stdatomic.h; do
410+
filename=$(basename "$h")
411+
if [ -e "/tools/host/include/${filename}" ]; then
412+
echo "${filename} already exists; don't need to copy!"
413+
exit 1
414+
fi
415+
cp "$h" /tools/host/include/
416+
done
417+
fi
418+
419+
404420
if [ -n "${CPYTHON_STATIC}" ]; then
405421
CFLAGS="${CFLAGS} -static"
406422
CPPFLAGS="${CPPFLAGS} -static"
@@ -416,8 +432,8 @@ if [ -n "${CPYTHON_DEBUG}" ]; then
416432
fi
417433

418434
# Explicitly enable mimalloc on 3.13+, it's already included by default but with this it'll fail
419-
# if it's missing from the system. The musl builds do not supprt mimalloc yet.
420-
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" && "${CC}" != "musl-clang" ]]; then
435+
# if it's missing from the system.
436+
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]]; then
421437
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-mimalloc"
422438
fi
423439

0 commit comments

Comments
 (0)