[GHC] #9498: GHC links against unversioned .so files

GHC ghc-devs at haskell.org
Wed Nov 12 23:38:03 UTC 2014


#9498: GHC links against unversioned .so files
-------------------------------------+-------------------------------------
              Reporter:  Kritzefitz  |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  low         |          Version:  7.6.3
             Component:  Compiler    |         Keywords:  Debian
  (FFI)                              |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Unknown
      Operating System:  Linux       |       Blocked By:
       Type of failure:  Other       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by thomie):

 Kritzefitz: thank you for the report. I am adding an example here for
 later reference. Please let me me know if there are any mistakes in the
 text below, I just learned this stuff tonight.

 On Ubuntu 14.04, `libbsd.so` (unversioned) is a symbolic link to the file
 `libbsd.so.0.6.0` (versioned). That symbolic link is created by the
 `libbsd-dev` (dev) package, while the library file is installed by the
 `libbsd0` (runtime) package.

 {{{
 $ ll /usr/lib/x86_64-linux-gnu/libbsd.so
 lrwxrwxrwx 1 root root 37 Mar 20  2014 /usr/lib/x86_64-linux-gnu/libbsd.so
 -> /lib/x86_64-linux-gnu/libbsd.so.0.6.0

 $ dpkg -S /usr/lib/x86_64-linux-gnu/libbsd.so
 libbsd-dev: /usr/lib/x86_64-linux-gnu/libbsd.so

 $ dpkg -S /lib/x86_64-linux-gnu/libbsd.so.0.6.0
 libbsd0:amd64: /lib/x86_64-linux-gnu/libbsd.so.0.6.0
 }}}

 This is a small program (called `testbsd.hs`) that calls a function in the
 libbsd library via the foreign function interface:
 {{{#!haskell
 module Main where

 import Foreign.C.Types

 foreign import ccall "arc4random"
   version :: CUInt

 main = print version
 }}}

 GHC links this program to `libbsd.so.0`, not `libbsd.so.0.6.0`, so the dev
 package will be needed to run it:
 {{{
 $ ghc --make -lbsd testbsd.hs
 [1 of 1] Compiling Main             ( testbsd.hs, testbsd.o )
 Linking testbsd ...

 $ ldd testbsd
         ...
         libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0
 (0x00007faef5c2c000)
         ...

 $ ./testbsd
 1131902945
 }}}

 Note that some runtime packages do create the link from the unversioned to
 the versioned library themselves. This seems to be in particular true for
 all libraries in the `/lib/` directory. For example for `libpng`:

 {{{
 $ ll /lib/x86_64-linux-gnu/libpng12.so.0
 lrwxrwxrwx 1 root root 18 Apr  1  2014 /lib/x86_64-linux-gnu/libpng12.so.0
 -> libpng12.so.0.50.0

 $ dpkg -S /lib/x86_64-linux-gnu/libpng12.so.0.50.0
 libpng12-0:amd64: /lib/x86_64-linux-gnu/libpng12.so.0.50.0

 $ dpkg -S /lib/x86_64-linux-gnu/libpng12.so.0
 libpng12-0:amd64: /lib/x86_64-linux-gnu/libpng12.so.0

 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9498#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list