Skip to content

Commit

Permalink
haskell-stack: Fix build from source, support M1
Browse files Browse the repository at this point in the history
- Fixed building from source.

  Due to recent update of aeson-2.0.0.0, stack can no longer be built
  with cabal-install. So I patched stack to freeze cabal dependencies
  using stackage 17.15 LTS.

- Add Apple Silicon support.

  HEAD version of stack has already been patched to support Apple
  Silicon. However, the next release containing that patch hasn't
  release yet. So I manually patched stack v2.7.3 to support Apple
  Silicon.

- Add llvm@12 as a dependency only on ARM

  All ghc versions before 9.2.1 requires LLVM Code Generator as a
  backend on ARM.

Fixes Homebrew#94796

Reference:
  commercialhaskell/stack#5562
  commercialhaskell/stack#5677
  • Loading branch information
simnalamburt committed Feb 17, 2022
1 parent ebbf313 commit 9680993
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions Formula/haskell-stack.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
class HaskellStack < Formula
desc "Cross-platform program for developing Haskell projects"
homepage "https://haskellstack.org/"
url "https://github.com/commercialhaskell/stack/archive/v2.7.3.tar.gz"
sha256 "37f4bc0177534782609ec3a67ec413548d3f2cabff7c4c0bc8a92a36e49c6877"
license "BSD-3-Clause"
head "https://github.com/commercialhaskell/stack.git", branch: "master"

stable do
url "https://github.com/commercialhaskell/stack/archive/v2.7.3.tar.gz"
sha256 "37f4bc0177534782609ec3a67ec413548d3f2cabff7c4c0bc8a92a36e49c6877"

# Due to recent update of aeson-2.0.0.0, stack can no longer be built with
# cabal-install. So I patched stack to freeze cabal dependencies using
# stackage 17.15 LTS.
#
# Reference:
# https://github.com/commercialhaskell/stack/pull/5677
patch do
url "https://github.com/commercialhaskell/stack/commit/05951f21.patch?full_index=1"
sha256 "bc12787bffb450ac7246a34987e2d546325e6ecb0b5c75f6bfccf1b32f9693aa"
end

# HEAD version of stack has already been patched to support Apple Silicon.
# However, the next release containing that patch hasn't release yet. So I
# manually patched stack v2.7.3 to support Apple Silicon.
#
# Reference:
# https://github.com/commercialhaskell/stack/pull/5562
patch do
url "https://github.com/commercialhaskell/stack/commit/32b80476.patch?full_index=1"
sha256 "36e09f68c951adb0b35a0d9a510c9c367554058d690c667636147f1cb483ef8d"
end
end

livecheck do
url :stable
strategy :github_latest
Expand All @@ -21,12 +46,22 @@ class HaskellStack < Formula

depends_on "cabal-install" => :build
depends_on "ghc" => :build
# All ghc versions before 9.2.1 requires LLVM Code Generator as a backend on
# ARM. GHC 8.10.7 user manual recommend use LLVM 9 through 12 and we met some
# unknown issue with LLVM 13 before so conservatively use LLVM 12 here.
#
# References:
# https://downloads.haskell.org/~ghc/8.10.7/docs/html/users_guide/8.10.7-notes.html
# https://gitlab.haskell.org/ghc/ghc/-/issues/20559
depends_on "llvm@12" if Hardware::CPU.arm?

uses_from_macos "zlib"

def install
system "cabal", "v2-update"
system "cabal", "v2-install", *std_cabal_v2_args

bin.env_script_all_files libexec, PATH: "${PATH}:#{Formula["llvm@12"].opt_bin}" if Hardware::CPU.arm?
end

test do
Expand Down

0 comments on commit 9680993

Please # to comment.