Opened 12 months ago

Last modified 11 months ago

#15990 new bug

Dynamically built GHC crashes on MacOS

Reported by: harpocrates Owned by:
Priority: normal Milestone: 8.8.1
Component: Build System (Hadrian) Version: 8.7
Keywords: Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Since 79d5427e1f9de02c0b171bf5db46b6b49c6f85e3 (which add support for dynamically linking GHC), the default ./hadrian/build.sh is broken for MacOS. In particular, the ghc built always crashes with a "Symbol not found" error. Example:

$ ./hadrian/build.sh -j -c 
# << fails shortly after building first ghc >>
$ _build/stage1/bin/ghc
dyld: Symbol not found: _ffi_type_double
  Referenced from: _build/stage1/lib/../lib/x86_64-osx-ghc-8.7.20181202/libHSghci-8.7-ghc8.7.20181202.dylib
  Expected in: flat namespace
 in _build/stage1/lib/../lib/x86_64-osx-ghc-8.7.20181202/libHSghci-8.7-ghc8.7.20181202.dylib
[1]    52701 abort      _build/stage1/bin/ghc

See https://phabricator.haskell.org/rGHC79d5427e1f9de02c0b171bf5db46b6b49c6f85e3 for more discussion. The core of the issue seems to be that -Wl,-dead_strip_dylibs accidentally strips some essential libraries (libffi is one of these).

Change History (6)

comment:1 Changed 12 months ago by harpocrates

Differential Rev(s): Phab:D5409
Status: newpatch

comment:2 Changed 11 months ago by harpocrates

Differential Rev(s): Phab:D5409

comment:3 Changed 11 months ago by Ben Gamari <ben@…>

In 2f65025e/ghc:

Hadrian: support extra libraries + OSX rpath

Summary:
This fixes some of the issues that surfaced when trying to build
dynamic GHC on OSX. Unfortunately, due some other `libffi`
issues, this doesn't completely fix dynamic builds on OSX.

  - Use 'extra-libraries' from .cabal files instead of hardcoding
    which packages need which extra libs. Also add support for
    'extra-lib-dirs'.

  - Make sure Hadrian looks in the right places to support both
    plain '<pkg>.buildinfo' and '<pkg>.buildinfo.in' files.

  - Make the '-rpath' support more robust across OS's (it previously
    didn't work on OSX and possibly windows either).

Reviewers: angerman, alpmestan, adamse, DavidEichmann, bgamari, Phyx

Subscribers: rwbarton, carter

GHC Trac Issues: #15990

Differential Revision: https://phabricator.haskell.org/D5409

comment:4 Changed 11 months ago by bgamari

Resolution: fixed
Status: patchclosed

I believe this should now be fixed.

comment:5 Changed 11 months ago by harpocrates

Wait, when did this get fully fixed? Weren't there still some outstanding libffi issues? My patch was definitely not enough.

comment:6 Changed 11 months ago by bgamari

Resolution: fixed
Status: closednew

Alright, in that case my belief was incorrect :)

Note: See TracTickets for help on using tickets.