[GHC] #7749: hsc2hs generated executable does not reflect additional library directories

GHC cvs-ghc at haskell.org
Thu Mar 7 20:52:19 CET 2013


#7749: hsc2hs generated executable does not reflect additional library directories
---------------------+------------------------------------------------------
Reporter:  ijmorlan  |          Owner:                  
    Type:  bug       |         Status:  new             
Priority:  normal    |      Component:  hsc2hs          
 Version:  7.4.2     |       Keywords:                  
      Os:  MacOS X   |   Architecture:  Unknown/Multiple
 Failure:  Other     |      Blockedby:                  
Blocking:            |        Related:                  
---------------------+------------------------------------------------------
 This came up attempting to "cabal install postgresql-libpq", with the
 following result:

 {{{
 14:36 ijmorlan at 27imac.local$ cabal install postgresql-libpq
 Resolving dependencies...
 [1 of 1] Compiling Main             (
 /var/folders/Lh/LhVs9ls4Hme1jR+t1DJbm++++TQ/-Tmp-/postgresql-
 libpq-0.8.2.2-60148/postgresql-libpq-0.8.2.2/Setup.hs,
 /var/folders/Lh/LhVs9ls4Hme1jR+t1DJbm++++TQ/-Tmp-/postgresql-
 libpq-0.8.2.2-60148/postgresql-libpq-0.8.2.2/dist/setup/Main.o )
 Linking /var/folders/Lh/LhVs9ls4Hme1jR+t1DJbm++++TQ/-Tmp-/postgresql-
 libpq-0.8.2.2-60148/postgresql-libpq-0.8.2.2/dist/setup/setup ...
 Configuring postgresql-libpq-0.8.2.2...
 Building postgresql-libpq-0.8.2.2...
 Preprocessing library postgresql-libpq-0.8.2.2...
 dyld: Library not loaded: libpq.5.dylib
   Referenced from:
 /private/var/folders/Lh/LhVs9ls4Hme1jR+t1DJbm++++TQ/-Tmp-/postgresql-
 libpq-0.8.2.2-60148/postgresql-
 libpq-0.8.2.2/dist/build/Database/PostgreSQL/LibPQ_hsc_make
   Reason: image not found
 running dist/build/Database/PostgreSQL/LibPQ_hsc_make failed (exit code 5)
 command was: dist/build/Database/PostgreSQL/LibPQ_hsc_make
 >dist/build/Database/PostgreSQL/LibPQ.hs
 cabal: Error: some packages failed to install:
 postgresql-libpq-0.8.2.2 failed during the building phase. The exception
 was:
 ExitFailure 1
 14:36 ijmorlan at 27imac.local$
 }}}

 Some background: My PostgreSQL installation was made using the one-click
 installer available from
 PostgreSQL:http://www.postgresql.org/download/macosx/.  Libraries are in
 /Library/PostgreSQL/9.2/lib.

 The postgresql-libpq Setup.hs uses pg_config to pick up the proper include
 and library directories, and these are passed to hsc2hs with a "--
 lflag=-L/Library/PostgreSQL/9.2/lib" option.  hsc2hs successfully builds
 its temporary intermediate executable.  However, running this executable
 gives the dyld error seen above.

 I managed to use install_name_tool to fix the intermediate executable, as
 follows:

 {{{
 14:16 ijmorlan at 27imac.local$ install_name_tool -add_rpath
 /Library/PostgreSQL/9.2/lib dist/build/Database/PostgreSQL/LibPQ_hsc_make
 14:17 ijmorlan at 27imac.local$ install_name_tool -change libiconv.2.dylib
 @rpath/libiconv.2.dylib dist/build/Database/PostgreSQL/LibPQ_hsc_make
 14:17 ijmorlan at 27imac.local$ install_name_tool -change libpq.5.dylib
 @rpath/libpq.5.dylib dist/build/Database/PostgreSQL/LibPQ_hsc_make
 }}}

 That is, add an "rpath" to the executable, and change both libraries that
 need it to use it, with the following result:

 {{{
 14:41 ijmorlan at 27imac.local$ otool -L
 dist/build/Database/PostgreSQL/LibPQ_hsc_make
 dist/build/Database/PostgreSQL/LibPQ_hsc_make:
         @rpath/libpq.5.dylib (compatibility version 5.0.0, current version
 5.5.0)
         @rpath/libiconv.2.dylib (compatibility version 8.0.0, current
 version 8.1.0)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
 version 125.2.11)
 }}}

 The modified executable runs and dumps out a bunch of .hs code, as
 expected.

 So, I'm not sure if this is really best characterized as a bug in hsc2hs,
 but it seems like hsc2hs might be the right place to fix the problem.

 I've been trying to figure out extra parameters to hsc2hs to tell it to
 give extra parameters to the linker to install the rpath, but there are
 too many layers and I'm not confident the gcc documentation re: the -rpath
 option I'm reading is even appropriate on Mac OS X.

 So what I'm really hoping is that somebody familiar with hsc2hs and Mac OS
 X library management can give me some hints on how this might be fixed,
 and how it might be that I'm the only one who can't install postresql-
 libpq on Mac OS X.  As I mentioned, my PostgreSQL installation is pretty
 stock, and I re-installed Haskell Platform just the other day, so I can't
 see how the problem is being caused by anything unusual that I'm doing.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7749>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list