From b4b0914097642758bc9754c25e3d6727d595bdca Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Fri, 7 Feb 2025 19:54:41 +0000 Subject: [PATCH] tcl: fix on static architectures This is a bit of a silly one. It's a symbol redefinition problem caused by autoconf being pessimistic, then a funny eval error where `stdenv.hostPlatform.extensions.dynamicLibrary` is not defined, say, when the platform does not support dynamic libraries. Fixes: https://github.com/NixOS/nixpkgs/issues/380168 --- pkgs/development/interpreters/tcl/generic.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/tcl/generic.nix b/pkgs/development/interpreters/tcl/generic.nix index 51519f61b0f2..43b9aefbde20 100644 --- a/pkgs/development/interpreters/tcl/generic.nix +++ b/pkgs/development/interpreters/tcl/generic.nix @@ -80,7 +80,14 @@ let "--disable-zipfs" ] ++ [ + # During cross compilation, the tcl build system assumes that libc + # functions are broken if it cannot test if they are broken or not and + # then causes a link error on static platforms due to symbol conflict. + # These functions are *checks notes* strtoul and strstr. These are + # never broken on modern platforms! "tcl_cv_strtod_unbroken=ok" + "tcl_cv_strtoul_unbroken=ok" + "tcl_cv_strstr_unbroken=ok" ] ++ lib.optional stdenv.hostPlatform.is64bit "--enable-64bit"; @@ -89,11 +96,17 @@ let postInstall = let dllExtension = stdenv.hostPlatform.extensions.sharedLibrary; + staticExtension = stdenv.hostPlatform.extensions.staticLibrary; in '' make install-private-headers ln -s $out/bin/tclsh${release} $out/bin/tclsh - ln -s $out/lib/libtcl${release}${dllExtension} $out/lib/libtcl${dllExtension} + if [[ -e $out/lib/libtcl${release}${staticExtension} ]]; then + ln -s $out/lib/libtcl${release}${staticExtension} $out/lib/libtcl${staticExtension} + fi + ${lib.optionalString (!stdenv.hostPlatform.isStatic) '' + ln -s $out/lib/libtcl${release}${dllExtension} $out/lib/libtcl${dllExtension} + ''} ''; meta = with lib; {