Customising Cabal libraries (I think?)

Perhaps it's just better to describe my problem.

I'm developing a Haskell library. But part of the library is written in C, and another part actually in raw LLVM. To actually get GHC to spit out the code I want I have to follow this process:

  • Run ghc -emit-llvm on both the code that uses the Haskell module and the "Main" module.
  • Run clang -emit-llvm on the C file
  • Now I've got three .ll files from above. I add the part of the library I've handwritten in raw LLVM and llvm-link these into one .ll file.
  • I then run LLVM's opt on the linked file.
  • Lastly, I feed the LLVM bitcode fileback into GHC (which pleasantly accepts it) and produces an executable.
  • This process (with appropriate optimisation settings of course) seems to be the only way I can inline code from C, removing the function call overhead. Since many of these C functions are very small this is significant.

    Anyway, I want to be able to distribute the library and for users to be able to use it as painlessly as possible, whilst still gaining the optimisations from the process above. I understand it's going to be a bit more of a pain than an ordinary library (for example, you're forced to compile via LLVM) but as painlessly as possible is what I'm looking for advice for.

    Any guidance will be appreciated, I don't expect a step by step answer because I think it will be complex, but just some ideas would be helpful.

    链接地址: http://www.djcxy.com/p/43222.html

    上一篇: 穷尽模式匹配只是因为我遗漏了`否则=`?

    下一篇: 定制Cabal库(我认为?)