haskell - LLVM-General segmentation fault -
i have 2 llvm.general.module modules, , b. goal link b , write assembly file. playing moment toy program see how use llvm-general interface. have used llvm-general-pure package create llvm.general.ast modules compiler backends.
i take these asts c++ world (llvm.general.module), link them, , write assembly. found error while linking c++ modules, have feeling error in way produce c++ objects. here did:
convasttomode ast = <- withcontext $ \context -> x <- runerrort $ withmodulefromast context ast $ \mod -> return mod return x return
comment: couldn't find function of type module -> module (like moduleast make ast c++ object when using, withmodulefromllvmassembly) give withmodulefromast, module back, used unit. reading of can module ast, , want module, took it. guessing wrong, figured something.
when execute code on 1 of llvm.general.ast.module modules, code seems run fine. when try use it, breaks. example, if x llvm.general.ast.module, , do
mod <- convasttomode x case mod of left _ -> error "" right mod' -> assemb <- modulellvmassembly mod putstrln assemb
i segmentation fault.
llvm-general-3.4.3.0 llvm-3.4
update: tried following:
writeasttollvmassembly ast filename = withcontext $ \context -> runerrort $ withmodulefromast context ast $ \mod -> runerrort $ writellvmassemblytofile (file filename) mod return ()
gives:
*** error in `./llvmimportandlinktest': munmap_chunk(): invalid pointer: 0x00000000012db000 *** aborted (core dumped)
however,
showllvmassfromast ast = str <- withcontext $ \context -> str2 <- runerrort $ withmodulefromast context ast $ \mod -> str3 <- modulellvmassembly mod return str3 return str2 case str of left _ -> error "ast not convertible string" right st -> return st
gives no problems.
llvm-general.3.4.3.0 llvm-3.4
for example, llvm.general.ast.module found http://lpaste.net/106407
that pretty printed version of ast obtained uploading http://lpaste.net/106408 llvm-general.
that llvm assembly generated clang compiling c file.
solution upgrade version of llvm-general changing llvm-general dependency llvm-general >= 3.4.3
fixes known bug in implementation.
Comments
Post a Comment