Skip to content

Commit 3910246

Browse files
committed
Build libtcl, libtk, and _tkinter as shared objects
1 parent 98ed871 commit 3910246

File tree

5 files changed

+15
-39
lines changed

5 files changed

+15
-39
lines changed

cpython-unix/build-cpython.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ sed "${sed_args[@]}" "s|/tools/host|${TOOLS_PATH}/host|g" ${TOOLS_PATH}/host/sha
4444
# We force linking of external static libraries by removing the shared
4545
# libraries. This is hacky. But we're building in a temporary container
4646
# and it gets the job done.
47-
find ${TOOLS_PATH}/deps -name '*.so*' -exec rm {} \;
47+
find ${TOOLS_PATH}/deps -name '*.so*' -a \! \( -name 'libtcl*.so*' -or -name 'libtk*.so*' \) -exec rm {} \;
4848

4949
tar -xf Python-${PYTHON_VERSION}.tar.xz
5050

@@ -1253,6 +1253,7 @@ if [ -d "${TOOLS_PATH}/deps/lib/tcl8" ]; then
12531253

12541254
if [[ "${PYBUILD_PLATFORM}" != macos* ]]; then
12551255
cp -av ${TOOLS_PATH}/deps/lib/Tix8.4.3 ${ROOT}/out/python/install/lib/
1256+
cp -av ${TOOLS_PATH}/deps/lib/lib*.so ${ROOT}/out/python/install/lib/
12561257
fi
12571258
fi
12581259

cpython-unix/build-tcl.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ if [ -n "${STATIC}" ]; then
2020
# `checking whether musl-clang accepts -g...` fails with a duplicate definition error
2121
TARGET_TRIPLE="$(echo "${TARGET_TRIPLE}" | sed -e 's/-unknown-linux-musl/-unknown-linux-gnu/g')"
2222
fi
23-
fi
2423

25-
patch -p1 << 'EOF'
24+
patch -p1 << 'EOF'
2625
diff --git a/unix/Makefile.in b/unix/Makefile.in
2726
--- a/unix/Makefile.in
2827
+++ b/unix/Makefile.in
@@ -36,6 +35,7 @@ diff --git a/unix/Makefile.in b/unix/Makefile.in
3635
fi; \
3736
fi; \
3837
EOF
38+
fi
3939

4040
# Remove packages we don't care about and can pull in unwanted symbols.
4141
rm -rf pkgs/sqlite* pkgs/tdbc*
@@ -48,12 +48,14 @@ CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${EXTRA_TARGET_LDFLAGS}" ./conf
4848
--build=${BUILD_TRIPLE} \
4949
--host=${TARGET_TRIPLE} \
5050
--prefix=/tools/deps \
51-
--enable-shared=no \
51+
--enable-shared"${STATIC:+=no}" \
5252
--enable-threads
5353

5454
make -j ${NUM_CPUS}
5555
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
5656
make -j ${NUM_CPUS} install-private-headers DESTDIR=${ROOT}/out
5757

58-
# For some reason libtcl*.a have weird permissions. Fix that.
59-
chmod 644 ${ROOT}/out/tools/deps/lib/libtcl*.a
58+
if [ -n "${STATIC}" ]; then
59+
# For some reason libtcl*.a have weird permissions. Fix that.
60+
chmod 644 ${ROOT}/out/tools/deps/lib/libtcl*.a
61+
fi

cpython-unix/build-tk.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
3131
--host=${TARGET_TRIPLE} \
3232
--prefix=/tools/deps \
3333
--with-tcl=${TOOLS_PATH}/deps/lib \
34-
--enable-shared=no \
34+
--enable-shared"${STATIC:+=no}" \
3535
--enable-threads \
3636
${EXTRA_CONFIGURE_FLAGS}
3737

@@ -54,6 +54,8 @@ make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
5454
make -j ${NUM_CPUS} install-private-headers DESTDIR=${ROOT}/out
5555

5656
# For some reason libtk*.a have weird permissions. Fix that.
57-
chmod 644 /${ROOT}/out/tools/deps/lib/libtk*.a
57+
if [ -n "${STATIC}" ]; then
58+
chmod 644 /${ROOT}/out/tools/deps/lib/libtk*.a
59+
fi
5860

5961
rm ${ROOT}/out/tools/deps/bin/wish*

cpython-unix/extension-modules.yml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -679,40 +679,11 @@ _tkinter:
679679
- WITH_APPINIT
680680
includes-deps:
681681
- include/X11
682+
build-mode: shared
682683
links:
683684
- tcl8.6
684685
- tk8.6
685686

686-
# Without -ObjC, we get a crash: -[TKApplication tkProcessEvent:]: unrecognized selector sent to instance.
687-
# See also https://core.tcl-lang.org/tk/tktview/85f316beb15108ac43b03fa6c8608e31f3ae5f92.
688-
# This is apparently an issue with static linking Objective-C binaries.
689-
linker-args:
690-
- args: ["-ObjC"]
691-
targets:
692-
- .*-apple-darwin
693-
links-conditional:
694-
- name: X11
695-
targets:
696-
- .*-unknown-linux-.*
697-
- name: xcb
698-
targets:
699-
- .*-unknown-linux-.*
700-
- name: Xau
701-
targets:
702-
- .*-unknown-linux-.*
703-
# Many of these are dependencies of libtcl and libtk.
704-
frameworks:
705-
- AppKit
706-
- ApplicationServices
707-
- Carbon
708-
- Cocoa
709-
- CoreFoundation
710-
- CoreServices
711-
- CoreGraphics
712-
- IOKit
713-
- QuartzCore
714-
- UniformTypeIdentifiers
715-
716687
_tokenize:
717688
minimum-python-version: "3.11"
718689
config-c-only: true

src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ const GLOBAL_EXTENSIONS_WINDOWS_PRE_3_13: &[&str] = &["_msi"];
822822
const GLOBAL_EXTENSIONS_WINDOWS_NO_STATIC: &[&str] = &["_testinternalcapi", "_tkinter"];
823823

824824
/// Extension modules that should be built as shared libraries.
825-
const SHARED_LIBRARY_EXTENSIONS: &[&str] = &["_crypt"];
825+
const SHARED_LIBRARY_EXTENSIONS: &[&str] = &["_crypt", "_tkinter"];
826826

827827
const PYTHON_VERIFICATIONS: &str = include_str!("verify_distribution.py");
828828

0 commit comments

Comments
 (0)