[GHC] #11531: ghci with ffi to inline assembly results in "the 'impossible'"

#11531: ghci with ffi to inline assembly results in "the 'impossible'" --------------------------------------+--------------------------------- Reporter: isovector | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Keywords: ffi, asm, ghci | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- I'm attempting to run some assembly in Haskell; in order to do that I wrote a FFI to some inline C asm. Attempting to load it in ghci results in: $ g++ -c ffi.cpp -fPIC $ ghci ffi.o Main.hs GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading object (static) ffi.o ... ghc: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): Loading temp shared object failed: /tmp/ghc8684_0/ghc8684_1.so: undefined symbol: _ZNSt8ios_base4InitD1Ev Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug It said to report a bug, so here it is! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11531 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11531: ghci with ffi to inline assembly results in "the 'impossible'" ---------------------------------+-------------------------------------- Reporter: isovector | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: ffi, asm, ghci Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by isovector): * Attachment "ffi.cpp" added. ffi implementation -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11531 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11531: ghci with ffi to inline assembly results in "the 'impossible'" ---------------------------------+-------------------------------------- Reporter: isovector | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: ffi, asm, ghci Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by isovector): * Attachment "ffi.h" added. ffi header -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11531 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11531: ghci with ffi to inline assembly results in "the 'impossible'" ---------------------------------+-------------------------------------- Reporter: isovector | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: ffi, asm, ghci Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by isovector): * Attachment "Main.hs" added. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11531 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11531: ghci with ffi to inline assembly results in "the 'impossible'" ---------------------------------+-------------------------------------- Reporter: isovector | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: duplicate | Keywords: ffi, asm, ghci Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10458 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => duplicate * related: => #10458 Comment: Thanks for the report. Actually, the issue here is that you wrote a C++ program. In order to link C++-compiled object files with the outside world, you need to link with the C++ standard library, `-lstdc++`. So, you could do this: {{{ $ ghci ffi.o Main.hs -lstdc++ }}} This won't actually work in 7.8 or 7.10, because of #10458. But I tested that it does work in current HEAD and 8.0. So, closing as a duplicate of that ticket. In the meantime, you can build your C++ object into a shared library yourself, and load that in ghci: {{{ $ g++ -shared -o libmyffi.so ffi.o $ ghci Main.hs -L. -lmyffi }}} Alternatively, just write your inline assembly in C. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11531#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC