Skip to content
This repository
Browse code

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.
        47ac5d8
        a8d4731

Fixes #13519

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information...
commit 3cf0db7ed209e9134f21ea326c6260727ed89168 1 parent fb0407f
2bits authored August 25, 2012 mikemcquaid committed October 06, 2012

Showing 1 changed file with 63 additions and 5 deletions. Show diff stats Hide diff stats

  1. 68  Library/Formula/ghc.rb
68  Library/Formula/ghc.rb
@@ -13,9 +13,7 @@ def message; <<-EOS.undent
13 13
   end
14 14
 end
15 15
 
16  
-class Ghc < Formula
17  
-  homepage 'http://haskell.org/ghc/'
18  
-  version '7.4.2'
  16
+class Ghcbinary < Formula
19 17
   if Hardware.is_64_bit? and not build.build_32_bit?
20 18
     url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-apple-darwin.tar.bz2'
21 19
     sha1 '7c655701672f4b223980c3a1068a59b9fbd08825'
@@ -23,12 +21,25 @@ class Ghc < Formula
23 21
     url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-i386-apple-darwin.tar.bz2'
24 22
     sha1 '60f749893332d7c22bb4905004a67510992d8ef6'
25 23
   end
  24
+  version '7.4.2'
  25
+end
  26
+
  27
+class Ghctestsuite < Formula
  28
+  url 'https://github.com/ghc/testsuite/tarball/ghc-7.4.2-release'
  29
+  sha1 '6b1f161a78a70638aacc931abfdef7dd50c7f923'
  30
+end
  31
+
  32
+class Ghc < Formula
  33
+  homepage 'http://haskell.org/ghc/'
  34
+  url 'http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-src.tar.bz2'
  35
+  sha1 '73b3b39dc164069bc80b69f7f2963ca1814ddf3d'
26 36
 
27 37
   env :std
28 38
 
29 39
   depends_on NeedsSnowLeopard.new
30 40
 
31 41
   option '32-bit'
  42
+  option 'tests', 'Verify the build using the testsuite in Fast Mode, 5 min'
32 43
 
33 44
   fails_with :clang do
34 45
     build 421
@@ -38,9 +49,56 @@ class Ghc < Formula
38 49
       EOS
39 50
   end
40 51
 
  52
+  def patches
  53
+    # Explained: http://hackage.haskell.org/trac/ghc/ticket/7040
  54
+    # Discussed: https://github.com/mxcl/homebrew/issues/13519
  55
+    # Remove: version > 7.4.2
  56
+    'http://hackage.haskell.org/trac/ghc/raw-attachment/ticket/7040/ghc7040.patch'
  57
+  end
  58
+
41 59
   def install
42  
-    system "./configure", "--prefix=#{prefix}"
43  
-    system "make install"
  60
+    # Move the main tarball contents into a subdirectory
  61
+    (buildpath+'Ghcsource').install Dir['*']
  62
+
  63
+    # Define where the subformula will temporarily install itself
  64
+    subprefix = buildpath+'subfo'
  65
+
  66
+    Ghcbinary.new.brew do
  67
+      system "./configure", "--prefix=#{subprefix}"
  68
+      # Temporary j1 to stop an intermittent race condition
  69
+      system 'make', '-j1', 'install'
  70
+      ENV.prepend 'PATH', subprefix/'bin', ':'
  71
+    end
  72
+
  73
+    cd 'Ghcsource' do
  74
+      # Fix an assertion when linking ghc with llvm-gcc
  75
+      # https://github.com/mxcl/homebrew/issues/13650
  76
+      ENV['LD'] = 'ld'
  77
+
  78
+      if Hardware.is_64_bit? and not build.build_32_bit?
  79
+        arch = 'x86_64'
  80
+      else
  81
+        arch = 'i386'
  82
+      end
  83
+
  84
+      system "./configure", "--prefix=#{prefix}",
  85
+                            "--build=#{arch}-apple-darwin"
  86
+      system 'make'
  87
+      if build.include? 'tests'
  88
+        Ghctestsuite.new.brew do
  89
+          (buildpath+'Ghcsource/config').install Dir['config/*']
  90
+          (buildpath+'Ghcsource/driver').install Dir['driver/*']
  91
+          (buildpath+'Ghcsource/mk').install Dir['mk/*']
  92
+          (buildpath+'Ghcsource/tests').install Dir['tests/*']
  93
+          (buildpath+'Ghcsource/timeout').install Dir['timeout/*']
  94
+          cd (buildpath+'Ghcsource/tests') do
  95
+            system 'make', 'CLEANUP=1', "THREADS=#{ENV.make_jobs}", 'fast'
  96
+          end
  97
+        end
  98
+      end
  99
+      ENV.j1 # Fixes an intermittent race condition
  100
+      system 'make', 'install'
  101
+    end
44 102
   end
45 103
 
46 104
   def caveats; <<-EOS.undent

0 notes on commit 3cf0db7

Please sign in to comment.
Something went wrong with that request. Please try again.