Providing libraries for compilers

I’m a bit lost on how to properly reference a lib for a compiler in the compilers derivation such that the lib can finally be linked to the resulting program by this compiler.

To be more specific: ghdl-llvm at some point calls ld with -lz. The way ghdl-llvmis currently packaged, this fails alszlibcannot be found. However, if I run a nix-shell -p ghdl-llvm -p zlib` the lib is found and ghdl works as fine (e.g. it compiles and simulates the given VHDL code).

I played with depsTargetTarget and friends, but nothing did the trick.

An additional complication might be that ghdl-llvm itself is not linked against zlib.

Any hints how ghdl-llvm could be fixed in nixpkgs?