From 6399d52ba10d510a94c9db6552a4ea8aae8e003b Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Tue, 16 Apr 2024 19:05:31 +0000
Subject: [PATCH] ghc-bignum: update gmp to 6.3.0

This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0.
The tarball format is now xz, and gmpsrc.patch has been patched into
the tarball so hadrian no longer needs to deal with patching logic
when building in-tree GMP.
---
 hadrian/src/Rules/Gmp.hs              | 11 ++-----
 libraries/ghc-bignum/gmp/gmp-tarballs |  2 +-
 libraries/ghc-bignum/gmp/gmpsrc.patch | 44 ---------------------------
 3 files changed, 4 insertions(+), 53 deletions(-)
 delete mode 100644 libraries/ghc-bignum/gmp/gmpsrc.patch

diff --git a/hadrian/src/Rules/Gmp.hs b/hadrian/src/Rules/Gmp.hs
index 65d20b04d7ae..ebca995bfe38 100644
--- a/hadrian/src/Rules/Gmp.hs
+++ b/hadrian/src/Rules/Gmp.hs
@@ -143,23 +143,18 @@ gmpRules = do
                 gmpP      = takeDirectory gmpBuildP
             ctx <- makeGmpPathContext gmpP
             removeDirectory gmpBuildP
-            -- Note: We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
-            -- gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
+            -- Note: We use a tarball like gmp-4.2.4-nodoc.tar.xz, which is
+            -- gmp-4.2.4.tar.xz repacked without the doc/ directory contents.
             -- That's because the doc/ directory contents are under the GFDL,
             -- which causes problems for Debian.
             tarball <- unifyPath . fromSingleton "Exactly one GMP tarball is expected"
-                   <$> getDirectoryFiles top [gmpBase -/- "gmp-tarballs/gmp*.tar.bz2"]
+                   <$> getDirectoryFiles top [gmpBase -/- "gmp-tarballs/gmp*.tar.xz"]
 
             withTempDir $ \dir -> do
                 let tmp = unifyPath dir
                 need [top -/- tarball]
                 build $ target ctx (Tar Extract) [top -/- tarball] [tmp]
 
-                let patch     = gmpBase -/- "gmpsrc.patch"
-                    patchName = takeFileName patch
-                copyFile patch $ tmp -/- patchName
-                applyPatch tmp patchName
-
                 let name    = dropExtension . dropExtension $ takeFileName tarball
                     unpack  = fromMaybe . error $ "gmpRules: expected suffix "
                         ++ "-nodoc (found: " ++ name ++ ")."
diff --git a/libraries/ghc-bignum/gmp/gmp-tarballs b/libraries/ghc-bignum/gmp/gmp-tarballs
index 4f26049af40a..01149ce34711 160000
--- a/libraries/ghc-bignum/gmp/gmp-tarballs
+++ b/libraries/ghc-bignum/gmp/gmp-tarballs
@@ -1 +1 @@
-Subproject commit 4f26049af40afb380eaf033ab91404cd2e214919
+Subproject commit 01149ce3471128e9fe0feca607579981f4b64395
diff --git a/libraries/ghc-bignum/gmp/gmpsrc.patch b/libraries/ghc-bignum/gmp/gmpsrc.patch
deleted file mode 100644
index d539b9545fd6..000000000000
--- a/libraries/ghc-bignum/gmp/gmpsrc.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-diff -Naur gmp-6.2.1/Makefile.am gmpbuild/Makefile.am
---- gmp-6.2.1/Makefile.am	2020-11-15 02:45:09.000000000 +0800
-+++ gmpbuild/Makefile.am	2021-01-09 22:56:14.571708858 +0800
-@@ -112,7 +112,7 @@
- LIBGMPXX_LT_AGE      = 6
- 
- 
--SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc
-+SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune
- 
- EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \
- 	     COPYING.LESSERv3 COPYINGv2 COPYINGv3
-diff -Naur gmp-6.2.1/Makefile.in gmpbuild/Makefile.in
---- gmp-6.2.1/Makefile.in	2020-11-15 02:45:16.000000000 +0800
-+++ gmpbuild/Makefile.in	2021-01-10 16:15:37.387670402 +0800
-@@ -572,7 +572,7 @@
- LIBGMPXX_LT_CURRENT = 10
- LIBGMPXX_LT_REVISION = 1
- LIBGMPXX_LT_AGE = 6
--SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc
-+SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune
- 
- # Put asl.h here for now.
- 
-diff -Naur gmp-6.2.1/configure gmpbuild/configure
---- gmp-6.2.1/configure	2020-11-15 02:45:15.000000000 +0800
-+++ gmpbuild/configure	2021-01-10 16:13:59.196004951 +0800
-@@ -27985,7 +27985,7 @@
- # FIXME: Upcoming version of autoconf/automake may not like broken lines.
- #        Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
- 
--ac_config_files="$ac_config_files Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile doc/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile gmp.h:gmp-h.in gmp.pc:gmp.pc.in gmpxx.pc:gmpxx.pc.in"
-+ac_config_files="$ac_config_files Makefile mpf/Makefile mpn/Makefile mpq/Makefile mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile tests/Makefile tests/devel/Makefile tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile tests/cxx/Makefile tune/Makefile demos/Makefile demos/calc/Makefile demos/expr/Makefile gmp.h:gmp-h.in gmp.pc:gmp.pc.in gmpxx.pc:gmpxx.pc.in"
- 
- cat >confcache <<\_ACEOF
- # This file is a shell script that caches the results of configure
-@@ -29129,7 +29129,6 @@
-     "tests/rand/Makefile") CONFIG_FILES="$CONFIG_FILES tests/rand/Makefile" ;;
-     "tests/misc/Makefile") CONFIG_FILES="$CONFIG_FILES tests/misc/Makefile" ;;
-     "tests/cxx/Makefile") CONFIG_FILES="$CONFIG_FILES tests/cxx/Makefile" ;;
--    "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
-     "tune/Makefile") CONFIG_FILES="$CONFIG_FILES tune/Makefile" ;;
-     "demos/Makefile") CONFIG_FILES="$CONFIG_FILES demos/Makefile" ;;
-     "demos/calc/Makefile") CONFIG_FILES="$CONFIG_FILES demos/calc/Makefile" ;;
-- 
GitLab