Ticket #2745 (closed merge: fixed)

Opened 5 years ago

Last modified 5 years ago

ghc -shared broken

Reported by: simonmar Owned by: igloo
Priority: high Milestone: 6.10.2
Component: Compiler Version: 6.10.1
Keywords: Cc: lennart@…, clemens@…
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Lennart reports that ghc -shared is broken:

$ cat Foo.hs
{-# LANGUAGE ForeignFunctionInterface #-}
module Foo where

f :: Int -> Int
f x = x+1

foreign export ccall f :: Int -> Int

$ ghc -shared Foo.hs
Foo.o:fake:(.text+0x21): undefined reference to `stg_INTLIKE_closure'
Foo.o:fake:(.text+0x28): undefined reference to `stg_ap_pp_info'
Foo_stub.o:Foo_stub.c:(.text+0x9): undefined reference to `rts_lock'
Foo_stub.o:Foo_stub.c:(.text+0x1a): undefined reference to `rts_mkInt'
Foo_stub.o:Foo_stub.c:(.text+0x2e): undefined reference to `rts_apply'
Foo_stub.o:Foo_stub.c:(.text+0x42): undefined reference to `rts_apply'
Foo_stub.o:Foo_stub.c:(.text+0x55): undefined reference to `rts_evalIO'
Foo_stub.o:Foo_stub.c:(.text+0x67): undefined reference to
`rts_checkSchedStatus'
Foo_stub.o:Foo_stub.c:(.text+0x72): undefined reference to `rts_getInt'
Foo_stub.o:Foo_stub.c:(.text+0x7c): undefined reference to `rts_unlock'
Foo_stub.o:Foo_stub.c:(.text+0x97): undefined reference to `getStablePtr'
.....

Change History

Changed 5 years ago by simonmar

  • cc lennart@… added

Changed 5 years ago by simonmar

  • cc clemens@… added

The culprit appears to be this patch:

Mon Oct 13 21:14:26 BST 2008  Clemens Fruhwirth <clemens@endorphin.org>
  * Do not filter the rts from linked libraries in linkDynLib as Windows does not allo
w unresolved symbols
    {
    hunk ./compiler/main/DriverPipeline.hs 1497
    -    let pkgs_no_rts = filter ((/= rtsPackageId) . packageConfigId) pkgs
    hunk ./compiler/main/DriverPipeline.hs 1498
    +    -- On Windows we need to link the RTS import lib as Windows does
    +    -- not allow undefined symbols.
    +#if defined(mingw32_HOST_OS)
    +    let pkgs_no_rts = filter ((/= rtsPackageId) . packageConfigId) pkgs
    +#else
    +    let pkgs_no_rts = pkgs
    +#endif
    }

but the patch doesn't seem to match the description - should it be !defined(mingw32_HOST_OS)?

We need a test for this too.

Changed 5 years ago by simonmar

  • owner set to igloo
  • type changed from bug to merge

Fixed, and I have a test almost ready to commit too.

Fri Nov  7 09:29:25 GMT 2008  Simon Marlow <marlowsd@gmail.com>
  * Bugfix for patch "Do not filter the rts from linked libraries..." (#2745)
  The sense of the #ifdef was wrong

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged

Note: See TracTickets for help on using tickets.