问题
I don't repeat more than necessary, brief summary: Following the Adder example from this tutorial on a machine with win7 (64) with VS 2010. But I don't use C++ but plain C.
When using the cl (MS compiler) with cl /Zi (and no other flag) it works like expected.
If not use /Zi and then try to execute the exe goes into flames.
Why? (There must be some compiler/link options that make some init in the start of the haskell dll go wrong )
EDIT: Some investigation:
/Zi does not affect optimizations. However, /Zi does imply /debug; see /DEBUG (Generate Debug Info) for more information.
/DEBUG changes the defaults for the /OPT option from REF to NOREF and from ICF to NOICF (so, you will need to explicitly specify /OPT:REF or /OPT:ICF).]
/OPT:ICF can result in the same address being assigned to different functions or read only data members (const variables compiled with /Gy). So, /OPT:ICF can break a program that depends on the address of functions or read-only data members being different. See /Gy (Enable Function-Level Linking) for more information.
Can someone confirm that /OPT:ICF will affect the loading of a Haskell/GHC compiled shared library(dll) ?
来源:https://stackoverflow.com/questions/5829170/ghc-foreign-hs-init-hs-add-root-crashes