167 lines
6.3 KiB
Ruby
167 lines
6.3 KiB
Ruby
require "language/haskell"
|
|
|
|
class Ghc < Formula
|
|
include Language::Haskell::Cabal
|
|
|
|
desc "Glorious Glasgow Haskell Compilation System"
|
|
homepage "https://haskell.org/ghc/"
|
|
url "https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-src.tar.xz"
|
|
sha256 "bb8ec3634aa132d09faa270bbd604b82dfa61f04855655af6f9d14a9eedc05fc"
|
|
|
|
bottle do
|
|
sha256 "85937c1fca6a2979a8b0d0634b8353e44319fd21d27e7dd0e67e23270fb94a3b" => :high_sierra
|
|
sha256 "2c482188bcc18cc7976d7519258fe9a81adee93587a84af5c314eac9660cf624" => :sierra
|
|
sha256 "e12f013930d7ca6b988fb946ace0b58be5b5c057270fd3c3433524739f9af374" => :el_capitan
|
|
end
|
|
|
|
head do
|
|
url "https://git.haskell.org/ghc.git", :branch => "ghc-8.2"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
|
|
resource "cabal" do
|
|
url "https://hackage.haskell.org/package/cabal-install-1.24.0.2/cabal-install-1.24.0.2.tar.gz"
|
|
sha256 "2ac8819238a0e57fff9c3c857e97b8705b1b5fef2e46cd2829e85d96e2a00fe0"
|
|
end
|
|
end
|
|
|
|
option "with-test", "Verify the build using the testsuite"
|
|
option "without-docs", "Do not build documentation (including man page)"
|
|
deprecated_option "tests" => "with-test"
|
|
deprecated_option "with-tests" => "with-test"
|
|
|
|
depends_on :macos => :lion
|
|
depends_on "python3" => :build if build.bottle? || build.with?("test")
|
|
depends_on "sphinx-doc" => :build if build.with? "docs"
|
|
|
|
resource "gmp" do
|
|
url "https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
|
|
mirror "https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz"
|
|
mirror "https://ftpmirror.gnu.org/gmp/gmp-6.1.2.tar.xz"
|
|
sha256 "87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912"
|
|
end
|
|
|
|
if MacOS.version <= :lion
|
|
fails_with :clang do
|
|
cause <<~EOS
|
|
Fails to bootstrap ghc-cabal. Error is:
|
|
libraries/Cabal/Cabal/Distribution/Compat/Binary/Class.hs:398:14:
|
|
The last statement in a 'do' block must be an expression
|
|
n <- get :: Get Int getMany n
|
|
EOS
|
|
end
|
|
end
|
|
|
|
# https://www.haskell.org/ghc/download_ghc_8_0_1#macosx_x86_64
|
|
# "This is a distribution for Mac OS X, 10.7 or later."
|
|
resource "binary" do
|
|
url "https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-x86_64-apple-darwin.tar.xz"
|
|
sha256 "f90fcf62f7e0936a6dfc3601cf663729bfe9bbf85097d2d75f0a16f8c2e95c27"
|
|
end
|
|
|
|
resource "testsuite" do
|
|
url "https://downloads.haskell.org/~ghc/8.2.2/ghc-8.2.2-testsuite.tar.xz"
|
|
sha256 "927ff939f46a0f79aa87e16e56e0a024a288c78259bed874cb15aa96a653566c"
|
|
end
|
|
|
|
def install
|
|
ENV["CC"] = ENV.cc
|
|
ENV["LD"] = "ld"
|
|
|
|
# Setting -march=native, which is what --build-from-source does, fails
|
|
# on Skylake (and possibly other architectures as well) with the error
|
|
# "Segmentation fault: 11" for at least the following files:
|
|
# utils/haddock/dist/build/Haddock/Backends/Hyperlinker/Types.dyn_o
|
|
# utils/haddock/dist/build/Documentation/Haddock/Types.dyn_o
|
|
# utils/haddock/dist/build/Haddock/GhcUtils.dyn_o
|
|
# utils/haddock/dist/build/Paths_haddock.dyn_o
|
|
# utils/haddock/dist/build/ResponseFile.dyn_o
|
|
# Setting -march=core2 works around the bug.
|
|
# Reported 22 May 2016: https://ghc.haskell.org/trac/ghc/ticket/12100
|
|
# Note that `unless build.bottle?` avoids overriding --bottle-arch=[...].
|
|
ENV["HOMEBREW_OPTFLAGS"] = "-march=#{Hardware.oldest_cpu}" unless build.bottle?
|
|
|
|
# Build a static gmp rather than in-tree gmp, otherwise it links to brew's.
|
|
gmp = libexec/"integer-gmp"
|
|
|
|
# MPN_PATH: The lowest common denominator asm paths that work on Darwin,
|
|
# corresponding to Yonah and Merom. Obviates --disable-assembly.
|
|
ENV["MPN_PATH"] = "x86_64/fastsse x86_64/core2 x86_64 generic" if build.bottle?
|
|
|
|
# GMP *does not* use PIC by default without shared libs so --with-pic
|
|
# is mandatory or else you'll get "illegal text relocs" errors.
|
|
resource("gmp").stage do
|
|
system "./configure", "--prefix=#{gmp}", "--with-pic", "--disable-shared"
|
|
system "make"
|
|
system "make", "check"
|
|
ENV.deparallelize { system "make", "install" }
|
|
end
|
|
|
|
args = ["--with-gmp-includes=#{gmp}/include",
|
|
"--with-gmp-libraries=#{gmp}/lib"]
|
|
|
|
# As of Xcode 7.3 (and the corresponding CLT) `nm` is a symlink to `llvm-nm`
|
|
# and the old `nm` is renamed `nm-classic`. Building with the new `nm`, a
|
|
# segfault occurs with the following error:
|
|
# make[1]: * [compiler/stage2/dll-split.stamp] Segmentation fault: 11
|
|
# Upstream is aware of the issue and is recommending the use of nm-classic
|
|
# until Apple restores POSIX compliance:
|
|
# https://ghc.haskell.org/trac/ghc/ticket/11744
|
|
# https://ghc.haskell.org/trac/ghc/ticket/11823
|
|
# https://mail.haskell.org/pipermail/ghc-devs/2016-April/011862.html
|
|
# LLVM itself has already fixed the bug: llvm-mirror/llvm@ae7cf585
|
|
# rdar://25311883 and rdar://25299678
|
|
if DevelopmentTools.clang_build_version >= 703 && DevelopmentTools.clang_build_version < 800
|
|
args << "--with-nm=#{`xcrun --find nm-classic`.chomp}"
|
|
end
|
|
|
|
resource("binary").stage do
|
|
binary = buildpath/"binary"
|
|
|
|
system "./configure", "--prefix=#{binary}", *args
|
|
ENV.deparallelize { system "make", "install" }
|
|
|
|
ENV.prepend_path "PATH", binary/"bin"
|
|
end
|
|
|
|
if build.head?
|
|
resource("cabal").stage do
|
|
system "sh", "bootstrap.sh", "--sandbox"
|
|
(buildpath/"bootstrap-tools/bin").install ".cabal-sandbox/bin/cabal"
|
|
end
|
|
|
|
ENV.prepend_path "PATH", buildpath/"bootstrap-tools/bin"
|
|
|
|
cabal_sandbox do
|
|
cabal_install "--only-dependencies", "happy", "alex"
|
|
cabal_install "--prefix=#{buildpath}/bootstrap-tools", "happy", "alex"
|
|
end
|
|
|
|
system "./boot"
|
|
end
|
|
system "./configure", "--prefix=#{prefix}", *args
|
|
system "make"
|
|
|
|
if build.bottle? || build.with?("test")
|
|
resource("testsuite").stage { buildpath.install Dir["*"] }
|
|
cd "testsuite" do
|
|
system "make", "clean"
|
|
system "make", "CLEANUP=1", "THREADS=#{ENV.make_jobs}", "fast"
|
|
end
|
|
end
|
|
|
|
ENV.deparallelize { system "make", "install" }
|
|
Dir.glob(lib/"*/package.conf.d/package.cache") { |f| rm f }
|
|
end
|
|
|
|
def post_install
|
|
system "#{bin}/ghc-pkg", "recache"
|
|
end
|
|
|
|
test do
|
|
(testpath/"hello.hs").write('main = putStrLn "Hello Homebrew"')
|
|
system "#{bin}/runghc", testpath/"hello.hs"
|
|
end
|
|
end
|