Skip to content

Commit 15be6fd

Browse files
committed
Build libtcl, libtk, and _tkinter as shared objects
1 parent 684cb94 commit 15be6fd

File tree

5 files changed

+6
-55
lines changed

5 files changed

+6
-55
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: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ if [ -n "${STATIC}" ]; then
2222
fi
2323
fi
2424

25-
patch -p1 << 'EOF'
26-
diff --git a/unix/Makefile.in b/unix/Makefile.in
27-
--- a/unix/Makefile.in
28-
+++ b/unix/Makefile.in
29-
@@ -1813,7 +1813,7 @@ configure-packages:
30-
$$i/configure --with-tcl=../.. \
31-
--with-tclinclude=$(GENERIC_DIR) \
32-
$(PKG_CFG_ARGS) --libdir=$(PACKAGE_DIR) \
33-
- --enable-shared --enable-threads; ) || exit $$?; \
34-
+ --enable-shared=no --enable-threads; ) || exit $$?; \
35-
fi; \
36-
fi; \
37-
fi; \
38-
EOF
39-
4025
# Remove packages we don't care about and can pull in unwanted symbols.
4126
rm -rf pkgs/sqlite* pkgs/tdbc*
4227

@@ -48,12 +33,9 @@ CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${EXTRA_TARGET_LDFLAGS}" ./conf
4833
--build=${BUILD_TRIPLE} \
4934
--host=${TARGET_TRIPLE} \
5035
--prefix=/tools/deps \
51-
--enable-shared=no \
36+
--enable-shared \
5237
--enable-threads
5338

5439
make -j ${NUM_CPUS}
5540
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
5641
make -j ${NUM_CPUS} install-private-headers DESTDIR=${ROOT}/out
57-
58-
# For some reason libtcl*.a have weird permissions. Fix that.
59-
chmod 644 ${ROOT}/out/tools/deps/lib/libtcl*.a

cpython-unix/build-tk.sh

Lines changed: 1 addition & 4 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 \
3535
--enable-threads \
3636
${EXTRA_CONFIGURE_FLAGS}
3737

@@ -53,7 +53,4 @@ touch wish
5353
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
5454
make -j ${NUM_CPUS} install-private-headers DESTDIR=${ROOT}/out
5555

56-
# For some reason libtk*.a have weird permissions. Fix that.
57-
chmod 644 /${ROOT}/out/tools/deps/lib/libtk*.a
58-
5956
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
@@ -676,40 +676,11 @@ _tkinter:
676676
- WITH_APPINIT
677677
includes-deps:
678678
- include/X11
679+
build-mode: shared
679680
links:
680681
- tcl8.6
681682
- tk8.6
682683

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