NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.56k stars 13.72k forks source link

Build failure: pkgsStatic.tcl #303259

Open lolbinarycat opened 5 months ago

lolbinarycat commented 5 months ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. build pkgsStatic.tcl

Build log

initially the log was just a simple eval failure, which was simple enough to fix, but after that it started throwing errors about duplicate symbols

Additional context

i took a shot at fixing pkgs/development/interpreters/tcl/generic.nix, this is the best i could manage so far:

{ lib, stdenv, callPackage, makeSetupHook, runCommand
, tzdata

# Version specific stuff
, release, version, src
, ...
}:

let
  inherit (lib.strings) optionalString;
  baseInterp =
    stdenv.mkDerivation rec {
      pname = "tcl";
      inherit version src;

      outputs = [ "out" "man" ];

      setOutputFlags = false;

      postPatch = ''
        substituteInPlace library/clock.tcl \
          --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo" \
          --replace "/usr/share/lib/zoneinfo" "" \
          --replace "/usr/lib/zoneinfo" "" \
          --replace "/usr/local/etc/zoneinfo" ""
      '';

      preConfigure = ''
        cd unix
      '';

      configureFlags = [
        "--enable-threads"
        # Note: using $out instead of $man to prevent a runtime dependency on $man.
        "--mandir=${placeholder "out"}/share/man"
        "--enable-man-symlinks"
        # Don't install tzdata because NixOS already has a more up-to-date copy.
        "--with-tzdata=no"
        "tcl_cv_strtod_unbroken=ok"
      ] ++ lib.optional stdenv.is64bit "--enable-64bit"
        ++ lib.optional stdenv.hostPlatform.isStatic "--enable-shared=no";

      enableParallelBuilding = true;

      postInstall = let
        libExtension = stdenv.hostPlatform.extensions.library;
      in ''
        make install-private-headers
        ln -s $out/bin/tclsh${release} $out/bin/tclsh
        ln -s $out/lib/libtcl${release}${libExtension} $out/lib/libtcl${libExtension}
      '';

      meta = with lib; {
        description = "The Tcl scripting language";
        homepage = "https://www.tcl.tk/";
        license = licenses.tcltk;
        platforms = platforms.all;
        maintainers = with maintainers; [ agbrooks ];
      };

      passthru = rec {
        inherit release version;
        libPrefix = "tcl${release}";
        libdir = "lib/${libPrefix}";
        tclPackageHook = callPackage ({ buildPackages }: makeSetupHook {
          name = "tcl-package-hook";
          propagatedBuildInputs = [ buildPackages.makeBinaryWrapper ];
          meta = {
            inherit (meta) maintainers platforms;
          };
        } ./tcl-package-hook.sh) {};
        # verify that Tcl's clock library can access tzdata
        tests.tzdata = runCommand "${pname}-test-tzdata" {} ''
          ${baseInterp}/bin/tclsh <(echo "set t [clock scan {2004-10-30 05:00:00} \
                                        -format {%Y-%m-%d %H:%M:%S} \
                                        -timezone :America/New_York]") > $out
        '';
      };
    };

  mkTclDerivation = callPackage ./mk-tcl-derivation.nix { tcl = baseInterp; };

in baseInterp.overrideAttrs (self: {
     passthru = self.passthru // {
       inherit mkTclDerivation;
     };
})

Notify maintainers

@agbrooks

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.7.10, NixOS, 23.11 (Tapir), 23.11.5742.219951b495fc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(binarycat): `"stable-23.05, unstable"`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

lolbinarycat commented 5 months ago

adding

      postConfigure = ''
        sed -ie '/^COMPAT_OBJS/s/strtoul.o//' Makefile
      '';

fixed the the duplicate symbol error, but now i'm getting this:

/nix/store/37phs74i2zf4vx500nvvp1zfjvqc3i6g-x86_64-unknown-linux-musl-binutils-2.41/bin/x86_64-unknown-linux-musl-ld: /nix/store/crpqrn5cmgkl8zkxh2gfdxv5k75p87q2-x86_64-unknown-linux-musl-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-musl/13.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol '__TMC_END__' can not be used when making a shared object

which might be beyond my capabilities

lolbinarycat commented 5 months ago

digging deeper, it seems that tcl is getting built statically, but itcl (which has a seperate Makefile, generated by a configure script called by the main makefile) is not getting the memo.

lolbinarycat commented 5 months ago

in both cases, it seems the SHLIB_LD variable is getting set to a string that contains -shared, even when --enable-shared=no is passed to the makefile.