This should fix the %{_arch} issue.
-From ee9f3cca374ee9935cc0337cfbbd02f0d0e4e105 Mon Sep 17 00:00:00 2001
+From abe2459b56723a1ee1366056be5e8546a1a8facb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 9 Aug 2016 18:25:24 +0100
-Subject: [PATCH 1/3] RISCV 64-bit (riscv64) support.
+Subject: [PATCH 1/4] RISCV 64-bit (riscv64) support.
Based on Mark Salter's aarch64 support patch (commit 8e1ca16c58).
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
installplatform | 6 ++++++
- rpmrc.in | 16 ++++++++++++++++
- 2 files changed, 22 insertions(+)
+ rpmrc.in | 15 +++++++++++++++
+ 2 files changed, 21 insertions(+)
diff --git a/installplatform b/installplatform
index ebade42..12339fc 100755
CANONARCH=noarch
CANONCOLOR=0
diff --git a/rpmrc.in b/rpmrc.in
-index e888b0f..abc08fc 100644
+index e888b0f..830b9ed 100644
--- a/rpmrc.in
+++ b/rpmrc.in
@@ -99,6 +99,8 @@ optflags: sh4a -O2 -g -mieee
#############################################################
# Canonical arch names and numbers
-@@ -243,6 +247,9 @@ arch_canon: mipsr6el: mipsr6el 20
+@@ -243,6 +247,8 @@ arch_canon: mipsr6el: mipsr6el 20
arch_canon: mips64r6: mips64r6 21
arch_canon: mips64r6el: mips64r6el 21
+arch_canon: riscv: riscv64 22
-+arch_canon: riscv64: riscv64 22
+
#############################################################
# Canonical OS names and numbers
-@@ -368,6 +375,9 @@ buildarchtranslate: sh4a: sh4
+@@ -368,6 +374,9 @@ buildarchtranslate: sh4a: sh4
buildarchtranslate: aarch64: aarch64
#############################################################
# Architecture compatibility
-@@ -473,6 +483,9 @@ arch_compat: sh4a: sh4
+@@ -473,6 +482,9 @@ arch_compat: sh4a: sh4
arch_compat: aarch64: noarch
os_compat: IRIX64: IRIX
os_compat: solaris2.7: solaris2.3 solaris2.4 solaris2.5 solaris2.6
os_compat: solaris2.6: solaris2.3 solaris2.4 solaris2.5
-@@ -506,6 +519,9 @@ buildarch_compat: ia64: noarch
+@@ -506,6 +518,9 @@ buildarch_compat: ia64: noarch
buildarch_compat: aarch64: noarch
--- /dev/null
+From 331b0ac34a9767d1f0147daf3fd22b64e2e4e3af Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones@redhat.com>
+Date: Thu, 11 Aug 2016 11:38:18 +0100
+Subject: [PATCH 2/4] rpmrc: Convert uname.machine == "riscv" to
+ "riscv32"/"riscv64"/"riscv128".
+
+On RISC-V, the kernel returns uname.machine == "riscv" (for all bit
+sizes). GNU is using "riscv64". Convert the kernel uname machine
+type to a more suitable value.
+
+This conversion is supposed to be done by the arch_canon table.
+However the arch_canon table is not populated until after the
+defaultMachine function is called for the first time, making it a bit
+useless. In any case, arch_canon cannot take into account the bit
+size of the architecture, but the C code here can.
+
+Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
+---
+ lib/rpmrc.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/lib/rpmrc.c b/lib/rpmrc.c
+index f2e0f48..eb136d8 100644
+--- a/lib/rpmrc.c
++++ b/lib/rpmrc.c
+@@ -1216,6 +1216,17 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
+ }
+ # endif /* arm*-linux */
+
++# if defined(__linux__) && defined(__riscv__)
++ if (rstreq(un.machine, "riscv")) {
++ if (sizeof(long) == 4)
++ strcpy(un.machine, "riscv32");
++ else if (sizeof(long) == 8)
++ strcpy(un.machine, "riscv64");
++ else if (sizeof(long) == 16)
++ strcpy(un.machine, "riscv128");
++ }
++# endif /* riscv */
++
+ # if defined(__GNUC__) && defined(__alpha__)
+ {
+ unsigned long amask, implver;
+--
+2.7.4
+
-From 8217b4c4c44f666adf413ab3a0a21503a6f35a3e Mon Sep 17 00:00:00 2001
+From 0c44e5cdbdc525cc1bf1063b6c561efa23d06b0d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 10 Aug 2016 15:01:31 +0100
-Subject: [PATCH 2/3] build: fgetc returns int, not char.
+Subject: [PATCH 3/4] build: fgetc returns int, not char.
Returning the value into a char is a mistake on all platforms, but is
particularly bad on RISC-V. On that platform (like ARM) char is
-From daaa2fb07d725aa0e42c660776f88adebfa70945 Mon Sep 17 00:00:00 2001
+From 7a164577210693c1714c38398fe87270f62bb8c1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 9 Aug 2016 18:21:57 +0100
-Subject: [PATCH 3/3] HACKS TO GET RPM TO CROSS-COMPILE
+Subject: [PATCH 4/4] HACKS TO GET RPM TO CROSS-COMPILE
---
configure.ac | 28 ++++++++++++++++------------
cd rpm-$(RPM_SHORT_COMMIT) && ln -s db-$(BDB_VERSION) db
cd rpm-$(RPM_SHORT_COMMIT) && \
patch -p1 < ../0001-RISCV-64-bit-riscv64-support.patch && \
- patch -p1 < ../0002-build-fgetc-returns-int-not-char.patch && \
- patch -p1 < ../0003-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch
+ patch -p1 < ../0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch && \
+ patch -p1 < ../0003-build-fgetc-returns-int-not-char.patch && \
+ patch -p1 < ../0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch
cd rpm-$(RPM_SHORT_COMMIT) && autoreconf -i
cd rpm-$(RPM_SHORT_COMMIT) && \
PATH=$(ROOT)/fixed-gcc:$$PATH \