From ee5f854be79aa4f0cc28f885ac1c3e7a74ffe574 Mon Sep 17 00:00:00 2001 From: sempiternal-aurora <78790545+sempiternal-aurora@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:54:56 +1000 Subject: [PATCH] ghdl: fix environment for llvm and gcc backends gcc backend needs as on path, llvm requires the full gcc compiler suite, so just add stdenv.cc to both. Both also need to link against zlib, so add it to the library paths The problems arose in `nix shell nixpkgs#ghdl-llvm` and adding it to a system environment, not `nix-shell -p ghdl-llvm` because that added gcc and other things to the path. __structuredAttrs may also have affected this Fixes: #113401 --- pkgs/by-name/gh/ghdl/package.nix | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/pkgs/by-name/gh/ghdl/package.nix b/pkgs/by-name/gh/ghdl/package.nix index 290cd41a9416..b4f754b8e423 100644 --- a/pkgs/by-name/gh/ghdl/package.nix +++ b/pkgs/by-name/gh/ghdl/package.nix @@ -37,29 +37,22 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ gnat ] + ++ lib.optionals (backend == "llvm" || backend == "gcc") [ + makeWrapper + ] ++ lib.optionals (backend == "gcc") [ texinfo - makeWrapper ]; buildInputs = [ zlib ] - ++ lib.optionals (backend == "llvm") [ - llvm - ] ++ lib.optionals (backend == "gcc") [ gmp mpfr libmpc ]; - propagatedBuildInputs = [ - ] - ++ lib.optionals (backend == "llvm" || backend == "gcc") [ - zlib - ]; - preConfigure = '' # If llvm 7.0 works, 7.x releases should work too. sed -i 's/check_version 7.0/check_version 7/g' configure @@ -99,20 +92,18 @@ stdenv.mkDerivation (finalAttrs: { --with-gmp-lib=${gmp.out}/lib \ --with-mpfr-include=${mpfr.dev}/include \ --with-mpfr-lib=${mpfr.out}/lib \ - --with-mpc=${libmpc} + --with-mpc=${libmpc} \ + --enable-default-pie=${if stdenv.targetPlatform.hasSharedLibraries then "yes" else "no"} make -j $NIX_BUILD_CORES make install cd ../ make -j $NIX_BUILD_CORES ghdllib ''; - postFixup = lib.optionalString (backend == "gcc") '' + postFixup = lib.optionalString (backend == "llvm" || backend == "gcc") '' wrapProgram $out/bin/ghdl \ - --set LIBRARY_PATH ${ - lib.makeLibraryPath [ - stdenv.cc.libc - ] - } + --set LIBRARY_PATH ${lib.makeLibraryPath [ zlib ]} \ + --prefix PATH : ${lib.makeBinPath [ stdenv.cc ]} ''; hardeningDisable = [