Debug why a derivation has a reference to gcc

So there’s:

$ nix-store -q --references $(nix-build '<nixpkgs>' -A mpvScripts.mpris)

Which lists gcc.

The project has this Makefile (no autotools / autoconf / cmake involved):

Does anybody see right away from the Makefile why is it referencing gcc? Help will be appreciated.

You can use nix why-depends to find which file pulls it in.

Thanks, I didn’t know about this command. But, in this case, there’s only 1 file and that’s $out which is the same as $name:

So naturally I’d expect this to be the only one that references it.

$ nix why-depends nixpkgs.mpvScripts.mpris nixpkgs.gcc-unwrapped
╚═══/: …...................../nix/store/1m52x4908vr922dhnxz1i5rfnrsq244vzc-gcc-9.3.0/lib/gcc/x86_64-unknow…
    => /nix/store/52x4908vr922dhnxz1i5rfnrsq244vzc-gcc-9.3.0

After reading, I’m thinking that perhaps this:

post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/
shrinking /nix/store/
strip is /nix/store/3b3ighb83nhifa1v4n7855hlbdl1mhf9-binutils-2.31.1/bin/strip
patching script interpreter paths in /nix/store/
checking for references to /build/ in /nix/store/

Doesn’t remove the reference to gcc because $out is a file and not a directory?

EDIT: Answer: No that’s not it - even with a different installPhase that installs to a directory it references gcc.

Found it: We don’t run strip on the output file.

@jtojnar do you happen to know whether the standard fixup phases in Nixpkgs should run strip? Now that I see that, I remember I noticed strip is not used also for executables built with buildGoModule - I mean, file result/bin/* says not stripped

Stripping happens as fixupOutput hook:

and it is only done for files in directories that can be expected to contain elf files:

But strip just removes debugging symbols, I am not sure if that would contain GCC reference.

No idea about buildGoModule, perhaps they set dontStrip.

Awesome :). Thanks for the references.

I just tried to use stripDebugList and/or stripAllList like this:

  stripAllList = [ "$out" ];

But I think this doesn’t work if $out is a file and not a directory, per:

Hence, I’ll guess I’ll have to rewrite a bit that mpv plugins system to overcome that…