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

dist/build/Database/PostgreSQL/LibPQ.hs cabal: Error: some packages failed to install:
#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@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 postgresql-libpq-0.8.2.2 failed during the building phase. The exception was: ExitFailure 1 14:36 ijmorlan@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@27imac.local$ install_name_tool -add_rpath /Library/PostgreSQL/9.2/lib dist/build/Database/PostgreSQL/LibPQ_hsc_make 14:17 ijmorlan@27imac.local$ install_name_tool -change libiconv.2.dylib @rpath/libiconv.2.dylib dist/build/Database/PostgreSQL/LibPQ_hsc_make 14:17 ijmorlan@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@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

#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: ---------------------+------------------------------------------------------ Changes (by PHO): * cc: pho@… (added) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7749#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7749: hsc2hs generated executable does not reflect additional library directories -----------------------+---------------------------------------------------- Reporter: ijmorlan | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: hsc2hs | Version: 7.4.2 Resolution: invalid | Keywords: Os: MacOS X | Architecture: Unknown/Multiple Failure: Other | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: -----------------------+---------------------------------------------------- Changes (by igloo): * status: new => closed * difficulty: => Unknown * resolution: => invalid Comment: This doesn't look like an `hsc2hs` bug to me. Presumably if you compile a C program that uses the postgres library then you will get exactly the same problem. You can pass hsc2hs extra flags for the C compiler and the linker with the `--cflag` and `--lflag` flags respectively. Please reopen if you still think there's a ghc or hsc2hs bug here. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7749#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC