NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.08k forks source link

Closure of ldc-built programs is too large #324306

Open CyberShadow opened 4 months ago

CyberShadow commented 4 months ago

Describe the bug

{ lib, writeText, stdenv, ldc }:
stdenv.mkDerivation {
  name = "ldc-test";
  src = writeText "test.d" ''
    module test;
    import std.stdio;
    void main() {
      writeln("Hello, world!");
    }
  '';
  dontUnpack = true;
  buildInputs = [ ldc ];
  buildPhase = ''
    ldc2 -of=test $src
  '';
  installPhase = ''
    mkdir -p $out/bin
    mv test $out/bin
  '';
}

Building and getting the closure size gives us a number around 1.3 GiB:

$ nix --extra-experimental-features nix-command path-info -S $(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./package.nix {}')
/nix/store/fqlm6ailjq09shqrgrbhf4ll391n5mx8-ldc-test     1395772728

Graph:

out

It looks like there are some things there which might not need to be there, such as:

Notify maintainers

CC @ThomasMader @lionello @jtbx

Metadata


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

lionello commented 4 months ago

Also see https://github.com/NixOS/nixpkgs/issues/111475 "dmd keeps references to boostrap compiler" and PR #111525 which had fixes for dmd