Curious Windows GHCi linker behaviour .o vs. .dll

cg chengang31 at gmail.com
Sat Oct 11 15:04:57 UTC 2014


On 10/11/2014 9:24 PM, Herbert Valerio Riedel wrote:
> Consider the following trivial program:
>
>      module Main where
>
>      foreign import ccall unsafe "time.h tzset" c_tzset :: IO ()
>
>      main :: IO()
>      main = c_tzset
>
[...]
> However, when loaded into GHCi, the RTS linker fails to find `tzset`:
>
>      $ ghci tz.hs
>
[...]
>      ByteCodeLink: can't find label
>      During interactive linking, GHCi couldn't find the following symbol:
>        tzset
>

Strange, I tried it under HaskellPlatform-2014.2, it works, I didn't see 
the
failure. And I tried it in both Windows cmd and msys2 shell.

> However, when I prefix a `_` to the symbol-name in the FFI import, i.e.
>
>      foreign import ccall unsafe "time.h tzset" c_tzset :: IO ()
>

I guess it should read:
foreign import ccall unsafe "time.h _tzset" c_tzset :: IO ()

It works too.

Actually both _tzset and tzset exist in include/time.h, only tzset is old
style name. They will be linked as the same function __imp__tzset.

--
cg





More information about the ghc-devs mailing list