Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@ if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_10}" ]; then
patch -p1 -i ${ROOT}/patch-configure-crypt-no-modify-libs.patch
fi

# Backport Tcl/Tk 9.0 support from 3.12 to Python 3.10 and 3.11
if [ "${PYTHON_MAJMIN_VERSION}" = "3.10" ]; then
# git checkout v3.10.19
# git cherry-pick 625887e6 27cbeb08 d4680b9e ec139c8f
# git diff v3.10.19 Modules/_tkinter.c > patch-tkinter-backport-tcl-9-310.patch
patch -p1 -i ${ROOT}/patch-tkinter-backport-tcl-9-310.patch
fi
if [ "${PYTHON_MAJMIN_VERSION}" = "3.11" ]; then
# git checkout v3.11.14
# git cherry-pick 625887e6 27cbeb08 d4680b9e ec139c8f
# git diff v3.11.14 Modules/_tkinter.c > patch-tkinter-backport-tcl-9-311.patch
patch -p1 -i ${ROOT}/patch-tkinter-backport-tcl-9-311.patch
fi

# BOLT instrumented binaries segfault in some test_embed tests for unknown reasons.
# On 3.12 (minimum BOLT version), the segfault causes the test harness to
# abort and BOLT optimization uses the partial test results. On 3.13, the segfault
Expand Down Expand Up @@ -1257,11 +1271,11 @@ fi
# And prune libraries we never reference.
rm -f ${ROOT}/out/python/build/lib/{libdb-6.0,libxcb-*,libX11-xcb}.a

if [ -d "${TOOLS_PATH}/deps/lib/tcl8" ]; then
if [ -d "${TOOLS_PATH}/deps/lib/tk9.0" ]; then
# Copy tcl/tk resources needed by tkinter.
mkdir ${ROOT}/out/python/install/lib/tcl
mkdir ${ROOT}/out/python/install/lib/tk9.0
# Keep this list in sync with tcl_library_paths.
for source in ${TOOLS_PATH}/deps/lib/{itcl4.2.4,tcl8,tcl8.6,thread2.8.9,tk8.6}; do
for source in ${TOOLS_PATH}/deps/lib/{itcl4.3.5,thread3.0.4,tk9.0}; do
cp -av $source ${ROOT}/out/python/install/lib/
done

Expand Down
37 changes: 27 additions & 10 deletions cpython-unix/build-tcl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,45 @@ pushd tcl${TCL_VERSION}
EXTRA_CONFIGURE=

if [ -n "${STATIC}" ]; then
if echo "${TARGET_TRIPLE}" | grep -q -- "-unknown-linux-musl"; then
# tcl will use an internal implementation of certain POSIX function when
# cross-compiling. The implementation of strtoul create multiple definitions
# when linked against the static musl libc. Exclude the internal implementation.
EXTRA_CONFIGURE="${EXTRA_CONFIGURE} tcl_cv_strtoul_unbroken=ok"
fi

patch -p1 << 'EOF'
diff --git a/unix/Makefile.in b/unix/Makefile.in
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -1813,7 +1813,7 @@ configure-packages:
@@ -2062,7 +2062,7 @@ configure-packages:
$$i/configure --with-tcl8 --with-tcl=../.. \
--with-tclinclude=$(GENERIC_DIR) \
$(PKG_CFG_ARGS) --libdir=$(PACKAGE_DIR) \
- --enable-shared; ) || exit $$?; \
+ --enable-shared=no; ) || exit $$?; \
fi; \
mkdir -p $(PKG_DIR)/$$pkg; \
if [ ! -f $(PKG_DIR)/$$pkg/Makefile ] ; then \
@@ -2070,7 +2070,7 @@ configure-packages:
$$i/configure --with-tcl=../.. \
--with-tclinclude=$(GENERIC_DIR) \
$(PKG_CFG_ARGS) --libdir=$(PACKAGE_DIR) \
- --enable-shared --enable-threads; ) || exit $$?; \
+ --enable-shared=no --enable-threads; ) || exit $$?; \
- --enable-shared; ) || exit $$?; \
+ --enable-shared=no; ) || exit $$?; \
fi; \
fi; \
fi; \
EOF
fi

# Disable the use of fts64_* functions on the 32-bit armv7 platform as these
# functions are not available in glibc 2.17
if [[ ${TARGET_TRIPLE} = armv7* ]]; then
EXTRA_CONFIGURE="${EXTRA_CONFIGURE} tcl_cv_flag__file_offset_bits=no"
fi

# musl does not include queue.h
# https://wiki.musl-libc.org/faq#Q:-Why-is-%3Ccode%3Esys/queue.h%3C/code%3E-not-included?
# It is a self contained header file, use a copy from the container.
# https://core.tcl-lang.org/tcl/tktview/3ff2d724d03ba7d6edb8
if [ "${CC}" = "musl-clang" ]; then
cp /usr/include/$(uname -m)-linux-gnu/sys/queue.h /tools/host/include/sys
fi

# Remove packages we don't care about and can pull in unwanted symbols.
rm -rf pkgs/sqlite* pkgs/tdbc*

Expand All @@ -62,6 +78,7 @@ CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
--prefix=/tools/deps \
--enable-shared"${STATIC:+=no}" \
--enable-threads \
--disable-zipfs \
${EXTRA_CONFIGURE}

make -j ${NUM_CPUS} DYLIB_INSTALL_DIR=@rpath
Expand Down
3 changes: 2 additions & 1 deletion cpython-unix/build-tk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
--with-tcl=${TOOLS_PATH}/deps/lib \
--enable-shared"${STATIC:+=no}" \
--enable-threads \
--disable-zipfs \
${EXTRA_CONFIGURE_FLAGS}

# Remove wish, since we don't need it.
Expand All @@ -48,7 +49,7 @@ if [[ "${PYBUILD_PLATFORM}" = macos* ]]; then
else
sed_args=(-i)
fi
sed "${sed_args[@]}" 's/all: binaries libraries doc/all: libraries/' Makefile
sed "${sed_args[@]}" 's/all: binaries libraries/all: libraries/' Makefile
sed "${sed_args[@]}" 's/install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE) ${WISH_EXE}/install-binaries: $(TK_STUB_LIB_FILE) $(TK_LIB_FILE)/' Makefile

# We are statically linking libX11, and static libraries do not carry
Expand Down
8 changes: 3 additions & 5 deletions cpython-unix/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,9 @@ def build_cpython(

python_info["tcl_library_path"] = "install/lib"
python_info["tcl_library_paths"] = [
"itcl4.2.4",
"tcl8",
"tcl8.6",
"thread2.8.7",
"tk8.6",
"itcl4.3.5",
"thread3.0.4",
"tk9.0",
]

if "-apple" in target_triple:
Expand Down
4 changes: 2 additions & 2 deletions cpython-unix/extension-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ _tkinter:
- include/X11
build-mode: shared
links:
- tcl8.6
- tk8.6
- tcl9.0
- tcl9tk9.0
links-conditional:
- name: X11
targets:
Expand Down
Loading
Loading