[GHC] #10492: rpath & shared libraries in ghc 7.10.1

#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: | Owner: artella.coding | Status: new Type: bug | Milestone: 7.10.2 Priority: high | Version: 7.10.1 Component: Compiler | Operating System: Linux Keywords: | Type of failure: Runtime crash Architecture: | Blocked By: Unknown/Multiple | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Suppose that I have : {{{#!hs //test.h int add(int a, int b); }}} {{{#!hs //test.c int add(int a, int b){ return (a + b); } }}} {{{#!hs //mylib.c #include "test.h" int testAdd(){ return add(2,3); } }}} Then I compile via : {{{#!hs gcc -shared -o libDir/libtest.so test.c gcc -fPIC -c mylib.c -o mylib.o gcc -shared -o libDir/libMy.so mylib.o -L./libDir -l test -Wl,-rpath=./libDir }}} Then I have Main.hs with : {{{#!hs module Main where import Foreign.C.Types foreign import ccall "testAdd" c_testAdd :: CInt -> CInt -> IO (CInt) main = do result <- c_testAdd 3 4 print result }}} and I have the associated cabal file : {{{#!hs name: illustrate version: 0.1.0.0 build-type: Simple cabal-version: >=1.10 executable illustrate main-is: Main.hs build-depends: base >=4.8 && <4.9 default-language: Haskell2010 extra-libraries: test My extra-lib-dirs: ./libDir }}} Then `cabal repl` works fine, but upon `cabal run` we get the following error : {{{ cabal run Preprocessing executable 'illustrate' for illustrate-0.1.0.0... [1 of 1] Compiling Main ( Main.hs, dist/build/illustrate /illustrate-tmp/Main.o ) Linking dist/build/illustrate/illustrate ... Running illustrate... /home/linux/Downloads/illustrate_withDir/dist/build/illustrate/illustrate: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory }}} In https://ghc.haskell.org/trac/ghc/ticket/10442#comment:8 trommler mentions that the problem arises because `-rpath` is not fed as an argument for `libtest.so` during linking. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: artella.coding | Owner: trommler Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by trommler): * owner: => trommler * priority: high => normal Comment: Setting priority to normal. The issue affects only C libraries that are not installed in a standard location and there is a workaround https://ghc.haskell.org/trac/ghc/ticket/10442#comment:8 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: artella.coding | Owner: trommler Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Isn't this a Cabal bug, not a GHC bug? We don't expect GHC to automatically add rpath entries for C libraries it is told to link against, do we? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Isn't this a Cabal bug, not a GHC bug? We don't expect GHC to automatically add rpath entries for C libraries it is told to link against, do we? I am not sure anymore that this is actually a bug. If an executable is
#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: artella.coding | Owner: trommler Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by trommler): Replying to [comment:2 rwbarton]: linked against a shared object that is not found in a standard location the user needs to provide the extra RPATH (or RUNPATH) or set LD_LIBRARY_PATH accordingly. So what I said in comment:1 is not a workaround but the actual fix. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: artella.coding | Owner: trommler Type: bug | Status: closed Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: wontfix | Keywords: Operating System: Linux | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by trommler): * status: new => closed * resolution: => wontfix Comment: Closing as won't fix. Please reopen if you disagree. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10492: rpath & shared libraries in ghc 7.10.1 -------------------------------------+------------------------------------- Reporter: artella.coding | Owner: trommler Type: bug | Status: closed Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: wontfix | Keywords: Operating System: Linux | Architecture: Type of failure: Runtime crash | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by artella.coding): Replying to [comment:4 trommler]:
Closing as won't fix. Please reopen if you disagree.
Hi yes I agree!. Thanks rwbarton and trommler for your help. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10492#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC