GHC Foreign hs_init/hs_add_root crashes

廉价感情. 提交于 2020-01-03 21:47:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!