
We've no idea what to do here. In your case it'd be possible to just ignore the script, but presumably not so in general. If anyone who understands the problem properly would like to advise, we'd be happy to hear from them. Parsing ld scripts seems beyond what our linker is ever going to do! Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Duncan Coutts | Sent: 16 May 2004 16:48 | To: GHC-users list | Subject: ghci and ld scripts | | So here's the problem: | | We have a Haskell binding to a C library (one of the gtk extension libs) | which uses the pthread library. So we put "pthread" in the | extra_libraries section of our ghc package conf file. | | This works fine when building standalone programs, however when we try | and use this package in ghci we get this error: | | ... | Loading package gtk2 ... linking ... done. | Loading package sourceview ... ghc-6.2.1: can't load .so/.DLL for: | pthread (/usr/lib/libpthread.so: invalid ELF header) | | Inspecting /usr/lib/libpthread.so we find that indeed it is not a .so | file but a gnu ld script: | | /* GNU ld script | Use the shared library, but some functions are only in | the static library, so try that secondarily. */ | OUTPUT_FORMAT(elf32-i386) | GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a ) | | So we should get ghci to dynamically load /lib/libpthread.so.0, however | there is no way to specify this in the package.conf file. | | It turns out that we don't need ghci to load this .so because it is a | dep of another .so that we do load, however if I leave it out then | building standalone progs would fail to link. | | Has anyone come across this before? How do you deal with it? | | Duncan | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Simon Peyton-Jones wrote:
We've no idea what to do here. In your case it'd be possible to just ignore the script, but presumably not so in general. [...]
I've just made a quick test on my SuSE 9.1 Linux and it seems to be the case that an explicit "-lpthread" is not necessary anymore, even for programs using pthread calls. Strange, but handy. :-) Could you try if things work for you without adding "pthread" to extra_libraries? Another way would be using some kind of autoconf/shell magic to test for the linker script and install a link to /lib/libpthread.so.0 with the name "myownpthread.so" to the installation directory of your package and add "myonwpthread" to extra_libraries. Ugly... Cheers, S.

On Fri, 2004-05-21 at 17:22, Sven Panne wrote:
Simon Peyton-Jones wrote:
We've no idea what to do here. In your case it'd be possible to just ignore the script, but presumably not so in general. [...]
I've just made a quick test on my SuSE 9.1 Linux and it seems to be the case that an explicit "-lpthread" is not necessary anymore, even for programs using pthread calls. Strange, but handy. :-) Could you try if things work for you without adding "pthread" to extra_libraries?
That does seem to work, thanks. The joys of linker magic. I guess that solves my immediate problem, but doesn't help answer Simon's question of what we do in general. :-( If we were using .so's for packages rather than .o's then we'd be using the system linker and we wouldn't have the problem, but that is a longer term project. Duncan
participants (3)
-
Duncan Coutts
-
Simon Peyton-Jones
-
Sven Panne