I have a bigger build process that compiles several C++ projects, and some of them require static linking, while others require shared linking, and I would like one shell.nix
which I can use to run the entire build process.
When I only specify gcc
as a buildInput
, however, static linking fails for (at least) one of the projects, as the static libraries are not available.
When I use gcc
and glibc.static
as buildInput
s, this project compiles, but another project that wants to link a shared library fails, and tries to link against the static libc, which it should not.
If I specify gcc
, glibc.static
and glibc
as buildInput
s, this actually works for small C examples (static and shared linking in the same environment), but fails for the actual bigger build process, with the same error as here: ardour: fix build with gcc6 by disassembler · Pull Request #28748 · NixOS/nixpkgs · GitHub
Now, the solution given in this PR is to remove glibc
as an explicit buildInput
, which works, because gcc
already contains an environment with its glibc available. However, in my case, this doesn’t work, because then shared linking fails again.
I also tried nixpkgs.gccStdenvNoLibs.mkDerivation
with gcc
, glibc.static
and glibc
as buildInput
s, but this fails with the same error as given in the PR.
Is there a good/okay solution for my usecase?