[GHC] #12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs
#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs ------------------------------+--------------------------------- Reporter: pl | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Windows Architecture: x86 | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ------------------------------+--------------------------------- GHCi (win32, v8.0.1) gives strange unknown symbols when being run using a library that interfaces code written in C or C++. Compiled code runs fine. As an example I use the eigen-2.1.6 package from hackage. However, it should be noted that I get a similar error message when trying to link a package that uses libgsl (gsl has been compiled with the mingw-gcc that ships with haskell-platform). When I compile the little script from the eigen-manual on hackage {{{#!hs module Main where import Data.Eigen.Matrix import Data.Eigen.LA main = do let a :: MatrixXd a = fromList [[1,2,3], [4,5,6], [7,8,10]] b = fromList [[3],[3],[4]] x = solve ColPivHouseholderQR a b putStrLn "Here is the matrix A:" >> print a putStrLn "Here is the vector b:" >> print b putStrLn "The solution is:" >> print x }}} I get (as expected): {{{ Here is the matrix A: Matrix 3x3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 10.0 Here is the vector b: Matrix 3x1 3.0 3.0 4.0 The solution is: Matrix 3x1 -2.0 1.0000000000000016 0.9999999999999988 }}} However, when I try to run it in GHCi I get {{{ GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( test.hs, interpreted ) Ok, modules loaded: Main. *Main> main ghc.exe: C:/Program Files (x86)/Haskell Platform/8.0.1/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libstdc++.a: unknown symbol `___emutls_get_address' ghc.exe: Could not on-demand load symbol '___cxa_get_globals' ghc.exe: C:/Program Files (x86)/Haskell Platform/8.0.1/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libstdc++.a: unknown symbol `___cxa_get_globals' ghc.exe: Could not on-demand load symbol '___cxa_begin_catch' ghc.exe: D:\Users\U439644\AppData\Roaming\cabal\i386-windows- ghc-8.0.1\eigen-2.1.6-6ZlfU8NIal9qgw3j5GclW\HSeigen-2.1.6-6 ZlfU8NIal9qgw3j5GclW.o: unknown symbol `___cxa_begin_catch' ghc.exe: unable to load package `eigen-2.1.6' }}} I tried the same on OS X using GHCi v8.0.1. There everything works as expected. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12496> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by pl): * failure: None/Unknown => GHC rejects valid program -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12496#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: #11072 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => closed * resolution: => duplicate * related: => #11072 Comment: Hi Thanks for the report. This will be fixed by #11072, In the mean time there are several ways to work around this. including editing the cabal file for `Eigen` to include `stdc++-6` instead of `stdc++`. This will get it to work in GHCi but the executable will need `libstdc++-6.dll` to work. As a side note, even if you do this, Eigen needs to #ifdef some posix calls that are named differently on Windows. e.g. `strdup` on Windows is `_strdup`. The compiled version works because mingw-w64 has them still defined under their deprecated names. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12496#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: #11072 | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * differential: => Phab:D2478 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12496#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12496: GHCi reports unknown symbols in Win32 when linking C and C++ libs -------------------------------------+------------------------------------- Reporter: pl | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: duplicate | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHC rejects | Test Case: valid program | Blocked By: | Blocking: Related Tickets: #11072 | Differential Rev(s): Phab:D2478 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0/ghc" e5ecb20/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0" Added support for deprecated POSIX functions on Windows. Summary: With the introduction of 8.0.1 We've stopped supporting in GHCi the use of POSIX functions under their deprecated names on Windows. This to be compatible with object and libraries from the most popular compilers on the platform (Microsoft and Intel compilers). However this brings a confusing disparity between the compiled and interpreted behavior since MingW-W64 does support the deprecated names. Also It seems clear that package writers won't update their packages to properly support Windows. As such I have added redirects in the RTS for the deprecated functions as listed on https://msdn.microsoft.com/en-us/library/ms235384.aspx. This won't export the functions (as in, they won't be in the symbol table of compiled code for the RTS.) but we inject them into the symbol table of the dynamic linker at startup. Test Plan: ./validate and make test TEST="ffi017 ffi021" Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd Reviewed By: simonmar, bgamari Subscribers: RyanGlScott, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2500 GHC Trac Issues: #12209, #12497, #12496 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12496#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC