Author: Jan Nijtmans <[email protected]> State: Draft Type: Project Vote: Pending Created: 9-April-2019 Post-History: Keywords: Tcl Tcl-Version: 8.7 Tcl-Branch: digit-bit-60
This TIP proposes to add the possibility to link Tcl with an external libtommath library, if available, for shared builds.
Since 8.6, Tcl has had a built-in libtommath library with modifications. By now, many of those modifications were adopted upstream. This makes it possible to change the built Tcl library, using the external libtommath library as-is, instead of using it's own fork. libtommath will continue to be delivered together with the Tcl source code.
Specification and Documentation
Starting with libtommath 1.1.0, it is possible to build Tcl without the internal libtommath, instead linking with the unmodified, externally built, libtommath. This has the following consequences:
On 64-bit platforms (win64, linux-64), libtommath will now be built in 64-bit mode, while Tcl's libtommath used to be built in 32-bit mode. Extensions which depend on the internal structure of the libtommath types will need to be re-compiled.
On win32/win64, a pre-built libtommath dll will be available, so libtommath will get the same status as zlib. Only when Tcl is build statically (
--disable-shared) a (subset of) libtommath will still be built-in, the same subset that Tcl depends on.
One of Tcl's modifications (in mp_sqrt) doesn't work in 64-bit mode. In the implementation branch this modification is reverted. It can be put back as soon as the code is fixed for 64-bit mode and accepted upstream.
Extensions can now choose whether they want to depend on libtommath directly or not. When using "
tclTomMath.h", they will be linked to Tcl's libtommath stub table, when using "
tommath.h" they will be linked directly to the external libtommath library. Both ways will continue to be supported. Extensions using "
tommath.h" can use all available libtommath functions. When using "
tclTomMath.h" only a subset is available.
tclTomMath.h" is no longer part of "
tclInt.h". So extension depending on "
tclInt.h" but using libtommath functions will need to be adapted.
The types "mp_digit" and "mp_word" are no longer declared by
tcl.h. Extensions using those types will need to start using the "
tclTomMath.h" or "
tommath.h" includes as well.
All makefiles are adapted to detect external presence of libtommath 1.1.0 or later. If so, this library will be used for shared builds, otherwise the built-in libtommath will continue to be used as before.
An implementation of this TIP is present in the digit-bit-60 branch.
This document has been placed in the public domain.