From d89526f9818bf8969f4a774738ea187a0ae301cd Mon Sep 17 00:00:00 2001
From: Felix Yan <felixonmars@archlinux.org>
Date: Sun, 2 Jul 2023 23:54:55 +0300
Subject: [PATCH] Add support for the 64-bit RISC-V architecture (#9062)

* Add support for the 64-bit RISC-V architecture

* Update hashes in tests as instructed

* Fix changelog syntax

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
---
 Cabal-syntax/src/Distribution/System.hs                      | 4 +++-
 Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs | 4 ++--
 Cabal/src/Distribution/Simple/PreProcess.hs                  | 1 +
 changelog.d/pr-9062                                          | 3 +++
 4 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 changelog.d/pr-9062

diff --git a/Cabal-syntax/src/Distribution/System.hs b/Cabal-syntax/src/Distribution/System.hs
index 730bb6d685..ad1cdedf57 100644
--- a/Cabal-syntax/src/Distribution/System.hs
+++ b/Cabal-syntax/src/Distribution/System.hs
@@ -183,7 +183,7 @@ buildOS = classifyOS Permissive System.Info.os
 
 -- | These are the known Arches: I386, X86_64, PPC, PPC64, Sparc,
 -- Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa, Rs6000,
--- M68k, Vax, JavaScript and Wasm32.
+-- M68k, Vax, RISCV64, JavaScript and Wasm32.
 --
 -- The following aliases can also be used:
 --    * PPC alias: powerpc
@@ -210,6 +210,7 @@ data Arch
   | Rs6000
   | M68k
   | Vax
+  | RISCV64
   | JavaScript
   | Wasm32
   | OtherArch String
@@ -238,6 +239,7 @@ knownArches =
   , Rs6000
   , M68k
   , Vax
+  , RISCV64
   , JavaScript
   , Wasm32
   ]
diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs
index a396dea860..f2d22f7755 100644
--- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs
+++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs
@@ -27,9 +27,9 @@ tests = testGroup "Distribution.Utils.Structured"
     -- The difference is in encoding of newtypes
 #if MIN_VERSION_base(4,7,0)
     , testCase "GenericPackageDescription" $
-      md5Check (Proxy :: Proxy GenericPackageDescription) 0xc7d1064aaf2c9bcf92c3d7f23e6d7e94
+      md5Check (Proxy :: Proxy GenericPackageDescription) 0xedd391339de1201511636bbb563fa5db
     , testCase "LocalBuildInfo" $
-      md5Check (Proxy :: Proxy LocalBuildInfo) 0x0324f420f9fb98417098127a414cc7c0
+      md5Check (Proxy :: Proxy LocalBuildInfo) 0x40253e3699453643336bdc7911717af0
 #endif
     ]
 
diff --git a/Cabal/src/Distribution/Simple/PreProcess.hs b/Cabal/src/Distribution/Simple/PreProcess.hs
index 6321a63b03..03b13ae5a7 100644
--- a/Cabal/src/Distribution/Simple/PreProcess.hs
+++ b/Cabal/src/Distribution/Simple/PreProcess.hs
@@ -868,6 +868,7 @@ platformDefines lbi =
       Rs6000 -> ["rs6000"]
       M68k -> ["m68k"]
       Vax -> ["vax"]
+      RISCV64 -> ["riscv64"]
       JavaScript -> ["javascript"]
       Wasm32 -> ["wasm32"]
       OtherArch _ -> []
diff --git a/changelog.d/pr-9062 b/changelog.d/pr-9062
new file mode 100644
index 0000000000..1cd4ad3e6e
--- /dev/null
+++ b/changelog.d/pr-9062
@@ -0,0 +1,3 @@
+synopsis: Add support for the 64-bit RISC-V architecture
+prs: #9062
+packages: Cabal Cabal-syntax
-- 
GitLab