How to connect to a Haskell static environment using cabal and stack without hard coding the ghc version?

I have a project that exports a shared static library and I use the next part in the file project.cabal

executable libsxp.so
    main-is:       Somefile.hs
    default-language: Haskell2010
    ghc-options: -shared -dynamic -fPIC -lHSrts-ghc7.10.2

The GHC version is controlled using Stack, so is there a way I can either get it, or add a version to do it -lHSrts-ghc{version}, or is there some kind of configuration for it? I tried to install

stack build --ghc-options='-O0 -lHSrts-ghc7.10.2' 

but he does not seem to choose him.

Also, to clarify, cabal installStack is called, not by me.

+4
source share
2 answers

Does this file bondage work? If so, then it should be enough to do something like this:

executable libsxp.so
    ghc-options: -shared -dynamic -fPIC
    if impl (ghc >= 7.10.2 && < 7.10.3)
        ghc-options: -lHSrts-ghc7.10.2
    else if impl (ghc >= 7.10.3 && < 7.10.4)
        ghc-options: -lHSrts-ghc7.10.3
    else if ...

, .so? .

, 7.10.2, 7.10.3? stack exec -- ghc --version

+3

: fooobar.com/questions/580146/...

configure Cabal, script, sdl-config . $foo.buildinfo.in, $foo.buildinfo, Cabal .


cabal build-type Configure project.cabal. cabal. Configure Setup.hs :

import Distribution.Simple
main = defaultMainWithHooks autoconfUserHooks

GHC @GHC_VERSION@ project.buildinfo.in:

ghc-options: -lHSrts-ghc@GHC_VERSION@

, configure bash script, GHC mgsloan project.buildinfo, @GHC_VERSION@ varibale in project.buildinfo.in:

GHC_VERSION=$(stack exec -- ghc-pkg field ghc version --simple-output)
sed 's,@GHC_VERSION@,'"$GHC_VERSION"',' project.buildinfo.in > project.buildinfo

configure script, project.buildinfo project.cabal.


extra-source-files project.buildinfo.in; extra-tmp-files project.buildinfo project.cabal.

: fooobar.com/questions/464829/...

+1

All Articles