Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Don't assume that Windows has no usable zlib/tommath

Closed / Fixedac3ea8730530daf7c680a4b9e2163dc146091fd6Created 1 year agoUpdated 43 days ago
Descriptionplain2025-10-26 12:43:34
win/configure has this comment:

#------------------------------------------------------------------------
#	Add stuff for zlib/libtommath; note that this is mostly done in the
#	makefile now as we just assume that the platform hasn't got usable
#   z.lib/tommath.lib
#------------------------------------------------------------------------

MSYS2/Mingw-Packages has usable zlib & tommath for many years now. I'm the occasional package maintainer for tcl/tk and having to refresh the patch that corrects this assumption on every minor release is a pain. I'm looking into packaging tcl9/tk9 and having this annoyance resolved will be great.

I'm not proficient at autotools/automake, otherwise I would be glad to submit a patch years ago.

Thanks.
Referenced by4
  • 0890c290edFix [ac3ea87305] and [17ffc49790]. New option --with-system-zlib and fix out-of-tree build with "configure --srcdir=..." check-in2026-10-27 13:25:50
  • 809ce55fbcFix [ac3ea87305]: Don't assume that Windows has no usable zlib/tommath check-in2026-10-20 21:12:44
  • be527d2e2dFix [ac3ea87305]: Don't assume that Windows has no usable zlib/tommath check-in2026-10-20 21:09:32
  • 61fe2461e3Fix [ac3ea87305]: win/configure gets --with-system-zlib and --with-system-libtommath to link the zlib and libtommath of the build system (e.g. MSYS2) instead of the bundled ones. check-in2026-10-20 19:12:44
oscarfv Ticket [ac3ea87305]: 3 changes [History diff]2025-10-26 12:43:58
oscarfvplain2025-10-29 09:11:09
One brute-force solution for this is to explicitly exclude Tcl's zlib1.dll, etc. from our Tcl package. As long as Tcl's vendored zlib & tommath are keep in-sync with upstream (so it is basically building the same version as we have in MSYS2), it shouldn't be problematic, although not as robust as a proper build toggle.

What do you think?
jan.nijtmanswiki2025-10-29 21:50:31

> What do you think?

That should be OK. The zlib/tommath dll's distributed with Tcl are built with clang (ucrt) and with -static-gcclib. No other deviations from the standard build. It should be drop-in compatible with the MSYS2 built dll's.

oscarfvplain2025-10-30 08:44:30
Thanks. I already adapted our (MSYS2) build recipe to use this approach instead of the patch for zlib in 8.6.17 and will do the same for tommath in 9.0.3.

About 9.0.x: right now fails while building tcl90.dll with unresolved references to Tcl_GetNumberFromObj, Tcl_InitStringRep, TclBN_mp_neg, ....  ClockMCDict and more. Do you want a ticket for this or is it a known problem?
oscarfvplain2025-10-30 08:45:10
9.0.x is 9.0.2 on my previous comment.
jan.nijtmanswiki2025-10-30 09:20:36

> About 9.0.x: right now fails while building tcl90.dll with unresolved references ...

Try passing CFLAGS_OPTIMIZE in stead of CFLAGS.

See: [84e8a94613] (not exactly the same, but similar)

It might also be that a tcl.h from 8.6 is still found somewhere

serhiy.storchakawiki2026-10-20 19:15:30

Proposed in branch [win-system-zlib-tommath]: win/configure gets two options, off by default, so the standard build is unchanged:

--with-system-zlib        link -lz instead of the bundled zlib
--with-system-libtommath  link -ltommath instead of the bundled libtommath

With them the bundled zlib1.dll / libtommath.dll and their import libraries are neither copied nor installed (for static builds the bundled objects are not compiled in), and configure fails if the library is not found. Tested natively with MSYS2 UCRT64 and its zlib and libtommath packages: tcl91.dll imports zlib1.dll and libtommath-1.dll from /ucrt64/bin, and the zlib, expr and format tests pass. Also checked with a MinGW-w64 cross build on Linux (shared and static, tests under Wine). The bundled zlib.h and tommath.h are still used for compiling, as on Unix.

jan.nijtmanswiki2026-10-20 20:43:23

I don't see anything wrong with this, so go ahead.

+1

serhiy.storchaka Closed ticket [ac3ea87305]. [History diff]2026-10-20 21:09:33
serhiy.storchakawiki2026-10-20 21:14:09

Merged to [trunk] and [core-9-0-branch].

jan.nijtmanswiki2026-10-20 21:25:31

Please don't forget the changes.md/changes entries

Log in (anonymous is fine) to add a comment.