Search code examples
macoshaskellghccabal

Build Haskell macOS executable with a deployment target


I want to distribute a gui app built with Haskell, but when I try to open it on a different Mac (with an older macOS) it fails.

This seems to be due to the minos value in the LC_BUILD_VERSION mach-o load-command:

% otool -l ./lamdu | grep minos
    minos 11.0

How can I specify to GHC/Cabal/stack the deployment target to use (the equivalent to Clang's -mmacosx-version-min flag)?


Solution

  • Adding these lines to the .cabal file did the trick:

      if os(darwin)
        ld-options: -mmacosx-version-min=10.9
    

    Even though the build through stack shows warnings that not everything (i.e the used Haskell libs) was build for this deployment target, the executable worked fine when testing on an older macOS