dmd: improve eval failure on pkgsLLVM package set

`dmd` requires `libgcc` to be able to run `dmd` binary. As a result
`pkgsLLVM.dmd` fails the eval as:

    $ nix build -f. pkgsLLVM.dmd
       error: attribute 'libgcc' missing

       at pkgs/development/compilers/dmd/binary.nix:31:5:

           30|     glibc
           31|     stdenv.cc.cc.libgcc
             |     ^

Such reference to non-existent attributes is an unrecoverable exception.
The change turns it into recoverable `assert`:

    $ nix build --no-link -f. pkgsLLVM.dmd
       error: assertion '((hostPlatform).isLinux -> (((stdenv).cc.cc) ? libgcc))' failed

       at pkgs/development/compilers/dmd/binary.nix:12:1:

           11| # and can't build `dmd`.
           12| assert hostPlatform.isLinux -> (stdenv.cc.cc ? libgcc);
             | ^
This commit is contained in:
Sergei Trofimovich
2024-01-12 10:05:41 +00:00
parent a2f82b9b84
commit bb0c8c6bb8

View File

@@ -5,7 +5,12 @@ let
inherit (stdenv) hostPlatform;
OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name;
MODEL = toString hostPlatform.parsed.cpu.bits;
in stdenv.mkDerivation {
in
# On linux pargets like `pkgsLLVM.dmd` `cc` does not expose `libgcc`
# and can't build `dmd`.
assert hostPlatform.isLinux -> (stdenv.cc.cc ? libgcc);
stdenv.mkDerivation {
pname = "dmd-bootstrap";
inherit version;