[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

#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

#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