Skip to content
Tcl Source Code View Ticket
Login

View Ticket

unix/Makefile.in problem when building pkgs for static builds

Closed / Wont Fix9cdb0d585883311b2acc9577820e90713968c1cbCreated 6 years agoUpdated 34 days ago
Descriptionplain2020-11-02 21:37:38
In unix/Makefile.in, the lines
                      $(PKG_CFG_ARGS) --libdir=$(PACKAGE_DIR) \
                      --enable-shared --enable-threads; ) || exit $$?; \
want to be
                      --libdir=$(PACKAGE_DIR) \
                      --enable-shared --enable-threads $(PKG_CFG_ARGS) ; ) || exit $$?; \

so that the PKG_CFG_ARGS are not overridden by --enable-shared, and --disable-shared can take effect for static builds.
Referenced by3
  • 206df9c005Ticket [8228750a0a] Makefile issue when building packages status still Open with 3 other changes ticket2026-10-20 12:29:51
  • 732583df8cFix [9cdb0d5858] and [8228750a0a]: the bundled packages were always built as shared libraries, even with --disable-shared. Keep that default, so that [package require] can load them also from a static Tcl, but allow "make PKG_SHARED=--disable-shared" to build them as static libraries, in unix/Makefile.in and win/Makefile.in. check-in2026-10-20 12:23:34
  • 9d87df83e9Fix [9cdb0d5858] and [8228750a0a]: with --disable-shared the bundled packages were still built as shared libraries, since --enable-shared came after the arguments passed on to their configure. Put it before them, in unix/Makefile.in and win/Makefile.in, so that --disable-shared builds static packages too. Note that static packages cannot be loaded with [package require] unless linked into the application. check-in2026-10-20 12:22:15
serhiy.storchakawiki2026-10-20 12:29:51

Still present in 8.6, 9.0 and 9.1, on Unix and Windows: the fixed --enable-shared comes after the arguments passed on to the packages' configure, so --disable-shared never reaches them. This may be intended: shared, stub-enabled packages can be loaded with [package require] also from a static Tcl, while static ones only help when linked into the application. So there are two proposed fixes, please choose:

  • pkgs-respect-disable-shared, as suggested here: --disable-shared builds static packages too (--libdir stays last). Incompatible for static Tcl builds that load the bundled packages.
  • pkgs-shared-make-var: packages stay shared by default, and make PKG_SHARED=--disable-shared builds them static. No change for existing builds.

Both tested with Thread in pkgs/, on Linux and with a MinGW cross build.

dgpplain2026-10-21 18:05:34
The purpose of the `make *packages` targets in Tcl's unix Makefile
is to make installable builds of the bundled collection of packages
that can then successfully be [package require]d or [load]ed into
the Tcl built by the same Makefile.  Forcing the --enable-shared
build is intentional to achieve this aim.

Back when it made a difference, forcing --enable-threads had similar
justification.  I believe in Tcl 9 we can drop that since we
require thread-enabled code for everything now.

The Tcl+pkgs source code distribution contains the full source code
releases of all the packages.  Anyone who needs a --disable-shared
build of one of those packages is welcome to do that by directly
working within the package's source directory and using its own
configuration and build mechanism.  I strongly prefer we do not enable
that control in Tcl's unix/Makefile.  If you choose to build one of the
bundled packages through the Tcl+pkgs collection, then you get the build
configuration suitable for Tcl+pkgs installation.
jan.nijtmanswiki2026-10-30 21:11:33

I agree with Don. If you build a package with --disable-shared, the only thing built is a static library (*.a or *.lib). This library is not useful in itself, it still has to be linked in the application, neither Tcl nor Tk have the machinery to do that. So, when being part of the Tcl 'batteries included', --disable-shared makes no sense for the included packages.

So, closing as 'Won't fix' (in fact 'works as designed') makes most sense.

Anyway, thanks for bringing this up! Closing the two branches. Sorry!

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