Skip to content

Commit

Permalink
WIP CPython 3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
indygreg committed Oct 1, 2023
1 parent a8c0808 commit 0245628
Show file tree
Hide file tree
Showing 18 changed files with 648 additions and 28 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'aarch64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'aarch64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'aarch64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'lto'

# macOS on Intel hardware. This is pretty straightforward. We exclude
# noopt because it doesn't provide any compelling advantages over PGO
# or LTO builds.
Expand Down Expand Up @@ -137,6 +147,19 @@ jobs:
- target_triple: 'x86_64-apple-darwin'
py: 'cpython-3.11'
optimizations: 'pgo+lto'

- target_triple: 'x86_64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'x86_64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'lto'
- target_triple: 'x86_64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'pgo'
- target_triple: 'x86_64-apple-darwin'
py: 'cpython-3.12'
optimizations: 'pgo+lto'
needs:
- pythonbuild
runs-on: 'macos-11'
Expand Down
180 changes: 180 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.9'
Expand Down Expand Up @@ -188,6 +198,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.9'
Expand Down Expand Up @@ -219,6 +239,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -250,6 +280,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -281,6 +321,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -312,6 +362,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -343,6 +403,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# We don't publish noopt builds when PGO is available.
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.8'
Expand Down Expand Up @@ -412,6 +482,23 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'
run: true
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -463,6 +550,23 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'
run: true
- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -514,6 +618,23 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'
run: true
- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'pgo+lto'
run: true

# GitHub Actions runners don't support x86-64-v4 so we can't PGO.
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -546,6 +667,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.12'
optimizations: 'lto'

# musl doesn't support PGO.
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.8'
Expand Down Expand Up @@ -599,6 +730,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -638,6 +782,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -677,6 +834,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -707,6 +877,16 @@ jobs:
py: 'cpython-3.11'
optimizations: 'lto'

- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'debug'
- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'noopt'
- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.12'
optimizations: 'lto'

needs:
- pythonbuild
- image
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- 'cpython-3.9'
- 'cpython-3.10'
- 'cpython-3.11'
- 'cpython-3.12'
vcvars:
- 'vcvars32.bat'
- 'vcvars64.bat'
Expand Down
7 changes: 7 additions & 0 deletions cpython-unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ $(OUTDIR)/cpython-3.10-$(CPYTHON_3.10_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HO
$(OUTDIR)/cpython-3.11-$(CPYTHON_3.11_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HOST_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.11-host

$(OUTDIR)/cpython-3.12-$(CPYTHON_3.12_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HOST_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.12-host


PYTHON_DEPENDS := \
$(PYTHON_SUPPORT_FILES) \
$(OUTDIR)/versions/VERSION.pip \
Expand Down Expand Up @@ -302,3 +306,6 @@ $(OUTDIR)/cpython-$(CPYTHON_3.10_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DE

$(OUTDIR)/cpython-$(CPYTHON_3.11_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.11

$(OUTDIR)/cpython-$(CPYTHON_3.12_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.12
20 changes: 18 additions & 2 deletions cpython-unix/build-cpython-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,26 @@ case "${BUILD_TRIPLE}" in
;;
esac

EXTRA_CONFIGURE_FLAGS=

# We may not have a usable libraries to build against. Forcefully disable extensions
# that may not build.
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_12}" ]; then
for m in _hashlib _ssl; do
EXTRA_CONFIGURE_FLAGS="${EXTRA_CONFIGURE_FLAGS} py_cv_module_${m}=n/a"
done
fi

CC="${HOST_CC}" CXX="${HOST_CXX}" CFLAGS="${EXTRA_HOST_CFLAGS}" CPPFLAGS="${EXTRA_HOST_CFLAGS}" LDFLAGS="${EXTRA_HOST_LDFLAGS}" ./configure \
--prefix /tools/host \
--without-ensurepip
--without-ensurepip \
${EXTRA_CONFIGURE_FLAGS}

make -j "${NUM_CPUS}" install DESTDIR=${ROOT}/out
# Ideally we'd do `make install` here and be done with it. But there's a race
# condition in CPython's build system related to directory creation that gets
# tickled when we do this. https://github.com/python/cpython/issues/109796.
make -j "${NUM_CPUS}"
make -j sharedinstall DESTDIR=${ROOT}/out
make -j install DESTDIR=${ROOT}/out

popd
Loading

0 comments on commit 0245628

Please sign in to comment.