From bb0c8c6bb89d384023935e87ebdd1239ed6d242c Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Fri, 12 Jan 2024 10:05:41 +0000 Subject: [PATCH] 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); | ^ --- pkgs/development/compilers/dmd/binary.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/dmd/binary.nix b/pkgs/development/compilers/dmd/binary.nix index 6a99d42eff72..3a5d6b76cec8 100644 --- a/pkgs/development/compilers/dmd/binary.nix +++ b/pkgs/development/compilers/dmd/binary.nix @@ -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;