Tcl Source Code

View Ticket
Login
Ticket UUID: 5916e48806d93dd9b24f8f73c3f4d7ed74b04eb3
Title: tcl.pc: hardcoded depedencies, missing build flags
Type: Bug Version:
Submitter: chrstphrchvz Created on: 2023-04-29 22:24:48
Subsystem: 54. Configuration Reporting Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-07-11 09:30:19
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2023-07-11 09:30:19
Description:

I am not very familiar with pkg-config, but there seem to be a few issues with the installed tcl.pc file.

  1. My understanding is that the only time libtommath (on 8.7 and later) or zlib should be specified Requires.private field of tcl.pc is if they are installed on the system with pkg-config data, and Tcl is built to use them.
  2. If pkg-config-supporting copies of the libraries are not present, then pkg-config will complain when tcl.pc is used:

    Package zlib was not found in the pkg-config search path.
    Perhaps you should add the directory containing `zlib.pc'
    to the PKG_CONFIG_PATH environment variable
    Package 'zlib', required by 'tcl', not found
    
    

    Package libtommath was not found in the pkg-config search path. Perhaps you should add the directory containing `libtommath.pc' to the PKG_CONFIG_PATH environment variable Package 'libtommath', required by 'tcl', not found

  3. If Tcl has built against external copies of these libraries, but they do not provide pkg-config data, then presumably tcl.pc is responsible for providing any necessary build flags.

  4. If external libtommath is used, then -DTCL_WITH_EXTERNAL_TOMMATH should be specified in the cflags field of tcl.pc.

    Python, for its official binary distributions, would likely prefer to continue having Tcl build with its bundled libtommath, since nothing else in CPython uses libtommath. Defining TCL_NO_TOMMATH_H allows Tkinter to build against Tcl with bundled libtommath. But handling the case of Tcl built with external libtommath seems to require knowing whether TCL_WITH_EXTERNAL_TOMMATH is defined; and Tkinter, by default, tries to use pkg-config to get Tcl/Tk build flags, rather than from TEA/tclConfig.sh/TCL_DEFS as usually done by Tcl/Tk software.

  5. If Tcl was built using bundled versions of these libraries, then there is nothing which should be put in tcl.pc for them--at least not in Requires.private or linking flags.

User Comments: jan.nijtmans added on 2023-07-11 09:30:19:

Fixed [4b11db28e63dbe4a|here]. Looks good to me.


chrstphrchvz added on 2023-06-26 20:54:00:

I am attaching a brief patch for 8.7 and later, which I would consider the bare minimum for improving tcl.pc to correctly indicate bundled or external libtommath dependency. It appears to work with Tkinter.

The approach in the patch assumes that if external libtommath is used, then it was installed with pkg-config data; maybe it often is, but that is not guaranteed. (MacPorts, for example, only recently began installing libtommath.pc: https://github.com/macports/macports-ports/pull/18424) Ideally, if a dependency is listed in tcl.pc, then that should mean Tcl used pkg-config to detect it and retrieve its build flags (e.g. -lz, -ltommath); only when a dependency is not detected by pkg-config should Tcl try providing build flags.


Attachments: