Why does emacs depend on gcc?

emacs (and also emacs-nox) depends on gcc:

$ nix why-depends --all nixpkgs.emacs nixpkgs.gcc
/nix/store/6vcb897ym5fcnm8q19v2mp074nzzivs9-emacs-27.1
╚═══libexec/emacs/27.1/x86_64-pc-linux-gnu/emacs.pdmp: …ih8qb-gcc-10.2.0/bin./nix/store/fr5gpdf3m2nqq6g3v6x1vvgi7cg6px8b-gcc-wrapper-10.2.0/bin./nix/sto…
    => /nix/store/fr5gpdf3m2nqq6g3v6x1vvgi7cg6px8b-gcc-wrapper-10.2.0

I consider this a bug. But I’m at a loss of further debugging this issue. The Nix expression for emacs references cc-stuff only in case nativeComp is enabled, but this defaults to false.

I would appreciate any insights on this weird dependency :slight_smile: (and volunteer for submitting a pull request once I understand the issue)

1 Like

Looks like Emacs links to libgcc:

$ ldd "$(nix-store -q "$(type -fP emacs)")/bin/.emacs"-*-wrapped | grep libgcc
        libgcc_s.so.1 => /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libgcc_s.so.1 (0x00007f469432e000)

EDIT: I’m also on NixOS 20.09 where I find that

$ nix why-depends --all nixpkgs#emacs nixpkgs#gcc
'/nix/store/fyp43pws9vl4y2g6dwj7f8ycz9pgk31q-emacs-27.1' does not depend on '/nix/store/azayfhqyg9mjyv6rv9bcypi6ws8aqfmy-gcc-wrapper-9.3.0'

The dependency was probably reintroduced by

https://github.com/NixOS/nixpkgs/commit/14154fea5263b42b8ad982d7efe2061201f60f70#

See also this associated issue:

https://github.com/NixOS/nixpkgs/issues/98755

Thank you @hmenke! If the fix has been rolled back before, then I consider this issue to unfortunately be above my pay grade. But it was interesting to deep into this problem! :slight_smile: