From b397e49f0f30ea1a1377538130c49300068ba417 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 11 Aug 2016 11:42:43 +0100 Subject: [PATCH] Further fixes to RPM. This should fix the %{_arch} issue. --- 0001-RISCV-64-bit-riscv64-support.patch | 19 +++++---- ...rt-uname.machine-riscv-to-riscv32-riscv64.patch | 46 ++++++++++++++++++++++ ... => 0003-build-fgetc-returns-int-not-char.patch | 4 +- ...=> 0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch | 4 +- Makefile | 5 ++- 5 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch rename 0002-build-fgetc-returns-int-not-char.patch => 0003-build-fgetc-returns-int-not-char.patch (87%) rename 0003-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch => 0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch (93%) diff --git a/0001-RISCV-64-bit-riscv64-support.patch b/0001-RISCV-64-bit-riscv64-support.patch index e421c79..b00eaa8 100644 --- a/0001-RISCV-64-bit-riscv64-support.patch +++ b/0001-RISCV-64-bit-riscv64-support.patch @@ -1,15 +1,15 @@ -From ee9f3cca374ee9935cc0337cfbbd02f0d0e4e105 Mon Sep 17 00:00:00 2001 +From abe2459b56723a1ee1366056be5e8546a1a8facb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" 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 --- 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 @@ -29,7 +29,7 @@ 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 @@ -50,17 +50,16 @@ index e888b0f..abc08fc 100644 ############################################################# # 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 @@ -70,7 +69,7 @@ index e888b0f..abc08fc 100644 ############################################################# # Architecture compatibility -@@ -473,6 +483,9 @@ arch_compat: sh4a: sh4 +@@ -473,6 +482,9 @@ arch_compat: sh4a: sh4 arch_compat: aarch64: noarch @@ -80,7 +79,7 @@ index e888b0f..abc08fc 100644 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 diff --git a/0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch b/0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch new file mode 100644 index 0000000..0c89ede --- /dev/null +++ b/0002-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch @@ -0,0 +1,46 @@ +From 331b0ac34a9767d1f0147daf3fd22b64e2e4e3af Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +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 +--- + 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 + diff --git a/0002-build-fgetc-returns-int-not-char.patch b/0003-build-fgetc-returns-int-not-char.patch similarity index 87% rename from 0002-build-fgetc-returns-int-not-char.patch rename to 0003-build-fgetc-returns-int-not-char.patch index 2dd6e23..ebcc4cf 100644 --- a/0002-build-fgetc-returns-int-not-char.patch +++ b/0003-build-fgetc-returns-int-not-char.patch @@ -1,7 +1,7 @@ -From 8217b4c4c44f666adf413ab3a0a21503a6f35a3e Mon Sep 17 00:00:00 2001 +From 0c44e5cdbdc525cc1bf1063b6c561efa23d06b0d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" 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 diff --git a/0003-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch b/0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch similarity index 93% rename from 0003-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch rename to 0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch index 57a3f13..e7e7553 100644 --- a/0003-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch +++ b/0004-HACKS-TO-GET-RPM-TO-CROSS-COMPILE.patch @@ -1,7 +1,7 @@ -From daaa2fb07d725aa0e42c660776f88adebfa70945 Mon Sep 17 00:00:00 2001 +From 7a164577210693c1714c38398fe87270f62bb8c1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" 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 ++++++++++++++++------------ diff --git a/Makefile b/Makefile index 39abd5e..cd42938 100644 --- a/Makefile +++ b/Makefile @@ -920,8 +920,9 @@ stage3-chroot/usr/bin/rpm: rpm-$(RPM_SHORT_COMMIT).tar.gz db-$(BDB_VERSION).tar. 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 \ -- 1.8.3.1