Skip to content

GHC exceeds ARG_MAX when linking very large packages

Summary

GHC fails to link library or executable if the linker command line grows too long

Steps to reproduce

It's difficult to create a small reproduction for this, but the way we reproduced this internally was to link 4000+ Haskell modules within a project that had a sufficiently long build directory (whose absolute path is 100+ characters long). This ends up generating an enormous linker command that exceeds ARG_MAX on macOS, which fails with:

ld: Argument list too long

Expected behavior

In our case the linker supports response files, so the behavior we'd like is for ghc to use the linker's support for response files when available so that we don't exceed the length limit.

Environment

  • GHC version used: GHC 9.4.2

Optional:

  • Operating System: macOS
  • System Architecture: aarch64-darwin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information