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/vpjygfwbm23sld6b8dkas1cczbii53m1-mpv-mpris-0.4.so
╚═══/: …...................../nix/store/1m52x4908vr922dhnxz1i5rfnrsq244vzc-gcc-9.3.0/lib/gcc/x86_64-unknow…
    => /nix/store/52x4908vr922dhnxz1i5rfnrsq244vzc-gcc-9.3.0

After reading https://nixos.org/nixos/nix-pills/automatic-runtime-dependencies.html, I’m thinking that perhaps this:

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

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 mpris.so 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…