Skip to content

Instantly share code, notes, and snippets.

@MerelyAPseudonym MerelyAPseudonym/ghc.rb
Last active Aug 29, 2015

Embed
What would you like to do?
Proof of concept for GHC 7.8.2
require 'formula'
class Ghc < Formula
homepage "http://haskell.org/ghc/"
url "http://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-src.tar.bz2"
sha1 "8938e1ef08b37a4caa071fa169e79a3001d065ff"
depends_on "gmp"
bottle do
sha1 "33415814d8461ecd00f7f2d247c0147eb9f2bfde" => :mavericks
sha1 "58f51f5cf6184c40597719890bca19db4fe095f1" => :mountain_lion
sha1 "a29e3ba4b81b80abdf41e8581777da7b89ae5aae" => :lion
end
option "32-bit"
option "tests", "Verify the build using the testsuite."
resource "7.6.3-i386-binary" do
url "https://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-i386-apple-darwin.tar.bz2"
sha1 "6a312263fef41e06003f0676b879f2d2d5a1f30c"
end
resource "7.6.3-x86_64-binary" do
url "https://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-x86_64-apple-darwin.tar.bz2"
sha1 "fb9f18197852181a9472221e1944081985b75992"
end
devel do
url "https://www.haskell.org/ghc/dist/7.8.2/ghc-7.8.2-src.tar.xz"
sha1 "fe86ae790b7e8e5b4c78db7a914ee375bc6d9fc3"
version "7.8.2_1"
# GHC 7.6 —which we might use for bootstrapping— still needs GCC
depends_on "gcc" => :build if (build.build_32_bit? ||
!MacOS.prefer_64_bit? ||
MacOS::Xcode.version < "5.1")
resource "7.8.2-x86_64-binary" do
url "https://www.haskell.org/ghc/dist/7.8.2/ghc-7.8.2-x86_64-apple-darwin-mavericks.tar.bz2"
sha1 "efe602841300bcd887c46555fbc66fb67de34ebd"
end
resource "testsuite" do
url "https://www.haskell.org/ghc/dist/7.8.2/ghc-7.8.2-testsuite.tar.xz"
sha1 "3abe4e0ebbed17e825573f0f34be0eca9179f9e4"
end
end
# These don't work inside of a `stable do` block
if build.stable?
env :std
fails_with :clang do
cause <<-EOS.undent
Building with Clang configures GHC to use Clang as its preprocessor,
which causes subsequent GHC-based builds to fail.
EOS
end
end
stable do
# http://hackage.haskell.org/trac/ghc/ticket/6009
depends_on :macos => :snow_leopard
#depends_on "gcc" if MacOS.version >= :mountain_lion
resource "testsuite" do
url "https://github.com/ghc/testsuite/archive/ghc-7.6.3-release.tar.gz"
sha1 "6a1973ae3cccdb2f720606032ae84ffee8680ca1"
end
# Fixes 7.6.3 compilation on 10.9
patch :DATA if MacOS.version >= :mavericks
end
def install
if (build.build_32_bit? || !MacOS.prefer_64_bit?)
binary_resource = "7.6.3-i386-binary"
arch = "i386"
elsif (build.devel? && MacOS::Xcode.version >= "5.1")
binary_resource = "7.8.2-x86_64-binary"
arch = "x86_64"
else
binary_resource = "7.6.3-x86_64-binary"
arch = "x86_64"
end
# Move the main tarball contents into a subdirectory
(buildpath+"Ghcsource").install Dir["*"]
resource(binary_resource).stage do
# Define where the subformula will temporarily install itself
subprefix = buildpath+"subfo"
args = ["--prefix=#{subprefix}"]
args << "--with-gcc=#{ENV.cc}" # ensure configure does not use Xcode 5 "gcc" which is actually clang
system "./configure", *args
# if (build.devel? && MacOS.version <= :lion)
# # __thread is not supported on Lion but configure enables it anyway.
# File.open("mk/config.h", "a") do |file|
# file.write("#undef CC_SUPPORTS_TLS")
# end
# end
system "make", "--jobs=1", "install"
ENV.prepend_path "PATH", subprefix/"bin"
end
cd "Ghcsource" do
# Fix an assertion when linking ghc with llvm-gcc
# https://github.com/Homebrew/homebrew/issues/13650
#ENV["LD"] = "ld" if build.stable?
#ENV.m32 if arch == "i386" # Need to force this to fix build error on internal libgmp_ar.
args = ["--prefix=#{prefix}", "--build=#{arch}-apple-darwin"]
args << "--with-gcc=#{ENV.cc}" # ensure configure does not use Xcode 5 "gcc" which is actually clang
system "./configure", *args
system "make"
if build.include? "tests"
resource("testsuite").stage do
cd "testsuite" 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/*"]
end
cd (buildpath+"Ghcsource/tests") do
system "make", "CLEANUP=1", "THREADS=#{ENV.make_jobs}", "fast"
end
end
system "make"
end
system "make", "--jobs=1", "install"
end
end
def caveats; <<-EOS.undent
This brew is for GHC only; you might also be interested in haskell-platform.
EOS
end
test do
hello = (testpath/"hello.hs")
hello.write('main = putStrLn "Hello Homebrew"')
output = `echo "main" | '#{bin}/ghci' #{hello}`
assert $?.success?
assert_match /Hello Homebrew/i, output
end
end
__END__
diff --git a/includes/HsFFI.h b/includes/HsFFI.h
index 652fbea..a21811e 100644
--- a/includes/HsFFI.h
+++ b/includes/HsFFI.h
@@ -21,7 +21,7 @@ extern "C" {
#include "stg/Types.h"
/* get limits for integral types */
-#ifdef HAVE_STDINT_H
+#if defined HAVE_STDINT_H && !defined USE_INTTYPES_H_FOR_RTS_PROBES_D
/* ISO C 99 says:
* "C++ implementations should define these macros only when
* __STDC_LIMIT_MACROS is defined before <stdint.h> is included."
diff --git a/rts/RtsProbes.d b/rts/RtsProbes.d
index 13f40f8..226f881 100644
--- a/rts/RtsProbes.d
+++ b/rts/RtsProbes.d
@@ -6,6 +6,12 @@
*
* ---------------------------------------------------------------------------*/
+#ifdef __APPLE__ && __MACH__
+# if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
+# define USE_INTTYPES_H_FOR_RTS_PROBES_D
+# endif
+#endif
+
#include "HsFFI.h"
#include "rts/EventLogFormat.h"
diff --git a/utils/mkdirhier/mkdirhier.sh b/utils/mkdirhier/mkdirhier.sh
index 4c5d5f7..80762f4 100644
--- a/utils/mkdirhier/mkdirhier.sh
+++ b/utils/mkdirhier/mkdirhier.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-mkdir -p ${1+"$@"}
+mkdir -p ${1+"./$@"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.