You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enter the nix-shell I have gcc available from the nix store, but not gcov
[devshell]$ which gcc
/nix/store/2x4vcmasjgjs28arlgvx352y64h5y4z1-devshell-dir/bin/gcc
[devshell]$ which gcov
/usr/bin/gcov
I expect to have gcov available because when I run nix-shell -p gcc both are available:
$ which gcc
/nix/store/r4l53b461b2lyclxn1pdj0n4hvbxl2l6-gcc-wrapper-9.3.0/bin/gcc
$ which gcov
/nix/store/7rnys4pl8v7sb72ljbhzr3wjfly339rg-gcc-9.3.0/bin/gcov
My current workaround is to add "gcc-unwrapped" to the list of packages.
Ah yes, the language.c is still very early stage and needs more testing! devshell doesn't build on top of the stdenv so we have to re-instantiate a bunch of things ourselves. But the advantage is that we also get more control.
Are you able to share your project so I can give it a try?
I can't share my actual project, but I put together a minimal repo that mirrors what I'm doing in a simplified case that you can try.
nix-shell --pure uses devshell. nix-shell --pure nixshell.nix sets up an equivalent environment using nixpkgs.mkShell In the devshell if you cd into coverageTest and run the run_coverage_test script (or just setup and run a coverage build yourself manually with meson) it fails because gcov is not found. If you delete the build directory and do the same from the standard nixpkgs.mkShell, gcovis in the path and the coverage report succeeds.
I don't have a matrix client currently, but I'll look into setting one up and maybe catching you in that room sometime. Thanks for looking into this!
Hey @zimbatm, sorry for the delay on my end for this.
Including glibc along with gcc-unwrapped seems to work for my simple project which includes Cpputest. I'll look to add something to the demo you can look at as well.
Reflecting on this some more, I wonder if this is an upstream nixpkgs issue as much as it is a devshell issue? At the very least it seems inconsistent that clang would include llvm-cov if gcc doesn't include gcov. Is the fact that the gcc expression from nixpkgs does not provide gcov intentional, or is it an oversight?
I think it's because gcc is being used in the stdenv too much. The wrapped gcc makes a bunch of assumptions that are not valid outside. That's also why gcov is missing, it's probably not useful for building packages.
Activity
mayl commentedon Mar 4, 2021
Actually, my workaround doesn't seem to work.
gcovandgccare available, but don't seem to work (mesonsays "gcccan't compile programs").Appreciate any thoughts on how to get
gcovcoverage working in adevshell!zimbatm commentedon Mar 4, 2021
Ah yes, the
language.cis still very early stage and needs more testing! devshell doesn't build on top of the stdenv so we have to re-instantiate a bunch of things ourselves. But the advantage is that we also get more control.Are you able to share your project so I can give it a try?
zimbatm commentedon Mar 4, 2021
If you have a Matrix client we can also talk about it in this room: https://matrix.to/#/#devshell:numtide.com
mayl commentedon Mar 5, 2021
I can't share my actual project, but I put together a minimal repo that mirrors what I'm doing in a simplified case that you can try.
nix-shell --pureusesdevshell.nix-shell --pure nixshell.nixsets up an equivalent environment usingnixpkgs.mkShellIn thedevshellif youcdintocoverageTestand run therun_coverage_testscript (or just setup and run a coverage build yourself manually withmeson) it fails becausegcovis not found. If you delete the build directory and do the same from the standardnixpkgs.mkShell,gcovis in the path and the coverage report succeeds.I don't have a matrix client currently, but I'll look into setting one up and maybe catching you in that room sometime. Thanks for looking into this!
zimbatm commentedon Mar 6, 2021
I banged on it until it works: mayl/gcovDemo#1
Would you mind adding a C dependency like "libz" as well to exercise this out more?
And related PR: #102
mayl commentedon Mar 21, 2021
Hey @zimbatm, sorry for the delay on my end for this.
Including
glibcalong withgcc-unwrappedseems to work for my simple project which includesCpputest. I'll look to add something to the demo you can look at as well.Reflecting on this some more, I wonder if this is an upstream
nixpkgsissue as much as it is adevshellissue? At the very least it seems inconsistent thatclangwould includellvm-covifgccdoesn't includegcov. Is the fact that thegccexpression fromnixpkgsdoes not providegcovintentional, or is it an oversight?zimbatm commentedon May 10, 2021
I think it's because gcc is being used in the stdenv too much. The wrapped gcc makes a bunch of assumptions that are not valid outside. That's also why gcov is missing, it's probably not useful for building packages.