[GHC] #13113: Runtime linker errors with CSFML on Windows
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime | Version: 8.0.2 System (Linker) | Keywords: | Operating System: Windows Architecture: | Type of failure: GHCi crash Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Another day, another runtime linker bug on Windows. This time, it's from the CSFML library (written in C++). I observed this when trying to load the [http://hackage.haskell.org/package/SFML SFML] Haskell library in GHCi. To install CSFML in MSYS2: {{{ pacman -S mingw-w64-x86_64-csfml }}} Here's the Haskell code I'm using: {{{#!hs module Main (main) where import Foreign.Ptr newtype CircleShape = CircleShape (Ptr CircleShape) deriving Show foreign import ccall unsafe "sfCircleShape_create" sfCircleShape_create :: IO CircleShape foreign import ccall unsafe "sfCircleShape_copy" sfCircleShape_copy :: CircleShape -> IO CircleShape main :: IO () main = do putStrLn "----------------------" cs1 <- sfCircleShape_create print cs1 cs2 <- sfCircleShape_copy cs1 print cs2 putStrLn "----------------------" }}} Compiling it with `ghc -lcsfml-graphics SFML.hs` on GHC 8.0.2 and HEAD seems to work fine. But if you run it in GHCi, it breaks. With GHCi 8.0.2: {{{ $ ghci -lcsfml-graphics SFML.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help ghc.exe: addDLL: csfml-graphics-2.dll (Win32 error 127): The specified procedure could not be found. ghc.exe: Could not load `csfml-graphics-2.dll'. Reason: addDLL: could not load DLL Loaded GHCi configuration from C:\Users\RyanGlScott\AppData\Roaming\ghc\ghci.conf [1 of 1] Compiling Main ( SFML.hs, interpreted ) Ok, modules loaded: Main.
main
ByteCodeLink: can't find label During interactive linking, GHCi couldn't find the following symbol: sfCircleShape_create This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please send a bug report to: glasgow-haskell-bugs@haskell.org }}} With GHC HEAD: {{{ $ ..\..\..\Software\ghc\inplace\bin\ghci -lcsfml-graphics SFML.hs GHCi, version 8.1.20170108: http://www.haskell.org/ghc/ :? for help ghc-stage2.exe: addDLL: csfml-graphics-2.dll (Win32 error 127): The specified procedure could not be found. ghc-stage2.exe: Could not load `csfml-graphics-2.dll'. Reason: addDLL: could not load DLL Loaded GHCi configuration from C:\Users\RyanGlScott\AppData\Roaming\ghc\ghci.conf Ok, modules loaded: Main (SFML.o).
main ghc-stage2.exe: C:\Users\RyanGlScott\Documents\Hacking\Haskell\SFML.o: unknown symbol `sfCircleShape_create' }}}
I also get the same error with Phab:D2941 (#13082) applied. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * owner: => Phyx- * related: => #13093 Comment: This works in my local tree with changes I haven't put up for review yet {{{ $ echo main | ../inplace/bin/ghc-stage2.exe --interactive -L/mingw64/lib -lcsfml-graphics ../SFML.hs GHCi, version 8.1.20170102: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( ..\SFML.hs, interpreted ) Ok, modules loaded: Main. *Main> ---------------------- CircleShape 0x00000000062fa130 CircleShape 0x00000000062faa60 ---------------------- *Main> Leaving GHCi. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"f41c27d3ffdddbb1afe07de1bd25205061194c93/ghc" f41c27d3/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f41c27d3ffdddbb1afe07de1bd25205061194c93" Slighly clean up symbol loading error. The symbol not found error that is triggered during lazy-loading was a bit chaotic before. This reformats it a bit to: ``` ghc-stage2.exe: | E:\...\libLLVMSupport.a: unknown symbol `_ZN4llvm5APIntC1Ejyb' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm5APInt14AssignSlowCaseERKS0_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm13ConstantRangeC1ENS_5APIntES1_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm14FoldingSetImplC2Ej' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm15LLVMContextImplD1Ev' ghc-stage2.exe: | E:\...\libLLVMLTO.a: unknown symbol `_ZN4llvm11LLVMContextD1Ev' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZNK4llvm5Value10getContextEv' ghc-stage2.exe: ^^ Could not load 'LLVMIsMultithreaded', dependency unresolved. See top entry above. ``` I have also thought about also showing the demangled names, as it may be useful for the end user. `libgcc` seems to provide a method for this so we wouldn't need any extra dependency. Any thoughts on this or would it not be useful? Reviewers: austin, erikd, simonmar, bgamari Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3027 GHC Trac Issues: #13093, #13113 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Merged 2f1017b924740e66f093b0baba62ac0b1528abf8, {{{ commit 2f1017b924740e66f093b0baba62ac0b1528abf8 Author: Tamar Christina <tamar@zhox.com> Date: Tue Feb 14 09:44:53 2017 -0500 Fix ExtraSymbols jump table on Windows. This corrects the `jump islands` calculations for Windows. The code was incorrectly creating a new entry for every `usage` of a symbol instead of every used symbol. e.g. if a symbol is used 5 times it used to create 5 jump islands. This is incorrect and not in line with what the `ELF` and `Mach-O` linkers do. Also since we allocate `n` spaces where `n` is number of symbols, we would quickly run out of space and abort. Test Plan: ./validate Reviewers: simonmar, hvr, erikd, bgamari, austin Reviewed By: bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3026 }}} Phyx, does this resolve this issue? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): No, it requires Phab:D3028 before it is. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Phab:D3028 Wiki Page: | Phab:D3026 -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => patch * differential: => Phab:D3028 Phab:D3026 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13113: Runtime linker errors with CSFML on Windows -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Phyx- Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.2 (Linker) | Resolution: fixed | Keywords: Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #13093 | Differential Rev(s): Phab:D3028 Wiki Page: | Phab:D3026 -------------------------------------+------------------------------------- Changes (by Phyx-): * status: patch => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13113#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC