From 13b451c2b9515324157a541e93aefb0b6b4d9f8f Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Sat, 4 Jan 2025 19:57:29 -0500 Subject: [PATCH 1/2] ghc@9.10 9.10.1 (new formula) --- Aliases/ghc@9.10 | 1 - Formula/g/ghc@9.10.rb | 154 ++++++++++++++++++ ...nary_bootstrap_formula_urls_allowlist.json | 1 + 3 files changed, 155 insertions(+), 1 deletion(-) delete mode 120000 Aliases/ghc@9.10 create mode 100644 Formula/g/ghc@9.10.rb diff --git a/Aliases/ghc@9.10 b/Aliases/ghc@9.10 deleted file mode 120000 index cf505c10c4f221..00000000000000 --- a/Aliases/ghc@9.10 +++ /dev/null @@ -1 +0,0 @@ -../Formula/g/ghc.rb \ No newline at end of file diff --git a/Formula/g/ghc@9.10.rb b/Formula/g/ghc@9.10.rb new file mode 100644 index 00000000000000..e29ecf3f89ba6b --- /dev/null +++ b/Formula/g/ghc@9.10.rb @@ -0,0 +1,154 @@ +class GhcAT910 < Formula + desc "Glorious Glasgow Haskell Compilation System" + homepage "https://haskell.org/ghc/" + url "https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-src.tar.xz" + sha256 "bf386a302d4ee054791ffd51748900f15d71760fd199157922d120cc1f89e2f7" + # We build bundled copies of libffi and GMP so GHC inherits the licenses + license all_of: [ + "BSD-3-Clause", + "MIT", # libffi + any_of: ["LGPL-3.0-or-later", "GPL-2.0-or-later"], # GMP + ] + + livecheck do + url "https://www.haskell.org/ghc/download.html" + regex(/href=.*?download[._-]ghc[._-][^"' >]+?\.html[^>]*?>\s*?v?(9\.10(?:\.\d+)+)\s*? :build + depends_on "automake" => :build + depends_on "python@3.13" => :build + depends_on "sphinx-doc" => :build + depends_on "xz" => :build + + uses_from_macos "m4" => :build + uses_from_macos "ncurses" + + # Build uses sed -r option, which is not available in Catalina shipped sed. + on_catalina :or_older do + depends_on "gnu-sed" => :build + end + + on_linux do + depends_on "gmp" => :build + end + + # A binary of ghc is needed to bootstrap ghc + resource "binary" do + on_macos do + on_arm do + url "https://downloads.haskell.org/~ghc/9.8.2/ghc-9.8.2-aarch64-apple-darwin.tar.xz" + sha256 "67be089dedbe599d911efd8f82e4f9a19225761a3872be74dfd4b5a557fb8e1a" + end + on_intel do + url "https://downloads.haskell.org/~ghc/9.8.2/ghc-9.8.2-x86_64-apple-darwin.tar.xz" + sha256 "64e8cca6310443cd6de8255edcf391d937829792e701167f7e5fb234f7150078" + end + end + on_linux do + on_arm do + url "https://downloads.haskell.org/~ghc/9.8.2/ghc-9.8.2-aarch64-deb10-linux.tar.xz" + sha256 "9a3776fd8dc02f95b751f0e44823d6727dea2c212857e2c5c5f6a38a034d1575" + end + on_intel do + url "https://downloads.haskell.org/~ghc/9.8.2/ghc-9.8.2-x86_64-ubuntu20_04-linux.tar.xz" + sha256 "a65a4726203c606b58a7f6b714a576e7d81390158c8afa0dece3841a4c602de2" + end + end + end + + resource "cabal-install" do + on_macos do + on_arm do + url "https://downloads.haskell.org/~cabal/cabal-install-3.12.1.0/cabal-install-3.12.1.0-aarch64-darwin.tar.xz" + sha256 "9c165ca9a2e593b12dbb0eca92c0b04f8d1c259871742d7e9afc352364fe7a3f" + end + on_intel do + url "https://downloads.haskell.org/~cabal/cabal-install-3.12.1.0/cabal-install-3.12.1.0-x86_64-darwin.tar.xz" + sha256 "e89392429f59bbcfaf07e1164e55bc63bba8e5c788afe43c94e00b515c1578af" + end + end + on_linux do + on_arm do + url "https://downloads.haskell.org/~cabal/cabal-install-3.12.1.0/cabal-install-3.12.1.0-aarch64-linux-deb10.tar.xz" + sha256 "c01f2e0b3ba1fe4104cf2933ee18558a9b81d85831a145e8aba33fa172c7c618" + end + on_intel do + url "https://downloads.haskell.org/~cabal/cabal-install-3.12.1.0/cabal-install-3.12.1.0-x86_64-linux-ubuntu20_04.tar.xz" + sha256 "3724f2aa22f330c5e6605978f3dd9adee4e052866321a8dd222944cd178c3c24" + end + end + end + + # Backport fix to avoid unnecessary `alex` dependency + patch do + url "https://gitlab.haskell.org/ghc/ghc/-/commit/aba2c9d4728262cd9a2d711eded9050ac131c6c1.diff" + sha256 "152cd2711a7e103bbf0526dc62e51b437e6c60e26149f2cd50ccafaa057316ce" + end + + def install + # ENV.cc and ENV.cxx return specific compiler versions on Ubuntu, e.g. + # gcc-11 and g++-11 on Ubuntu 22.04. Using such values effectively causes + # the bottle (binary package) to only run on systems where gcc-11 and g++-11 + # binaries are available. This breaks on many systems including Arch Linux, + # Fedora and Ubuntu 24.04, as they provide g** but not g**-11 specifically. + # + # The workaround here is to hard-code both CC and CXX on Linux. + ENV["CC"] = ENV["ac_cv_path_CC"] = OS.linux? ? "cc" : ENV.cc + ENV["CXX"] = ENV["ac_cv_path_CXX"] = OS.linux? ? "c++" : ENV.cxx + ENV["LD"] = ENV["MergeObjsCmd"] = "ld" + ENV["PYTHON"] = which("python3.13") + + binary = buildpath/"binary" + resource("binary").stage do + binary_args = [] + if OS.linux? + binary_args << "--with-gmp-includes=#{Formula["gmp"].opt_include}" + binary_args << "--with-gmp-libraries=#{Formula["gmp"].opt_lib}" + end + + system "./configure", "--prefix=#{binary}", *binary_args + ENV.deparallelize { system "make", "install" } + end + + ENV.prepend_path "PATH", binary/"bin" + # Build uses sed -r option, which is not available in Catalina shipped sed. + ENV.prepend_path "PATH", Formula["gnu-sed"].libexec/"gnubin" if OS.mac? && MacOS.version <= :catalina + + resource("cabal-install").stage { (binary/"bin").install "cabal" } + system "cabal", "v2-update" + + args = [] + if OS.mac? + # https://gitlab.haskell.org/ghc/ghc/-/issues/22595#note_468423 + args << "--with-ffi-libraries=#{MacOS.sdk_path_if_needed}/usr/lib" + args << "--with-ffi-includes=#{MacOS.sdk_path_if_needed}/usr/include/ffi" + args << "--with-system-libffi" + end + + system "./configure", "--prefix=#{prefix}", "--disable-numa", "--with-intree-gmp", *args + hadrian_args = %W[ + -j#{ENV.make_jobs} + --prefix=#{prefix} + --flavour=release + --docs=no-sphinx-pdfs + ] + # Let hadrian handle its own parallelization + ENV.deparallelize { system "hadrian/build", "install", *hadrian_args } + + bash_completion.install "utils/completion/ghc.bash" => "ghc" + (lib/"ghc-#{version}/lib/package.conf.d/package.cache").unlink + (lib/"ghc-#{version}/lib/package.conf.d/package.cache.lock").unlink + end + + def post_install + system bin/"ghc-pkg", "recache" + end + + test do + (testpath/"hello.hs").write('main = putStrLn "Hello Homebrew"') + assert_match "Hello Homebrew", shell_output("#{bin}/runghc hello.hs") + end +end diff --git a/style_exceptions/binary_bootstrap_formula_urls_allowlist.json b/style_exceptions/binary_bootstrap_formula_urls_allowlist.json index b1f5b5db21d730..e48e04936a3f59 100644 --- a/style_exceptions/binary_bootstrap_formula_urls_allowlist.json +++ b/style_exceptions/binary_bootstrap_formula_urls_allowlist.json @@ -5,6 +5,7 @@ "fpc", "ghc", "ghc@8.10", + "ghc@9.10", "ghc@9.2", "ghc@9.4", "ghc@9.6", From f3f262c18832e405cf9de481831c4b0f60a33336 Mon Sep 17 00:00:00 2001 From: Michael Cho <20700669+cho-m@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:30:57 +0000 Subject: [PATCH 2/2] ghc@9.10: add 9.10.1 bottle. --- Formula/g/ghc@9.10.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Formula/g/ghc@9.10.rb b/Formula/g/ghc@9.10.rb index e29ecf3f89ba6b..e168fef87b711b 100644 --- a/Formula/g/ghc@9.10.rb +++ b/Formula/g/ghc@9.10.rb @@ -15,6 +15,15 @@ class GhcAT910 < Formula regex(/href=.*?download[._-]ghc[._-][^"' >]+?\.html[^>]*?>\s*?v?(9\.10(?:\.\d+)+)\s*? :build