Linker limit on OS X Sierra breaks builds for big projects
I'm opening a fresh ticket as @bgamari suggested in #12479 (closed). There are few more related closed tickets as well: #12198 (closed) and #12588 (closed). The issue occurs on projects with a lot of dependencies. There are reports of that happening across various projects:
I'm still able to reproduce it with 8.2.1 and git HEAD with a work project:
ghc: panic! (the 'impossible' happened) (GHC version 8.2.1 for x86_64-apple-darwin): Loading temp shared object failed: dlopen(/var/folders/f8/2_rc4tgd1gj9vbgv7q9gbk4c0000gn/T/ghc94377_0/libghc_325.dylib, 5): no suitable image found. Did find: /var/folders/f8/2_rc4tgd1gj9vbgv7q9gbk4c0000gn/T/ghc94377_0/libghc_325.dylib: malformed mach-o: load commands size (34592) > 32768 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
I can't share the sources, but this is a command(generated by stack) that results in this error:
/Users/dr/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_220.127.116.11_ghc-8.2.1 --builddir=.stack-work/dist/x86_64-osx/Cabal-18.104.22.168 build lib:projectname exe:projectname --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
We're having a chat about this issue with @bgamari and I'll post some of his input:
bgamari: dredozubov, unfortunately this is pretty much a limitation of OS X's linker bgamari: there's no great solution other than petitioning Apple to lift their arbitrary size limit bgamari: I've been asking people to open tickets with Apple bgamari: As they are really the only ones that can really fix this issue dredozubov: bgamari, do you know if someone did this already? bgamari: dredozubov, No one has said they have dredozubov: the other issue with it, I don't how to do a repro case dredozubov: I can reproduce it on a project with a closed sources and that's it bgamari: essentially you just need to build a project with enough dependencies bgamari: the problem is that Apple's linker sets an artificial cap on the number of shared libraries that an object file can load