Convert to use cross-compilation
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 23 May 2023 17:00:35 +0000 (18:00 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 23 May 2023 17:05:46 +0000 (18:05 +0100)
opensbi/opensbi.spec

index 651a835..8d779b3 100644 (file)
@@ -1,6 +1,14 @@
 # Disable debug packages, we don't need them.
 %global debug_package %{nil}
 
+# Make sure we use the cross-binary to strip.
+%global __strip riscv64-linux-gnu-strip
+
+# Avoid this error caused by cross-compilation and packaging the
+# result in a noarch package:
+#   error: Arch dependent binaries in noarch package
+%global _binaries_in_noarch_packages_terminate_build 0
+
 %global forgeurl https://github.com/riscv/opensbi
 %global commit   791953030836d39687688a8e7f1a3e708892cfa1
 %forgemeta
@@ -14,8 +22,12 @@ License:         BSD
 URL:             %{forgeurl}
 Source:          %{forgesource}
 
-BuildRequires:   gcc
-BuildRequires:   binutils
+# The resulting binary contains RISC-V firmware intended to be used
+# under virtualization, so it can be used on any architecture.
+Buildarch:      noarch
+
+BuildRequires:   gcc-riscv64-linux-gnu
+BuildRequires:   binutils-riscv64-linux-gnu
 BuildRequires:   findutils
 BuildRequires:   grep
 BuildRequires:   coreutils
@@ -37,11 +49,12 @@ RISC-V virt machines.
 
 %build
 make \
+  CROSS_COMPILE=riscv64-linux-gnu- \
   PLATFORM=generic
 
-
 %install
 make \
+  CROSS_COMPILE=riscv64-linux-gnu- \
   PLATFORM=generic \
   I=%{buildroot} \
   INSTALL_LIB_PATH=lib64 \
@@ -63,6 +76,7 @@ rm -rfv %{buildroot}%{_datadir}/%{name}/*/firmware/payloads
 %changelog
 * Tue May 23 2023 Richard W.M. Jones <rjones@redhat.com> 1.2
 - Use forge macros
+- Convert to use cross-compilation
 - Fix dates in changelog
 
 * Tue May 02 2023 David Abdurachmanov <davidlt@rivosinc.com> v1.2.116.2023.05.02.7919530-1