From 7c73d1e0258453b7ee08305e284197f8a7f7940c Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 28 Jan 2023 11:31:08 +0000 Subject: [PATCH] dmd: set --sysroot=/ to avoid cc-wrapper value After https://github.com/NixOS/nixpkgs/pull/210004 `dmd` started failing build as: ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' This happens because --sysroot=/nix/store/does/not/exist removes not just include headers by prefixing wrong path, but also removes RUNPATH dependencies of linked libraries. It's an unintended effect. Restore the build by reversing the effect with --sysroot=/. --- pkgs/development/compilers/dmd/generic.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/compilers/dmd/generic.nix b/pkgs/development/compilers/dmd/generic.nix index c862bb2bbfde0..8b68966e8ac2e 100644 --- a/pkgs/development/compilers/dmd/generic.nix +++ b/pkgs/development/compilers/dmd/generic.nix @@ -151,6 +151,13 @@ stdenv.mkDerivation rec { git ]; + # Workaround cc-wrapper's --sysroot= value for `staging-next`: it + # breaks library lookup via RUNPATH: + # ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) + # ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' + # TODO(trofi): remove the workaround once cc-wrapper is fixed. + NIX_CFLAGS_COMPILE = [ "--sysroot=/" ]; + buildInputs = [ curl tzdata