Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cabal: conditionally override a flag default value

Is there any way to rewrite either:

flag llvm
    description: compile via LLVM
    default    : if os(mingw32)
                   False
                 else
                   True

or

flag llvm
    description: compile via LLVM
    default    : True

if os(mingw32)
    ?SET-LLVM=False?

and get cabal to work with it?


Note:

Further down in the same file the llvm flag is used like:

if flag(llvm)
  ghc-options: -fllvm -optlo-O3

and there are many other single high-level flags that translate to multiple ghc-options entries, such as static to -static -optl-static.

like image 661
Cetin Sert Avatar asked Sep 02 '25 02:09

Cetin Sert


1 Answers

You can do something like this:

flag llvm
    description: compile via LLVM
    default    : True

-- ...

Executable foo
    if flag(llvm) && !os(windows)
        ghc-options: -fllvm -optlo-O3
like image 110
Daniel Wagner Avatar answered Sep 05 '25 20:09

Daniel Wagner