137 lines
5.4 KiB
Ruby
137 lines
5.4 KiB
Ruby
class Ghc < Formula
|
|
desc "Glorious Glasgow Haskell Compilation System"
|
|
homepage "https://haskell.org/ghc/"
|
|
url "https://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-src.tar.xz"
|
|
sha256 "90fb20cd8712e3c0fbeb2eac8dab6894404c21569746655b9b12ca9684c7d1d2"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "950b8ce79292f62f01327d7dbec598187ee5f26360c1393b6de56a4bc3dc237d" => :el_capitan
|
|
sha256 "6ed36065af3ee25688d104bd1b15be7a8e531a31af0d375f4b8b5b331a13de98" => :yosemite
|
|
sha256 "ea383499e518fa6ac12f472ae3e245eebec9ab6b7c4ad2396a61911d8c1f58c5" => :mavericks
|
|
end
|
|
|
|
option "with-test", "Verify the build using the testsuite"
|
|
deprecated_option "tests" => "with-test"
|
|
deprecated_option "with-tests" => "with-test"
|
|
|
|
resource "gmp" do
|
|
url "http://ftpmirror.gnu.org/gmp/gmp-6.1.0.tar.bz2"
|
|
mirror "https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2"
|
|
mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2"
|
|
sha256 "498449a994efeba527885c10405993427995d3f86b8768d8cdf8d9dd7c6b73e8"
|
|
end
|
|
|
|
if MacOS.version <= :lion
|
|
fails_with :clang do
|
|
cause <<-EOS.undent
|
|
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
|
|
|
|
resource "binary" do
|
|
if MacOS.version <= :lion
|
|
url "https://downloads.haskell.org/~ghc/7.6.3/ghc-7.6.3-x86_64-apple-darwin.tar.bz2"
|
|
sha256 "f7a35bea69b6cae798c5f603471a53b43c4cc5feeeeb71733815db6e0a280945"
|
|
else
|
|
url "https://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-x86_64-apple-darwin.tar.xz"
|
|
sha256 "06ec33056b927da5e68055147f165f873088f6812fe0c642c4c78c9a449fbc42"
|
|
end
|
|
end
|
|
|
|
resource "testsuite" do
|
|
url "https://downloads.haskell.org/~ghc/8.0.1/ghc-8.0.1-testsuite.tar.xz"
|
|
sha256 "bc57163656ece462ef61072559d491b72c5cdd694f3c39b80ac0f6b9a3dc8151"
|
|
end
|
|
|
|
def install
|
|
# 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",
|
|
"--with-ld=ld", # Avoid hardcoding superenv's ld.
|
|
"--with-gcc=#{ENV.cc}"] # Always.
|
|
|
|
if ENV.compiler == :clang
|
|
args << "--with-clang=#{ENV.cc}"
|
|
elsif ENV.compiler == :llvm
|
|
args << "--with-gcc-4.2=#{ENV.cc}"
|
|
end
|
|
|
|
# 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
|
|
args << "--with-nm=#{`xcrun --find nm-classic`.chomp}" if MacOS.clang_build_version >= 703
|
|
|
|
resource("binary").stage do
|
|
binary = buildpath/"binary"
|
|
|
|
system "./configure", "--prefix=#{binary}", *args
|
|
ENV.deparallelize { system "make", "install" }
|
|
|
|
ENV.prepend_path "PATH", binary/"bin"
|
|
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
|