Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ghc: 7.4.2 build from source

Following the discussion in #13519, ghc gets a major overhaul:

* Add a subformula that installs the ghc binary like before
* Use the ghc binary to build ghc from source
* Force ENV['LD'] = 'ld' to stop an assertion linking with llvm
* Add an option to run the testsuite. 9 unexpected fails atm
* Add a `j1` for an occasional install race
* Remove the patch which was fixed in two commits in Apr 2011.
        47ac5d859493ae0cd8dd02e1b4848f993acc3d5c
        a8d4731456ac3da0a70399e4ab821a763a4c04fb

Fixes #13519

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information...
commit 3cf0db7ed209e9134f21ea326c6260727ed89168 1 parent fb0407f
2bits 2bits authored mikemcquaid committed
Showing with 63 additions and 5 deletions.
  1. +63 −5 Library/Formula/ghc.rb
68 Library/Formula/ghc.rb
View
@@ -13,9 +13,7 @@ def message; <<-EOS.undent
end
end
-class Ghc < Formula
- homepage 'http://haskell.org/ghc/'
- version '7.4.2'
+class Ghcbinary < Formula
if Hardware.is_64_bit? and not build.build_32_bit?
url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-apple-darwin.tar.bz2'
sha1 '7c655701672f4b223980c3a1068a59b9fbd08825'
@@ -23,12 +21,25 @@ class Ghc < Formula
url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-i386-apple-darwin.tar.bz2'
sha1 '60f749893332d7c22bb4905004a67510992d8ef6'
end
+ version '7.4.2'
+end
+
+class Ghctestsuite < Formula
+ url 'https://github.com/ghc/testsuite/tarball/ghc-7.4.2-release'
+ sha1 '6b1f161a78a70638aacc931abfdef7dd50c7f923'
+end
+
+class Ghc < Formula
+ homepage 'http://haskell.org/ghc/'
+ url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-src.tar.bz2'
+ sha1 '73b3b39dc164069bc80b69f7f2963ca1814ddf3d'
env :std
depends_on NeedsSnowLeopard.new
option '32-bit'
+ option 'tests', 'Verify the build using the testsuite in Fast Mode, 5 min'
fails_with :clang do
build 421
@@ -38,9 +49,56 @@ class Ghc < Formula
EOS
end
+ def patches
+ # Explained: http://hackage.haskell.org/trac/ghc/ticket/7040
+ # Discussed: https://github.com/mxcl/homebrew/issues/13519
+ # Remove: version > 7.4.2
+ 'http://hackage.haskell.org/trac/ghc/raw-attachment/ticket/7040/ghc7040.patch'
+ end
+
def install
- system "./configure", "--prefix=#{prefix}"
- system "make install"
+ # Move the main tarball contents into a subdirectory
+ (buildpath+'Ghcsource').install Dir['*']
+
+ # Define where the subformula will temporarily install itself
+ subprefix = buildpath+'subfo'
+
+ Ghcbinary.new.brew do
+ system "./configure", "--prefix=#{subprefix}"
+ # Temporary j1 to stop an intermittent race condition
+ system 'make', '-j1', 'install'
+ ENV.prepend 'PATH', subprefix/'bin', ':'
+ end
+
+ cd 'Ghcsource' do
+ # Fix an assertion when linking ghc with llvm-gcc
+ # https://github.com/mxcl/homebrew/issues/13650
+ ENV['LD'] = 'ld'
+
+ if Hardware.is_64_bit? and not build.build_32_bit?
+ arch = 'x86_64'
+ else
+ arch = 'i386'
+ end
+
+ system "./configure", "--prefix=#{prefix}",
+ "--build=#{arch}-apple-darwin"
+ system 'make'
+ if build.include? 'tests'
+ Ghctestsuite.new.brew do
+ (buildpath+'Ghcsource/config').install Dir['config/*']
+ (buildpath+'Ghcsource/driver').install Dir['driver/*']
+ (buildpath+'Ghcsource/mk').install Dir['mk/*']
+ (buildpath+'Ghcsource/tests').install Dir['tests/*']
+ (buildpath+'Ghcsource/timeout').install Dir['timeout/*']
+ cd (buildpath+'Ghcsource/tests') do
+ system 'make', 'CLEANUP=1', "THREADS=#{ENV.make_jobs}", 'fast'
+ end
+ end
+ end
+ ENV.j1 # Fixes an intermittent race condition
+ system 'make', 'install'
+ end
end
def caveats; <<-EOS.undent
Please sign in to comment.
Something went wrong with that request. Please try again.