#8770 closed bug (fixed)

ghci dynamic loading on MacOSX assumes .dylib extension (should check .so also)

Reported by: z9p Owned by:
Priority: normal Milestone: 7.8.1
Component: GHCi Version: 7.8.1-rc1
Keywords: dlopen dylib so Cc: hvr
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I am using ghc-7.6.3 on MacOSX 10.9.1. I noticed that when -l foo option is specified to ghci, it assumes the shared library extension is .dylib and tries to load foo.dylib. Even though a valid foo.so is present while foo.dylib is not, ghci ignores the .so and signals an error. This is in contradiction to the behavior of gcc and python on MacOSX. gcc would check the existence of both .so and .dylib and try to link them. Python is able to load the .so as well. Notice that here the .so is simply a renamed Mach-O .dylib.

The reason I raise this issue is, in my case, I use macports to install cern ROOT and its shared libraries are all installed as .so files under /opt/local/lib. I would like to use them without change or creating .dylib -> .so links.

$ ghci -lGui
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading object (dynamic) Gui ... failed.
<command line>: user specified .o/.so/.DLL could not be loaded (dlopen(libGui.dylib, 9): image not found)
Whilst trying to load: (dynamic) Gui
Additional directories searched: (none)

$ ln -s libGui.so libGui.dylib
$ ghci -lGui
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading object (dynamic) Gui ... done
final link ... done
Prelude>

Change History (4)

comment:1 Changed 13 months ago by thoughtpolice

  • Milestone set to 7.8.1
  • Version changed from 7.6.3 to 7.8.1-rc1

I have a fix for this anyway in the course of fixing #8736, so I'll go ahead and mark this...

comment:2 Changed 13 months ago by Austin Seipp <austin@…>

In dc080915597065087b3821b3ded0a621a7e2fae7/ghc:

Fix #8770

As usual, Mac OS X is extremely annoying (or the software is, anyway),
because not only does it load dynamic libraries with the .dylib
extension, but also the .so extension. For whatever reason. At least
it's easy to fix.

Signed-off-by: Austin Seipp <[email protected]>

comment:3 Changed 13 months ago by thoughtpolice

  • Status changed from new to merge

comment:4 Changed 13 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from merge to closed

Merged in 7.8.

Note: See TracTickets for help on using tickets.