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
This commit is contained in:
sempiternal-aurora
2026-04-29 13:19:17 +10:00
parent 2159fa6704
commit ee5f854be7
+8 -17
View File
@@ -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 = [