Opened 5 months ago

Closed 3 weeks ago

#15404 closed bug (fixed)

ghc-8.6 uninstallable on macos due to hard coded libgmp directory

Reported by: tmcdonell Owned by:
Priority: highest Milestone: 8.6.3
Component: None Version: 8.6.1
Keywords: Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Installing GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It is very difficult to install the ghc-8.6.1 release candidates (both RC1 and RC2) on MacOS because several components attempt to link directly to /usr/local/opt/gmp/lib/libgmp.10.dylib. This is not a standard path.

See the offending LC_LOAD_DYLIB command here:

$ jtool -l libraries/base/dist-install/build/libHSbase-
LC 00: LC_SEGMENT_64          Mem: 0x000000000-0x4e1000 __TEXT
        Mem: 0x0000010b0-0x0004d12ba            __TEXT.__text   (Normal)
        Mem: 0x0004d12ba-0x0004d1686            __TEXT.__stubs  (Symbol Stubs)
        Mem: 0x0004d1688-0x0004d1cee            __TEXT.__stub_helper    (Normal)
        Mem: 0x0004d1cee-0x0004df75b            __TEXT.__cstring        (C-String Literals)
        Mem: 0x0004df760-0x0004e0f40            __TEXT.__const
        Mem: 0x0004e0f40-0x0004e1000            __TEXT.__unwind_info
LC 01: LC_SEGMENT_64          Mem: 0x0004e1000-0x5a7000 __DATA
        Mem: 0x0004e1000-0x0004e30f0            __DATA.__got    (Non-Lazy Symbol Ptrs)
        Mem: 0x0004e30f0-0x0004e3100            __DATA.__nl_symbol_ptr  (Non-Lazy Symbol Ptrs)
        Mem: 0x0004e3100-0x0004e3610            __DATA.__la_symbol_ptr  (Lazy Symbol Ptrs)
        Mem: 0x0004e3610-0x0004e3618            __DATA.__mod_init_func  (Module Init Function Ptrs)
        Mem: 0x0004e3620-0x0004f4bc0            __DATA.__const
        Mem: 0x0004f4bc0-0x0005a6920            __DATA.__data
        Mem: 0x0005a6920-0x0005a6928            __DATA.__bss    (Zero Fill)
LC 02: LC_SEGMENT_64          Mem: 0x0005a7000-0xb8c000 __LINKEDIT
LC 03: LC_ID_DYLIB              @rpath/libHSbase-
        Symbol table is at offset 0x6a5348 (6968136), 118090 entries
        String table is at offset 0x873d78 (8863096), 3241616 bytes
        81438 local symbols at index     0
        35948 external symbols at index  81438
          704 undefined symbols at index 117386
           No TOC
           No modtab
         1380 Indirect symbols at offset 0x8727e8

LC 07: LC_UUID                  UUID: B4C0C347-131F-317B-BA52-EE23F5C5CABA
LC 08: LC_VERSION_MIN_MACOSX    Minimum OS X version:    10.12.0
LC 09: LC_SOURCE_VERSION        Source Version:
LC 10: LC_LOAD_DYLIB            /usr/lib/libiconv.2.dylib
LC 11: LC_LOAD_DYLIB            @rpath/libHSinteger-gmp-
LC 12: LC_LOAD_DYLIB            @rpath/libHSghc-prim-0.5.3-ghc8.6.0.20180714.dylib
LC 13: LC_LOAD_DYLIB            /usr/local/opt/gmp/lib/libgmp.10.dylib
LC 14: LC_LOAD_DYLIB            /usr/lib/libSystem.B.dylib
LC 15: LC_RPATH                 @loader_path/../integer-gmp-
LC 16: LC_RPATH                 @loader_path/../ghc-prim-0.5.3
LC 17: LC_RPATH                 @loader_path/../rts
LC 18: LC_FUNCTION_STARTS       Offset: 6876632, Size: 91504 (0x68edd8-0x6a5348) with 83924 functions
LC 19: LC_DATA_IN_CODE          Offset: 6968136, Size: 0 (0x6a5348-0x6a5348)

The other offenders are libHSbinary and libHSinteger-gmp.

Without changing these load commands, you'll get the following error:

$ ./configure --prefix=...
$ make install
dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
  Referenced from: ./libraries/base/dist-install/build/libHSbase-
  Reason: image not found
make[1]: *** [install_packages] Abort trap: 6
make: *** [install] Error 2

I tried passing the --with-gmp-libraries option to configure, but that did not help.

I guess this is just a packaging problem, but figured you should be aware before the official release...

Change History (15)

comment:1 Changed 4 months ago by bgamari


These won't be fixed for in GHC 8.6.

comment:2 Changed 2 months ago by wereHamster

Is there documentation how to install /usr/local/opt/gmp/lib/libgmp.10.dylib?

comment:3 Changed 2 months ago by borsboom

On my system, where I was able to install ghc-8.6.1, the file seems to have been installed by Homebrew's gmp formula.

comment:4 Changed 2 months ago by bgamari


Hmm, oh dear. It looks like I overlooked this while bumping tickets to 8.8. This should indeed be fixed. It is likely fall-out from the recent switch to CI-based binary distribution builds.

comment:5 Changed 2 months ago by bgamari

Priority: normalhighest

comment:6 Changed 8 weeks ago by bgamari

I see what happened here: we used to build for Darwin using the in-tree GMP but this logic was never ported to CircleCI.

comment:7 Changed 6 weeks ago by Ben Gamari <ben@…>

In 78fb310/ghc:

circleci: Build with in-tree GMP on Darwin

Fixes #15404.

(cherry picked from commit 578012be13eb1548050d51c0a23bd1a98423f03e)

comment:8 Changed 6 weeks ago by bgamari

Resolution: fixed
Status: newclosed

comment:9 Changed 4 weeks ago by berdario

Has this really been fixed?

I get the same error:

dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib

Referenced from: /private/tmp/ghc-8.6.2/libraries/base/dist-install/build/libHSbase- Reason: image not found

comment:10 Changed 4 weeks ago by berdario

I see that here:

This message is logged:

configure: WARNING: unrecognized options: --with-intree-gmp

maybe the configuration hasn't been picked up by autoconf?

comment:11 Changed 4 weeks ago by bgamari

Resolution: fixed
Status: closednew

Indeed, very good catch!

Looks like another 8.6 release is in order.

comment:12 Changed 4 weeks ago by berdario


Thanks to dminuoso, he pointed out that the flag is actually defined for the inner library, and in fact should be toggled differently in the

While running tests with this fix in this surfaced test failures due to

This turned out to be the same behavior in GHC 8.4, unclear why the failures weren't seen before. The .o code for the HSinteger-gmp- had the same symbol table. The bug turned out to be in GHC static linker. We added a bunch more logging statements to the code that reads MachO symbols. It turned out that it was counting the number of external symbols (let's say M), and then going through the first M such symbols in the table (thus ignoring the last N-M symbols).

comment:13 Changed 4 weeks ago by berdario

Status: newpatch

comment:14 Changed 3 weeks ago by Ben Gamari <ben@…>

In 3584bd4/ghc:

circleci: Actually build with in-tree GMP on Darwin

Fixes #15404.

comment:15 Changed 3 weeks ago by bgamari

Resolution: fixed
Status: patchclosed
Version: 8.6.1
Note: See TracTickets for help on using tickets.