[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#996645: kodi: please add support for riscv64



Package: kodi
Version: 2:19.2+dfsg1-2
Severity: wishlist
Tags: ftbfs upstream patch
User: debian-riscv@lists.debian.org
Usertags: riscv64

Dear maintainer,

kodi currently fails to build from source on riscv64 due to missing
support for this architecture [1]. You will find attached a patch to fix
that. It touches many things, so please find some more details below:

- I modified debian/rules to pass -DWITH_ARCH=riscv64. It's not clear if
  that part should go upstream, it seems given we do not have CPU
  specific optimizations to add in cmake/scripts/linux/ArchSetup.cmake
  so it's not fully necessary. Please tell me if I am wrong, I'll submit
  that upstream.

- Patch 0024-add-riscv-compile-defines.patch is coming from upstream and
  will be in Kodi 20. It conflicts with 0006-fix-s390x-build and
  0009-fix-alpha-build patches whichh touch the same files. As 0024 is
  already upstream and will appear at some point in the Debian package,
  I have moved the 0006 and 0009 patches after it and "rebased" them as
  0025 and 0026.

- Patch 0027-link-with-pthread.patch changes the way cmake handles
  Thread support to correctly link with -pthread instead of -lpthread.
  That way GCC automatically pulls in -latomic if needed. I have noticed
  that debian/rules already forces LDFLAGS to contain -latomic, however
  it appears too early in the linker command to be early (it needs to be
  after the objects needing this library).

- Patch 0028-add-risc-v-support-to-system-info.patch adds support for
  RISC-V to SystemInfo.cpp and is needed to successfully pass the
  testsuite. I have submitted it upstream [2].

If you are fine with this patch, could you please consider applying it
in the future uploads? If you aren't, do not hesitate to comment, ask
for more details or ask for changes to the patch.

Regards,
Aurelien

[1] https://buildd.debian.org/status/fetch.php?pkg=kodi&arch=riscv64&ver=2%3A19.2%2Bdfsg1-2&stamp=1634297754&raw=0
[2] https://github.com/xbmc/xbmc/pull/20323
--- kodi-19.2+dfsg1/debian/patches/kodi/0006-fix-s390x-build.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0006-fix-s390x-build.patch
@@ -1,49 +0,0 @@
-From: Balint Reczey <balint@balintreczey.hu>
-Date: Tue, 3 Mar 2020 23:56:06 +0100
-Subject: Fix build on s390x
-Forwarded: not-needed
-
-Upstream is most probably not interested in this port thus I have not
-forwarded the patch.
----
- xbmc/cores/DllLoader/DllLoader.h  | 1 +
- xbmc/cores/DllLoader/ldt_keeper.c | 1 +
- xbmc/utils/MathUtils.h            | 1 +
- 3 files changed, 3 insertions(+)
-
-diff --git a/xbmc/cores/DllLoader/DllLoader.h b/xbmc/cores/DllLoader/DllLoader.h
-index 55ee623..81681f2 100644
---- a/xbmc/cores/DllLoader/DllLoader.h
-+++ b/xbmc/cores/DllLoader/DllLoader.h
-@@ -16,6 +16,7 @@
-     !defined(__arm__) && \
-     !defined(__aarch64__) && \
-     !defined(__mips__) && \
-+    !defined(__s390x__) && \
-     !defined(__SH4__) && \
-     !defined(__sparc__) && \
-     !defined(__arc__) && \
-diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
-index 0e6bc81..1e99e57 100644
---- a/xbmc/cores/DllLoader/ldt_keeper.c
-+++ b/xbmc/cores/DllLoader/ldt_keeper.c
-@@ -24,6 +24,7 @@
-     !defined(__arm__) && \
-     !defined(__aarch64__) && \
-     !defined(__mips__) && \
-+    !defined(__s390x__) && \
-     !defined(__SH4__) && \
-     !defined(__sparc__) && \
-     !defined(__arc__) && \
-diff --git a/xbmc/utils/MathUtils.h b/xbmc/utils/MathUtils.h
-index 7a69db7..4a09672 100644
---- a/xbmc/utils/MathUtils.h
-+++ b/xbmc/utils/MathUtils.h
-@@ -24,6 +24,7 @@
- #if defined(__ppc__) || \
-     defined(__powerpc__) || \
-     defined(__mips__) || \
-+    defined(__s390x__) || \
-     defined(__arm__) || \
-     defined(__aarch64__) || \
-     defined(__SH4__) || \
--- kodi-19.2+dfsg1/debian/patches/kodi/0009-fix-alpha-build.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0009-fix-alpha-build.patch
@@ -1,48 +0,0 @@
-From: Michael Cree <mcree@orcon.net.nz>
-Date: Tue, 3 Mar 2020 23:56:07 +0100
-Subject: Fix alpha build
-Forwarded: not-needed
-Bug: https://bugs.debian.org/856815
-
----
- xbmc/cores/DllLoader/DllLoader.h  | 1 +
- xbmc/cores/DllLoader/ldt_keeper.c | 1 +
- xbmc/utils/MathUtils.h            | 1 +
- 3 files changed, 3 insertions(+)
-
-diff --git a/xbmc/cores/DllLoader/DllLoader.h b/xbmc/cores/DllLoader/DllLoader.h
-index 81681f2..efcc2bc 100644
---- a/xbmc/cores/DllLoader/DllLoader.h
-+++ b/xbmc/cores/DllLoader/DllLoader.h
-@@ -17,6 +17,7 @@
-     !defined(__aarch64__) && \
-     !defined(__mips__) && \
-     !defined(__s390x__) && \
-+    !defined(__alpha__) && \
-     !defined(__SH4__) && \
-     !defined(__sparc__) && \
-     !defined(__arc__) && \
-diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
-index 1e99e57..4be6ebc 100644
---- a/xbmc/cores/DllLoader/ldt_keeper.c
-+++ b/xbmc/cores/DllLoader/ldt_keeper.c
-@@ -25,6 +25,7 @@
-     !defined(__aarch64__) && \
-     !defined(__mips__) && \
-     !defined(__s390x__) && \
-+    !defined(__alpha__) && \
-     !defined(__SH4__) && \
-     !defined(__sparc__) && \
-     !defined(__arc__) && \
-diff --git a/xbmc/utils/MathUtils.h b/xbmc/utils/MathUtils.h
-index 4a09672..579151a 100644
---- a/xbmc/utils/MathUtils.h
-+++ b/xbmc/utils/MathUtils.h
-@@ -25,6 +25,7 @@
-     defined(__powerpc__) || \
-     defined(__mips__) || \
-     defined(__s390x__) || \
-+    defined(__alpha__) || \
-     defined(__arm__) || \
-     defined(__aarch64__) || \
-     defined(__SH4__) || \
--- kodi-19.2+dfsg1/debian/patches/kodi/0024-add-riscv-compile-defines.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0024-add-riscv-compile-defines.patch
@@ -0,0 +1,113 @@
+From af576306b92f00dad4c96949b3ca49f7a5407f03 Mon Sep 17 00:00:00 2001
+From: heitbaum <rudi@heitbaum.com>
+Date: Sun, 29 Aug 2021 14:43:11 +1000
+Subject: [PATCH] add riscv compile defines
+
+Add defined(__riscv) so as to:
+- Disable USE_LDT_KEEPER
+- Enable DISABLE_MATHUTILS_ASM_ROUND_INT
+---
+ xbmc/cores/DllLoader/DllLoader.h  | 11 +++++++----
+ xbmc/cores/DllLoader/ldt_keeper.c | 14 ++++++++------
+ xbmc/utils/MathUtils.h            | 19 +++++++++++--------
+ 3 files changed, 26 insertions(+), 18 deletions(-)
+
+diff --git a/xbmc/cores/DllLoader/DllLoader.h b/xbmc/cores/DllLoader/DllLoader.h
+index 55ee623a7e..e3c6c7b889 100644
+--- a/xbmc/cores/DllLoader/DllLoader.h
++++ b/xbmc/cores/DllLoader/DllLoader.h
+@@ -11,19 +11,22 @@
+ #include "coffldr.h"
+ #include "LibraryLoader.h"
+ 
++// clang-format off
+ #if defined(__linux__) && \
+-    !defined(__powerpc__) && \
+-    !defined(__arm__) && \
+     !defined(__aarch64__) && \
++    !defined(__arc__) && \
++    !defined(__arm__) && \
+     !defined(__mips__) && \
++    !defined(__powerpc__) && \
++    !defined(__or1k__) && \
++    !defined(__riscv) && \
+     !defined(__SH4__) && \
+     !defined(__sparc__) && \
+-    !defined(__arc__) && \
+-    !defined(__or1k__) && \
+     !defined(__xtensa__)
+ #define USE_LDT_KEEPER
+ #include "ldt_keeper.h"
+ #endif
++// clang-format on
+ 
+ #ifndef NULL
+ #define NULL 0
+diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
+index c84fed02ad..24a81fcc04 100644
+--- a/xbmc/cores/DllLoader/ldt_keeper.c
++++ b/xbmc/cores/DllLoader/ldt_keeper.c
+@@ -18,17 +18,19 @@
+  * $Id: ldt_keeper.c 22733 2007-03-18 22:18:11Z nicodvb $
+  */
+ 
+-//#ifndef __powerpc__
+-#if !defined(__powerpc__) && \
+-    !defined(__ppc__) && \
++// clang-format off
++#if !defined(__aarch64__) && \
++    !defined(__arc__) &&\
+     !defined(__arm__) && \
+-    !defined(__aarch64__) && \
+     !defined(__mips__) && \
++    !defined(__or1k__) && \
++    !defined(__powerpc__) && \
++    !defined(__ppc__) && \
++    !defined(__riscv) && \
+     !defined(__SH4__) && \
+     !defined(__sparc__) && \
+-    !defined(__arc__) && \
+-    !defined(__or1k__) && \
+     !defined(__xtensa__)
++// clang-format on
+ 
+ #include "ldt_keeper.h"
+ 
+diff --git a/xbmc/utils/MathUtils.h b/xbmc/utils/MathUtils.h
+index 2d6ed5abe4..0cccb02ec4 100644
+--- a/xbmc/utils/MathUtils.h
++++ b/xbmc/utils/MathUtils.h
+@@ -21,19 +21,22 @@
+ // avoid including system.h or other magic includes.
+ // use 'gcc -dM -E - < /dev/null' or similar to find them.
+ 
+-#if defined(__ppc__) || \
+-    defined(__powerpc__) || \
+-    defined(__mips__) || \
+-    defined(__arm__) || \
+-    defined(__aarch64__) || \
+-    defined(__SH4__) || \
+-    defined(__sparc__) || \
++// clang-format off
++#if defined(__aarch64__) || \
+     defined(__arc__) || \
++    defined(__arm__) || \
+     defined(_M_ARM) || \
++    defined(__mips__) || \
+     defined(__or1k__) || \
++    defined(__powerpc__) || \
++    defined(__ppc__) || \
++    defined(__riscv) || \
++    defined(__SH4__) || \
++    defined(__sparc__) || \
+     defined(__xtensa__)
+-  #define DISABLE_MATHUTILS_ASM_ROUND_INT
++#define DISABLE_MATHUTILS_ASM_ROUND_INT
+ #endif
++// clang-format on
+ 
+ /*! \brief Math utility class.
+  Note that the test() routine should return true for all implementations
+-- 
+2.30.2
+
--- kodi-19.2+dfsg1/debian/patches/kodi/0025-fix-s390x-build.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0025-fix-s390x-build.patch
@@ -0,0 +1,49 @@
+From: Balint Reczey <balint@balintreczey.hu>
+Date: Tue, 3 Mar 2020 23:56:06 +0100
+Subject: Fix build on s390x
+Forwarded: not-needed
+
+Upstream is most probably not interested in this port thus I have not
+forwarded the patch.
+---
+ xbmc/cores/DllLoader/DllLoader.h  | 1 +
+ xbmc/cores/DllLoader/ldt_keeper.c | 1 +
+ xbmc/utils/MathUtils.h            | 1 +
+ 3 files changed, 3 insertions(+)
+
+diff --git a/xbmc/cores/DllLoader/DllLoader.h b/xbmc/cores/DllLoader/DllLoader.h
+index 55ee623..81681f2 100644
+--- a/xbmc/cores/DllLoader/DllLoader.h
++++ b/xbmc/cores/DllLoader/DllLoader.h
+@@ -20,6 +20,7 @@
+     !defined(__powerpc__) && \
+     !defined(__or1k__) && \
+     !defined(__riscv) && \
++    !defined(__s390x__) && \
+     !defined(__SH4__) && \
+     !defined(__sparc__) && \
+     !defined(__xtensa__)
+diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
+index 0e6bc81..1e99e57 100644
+--- a/xbmc/cores/DllLoader/ldt_keeper.c
++++ b/xbmc/cores/DllLoader/ldt_keeper.c
+@@ -27,6 +27,7 @@
+     !defined(__powerpc__) && \
+     !defined(__ppc__) && \
+     !defined(__riscv) && \
++    !defined(__s390x__) && \
+     !defined(__SH4__) && \
+     !defined(__sparc__) && \
+     !defined(__xtensa__)
+diff --git a/xbmc/utils/MathUtils.h b/xbmc/utils/MathUtils.h
+index 7a69db7..4a09672 100644
+--- a/xbmc/utils/MathUtils.h
++++ b/xbmc/utils/MathUtils.h
+@@ -31,6 +31,7 @@
+     defined(__powerpc__) || \
+     defined(__ppc__) || \
+     defined(__riscv) || \
++    defined(__s390x__) || \
+     defined(__SH4__) || \
+     defined(__sparc__) || \
+     defined(__xtensa__)
--- kodi-19.2+dfsg1/debian/patches/kodi/0026-fix-alpha-build.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0026-fix-alpha-build.patch
@@ -0,0 +1,48 @@
+From: Michael Cree <mcree@orcon.net.nz>
+Date: Tue, 3 Mar 2020 23:56:07 +0100
+Subject: Fix alpha build
+Forwarded: not-needed
+Bug: https://bugs.debian.org/856815
+
+---
+ xbmc/cores/DllLoader/DllLoader.h  | 1 +
+ xbmc/cores/DllLoader/ldt_keeper.c | 1 +
+ xbmc/utils/MathUtils.h            | 1 +
+ 3 files changed, 3 insertions(+)
+
+diff --git a/xbmc/cores/DllLoader/DllLoader.h b/xbmc/cores/DllLoader/DllLoader.h
+index 81681f2..efcc2bc 100644
+--- a/xbmc/cores/DllLoader/DllLoader.h
++++ b/xbmc/cores/DllLoader/DllLoader.h
+@@ -14,6 +14,7 @@
+ // clang-format off
+ #if defined(__linux__) && \
+     !defined(__aarch64__) && \
++    !defined(__alpha__) && \
+     !defined(__arc__) && \
+     !defined(__arm__) && \
+     !defined(__mips__) && \
+diff --git a/xbmc/cores/DllLoader/ldt_keeper.c b/xbmc/cores/DllLoader/ldt_keeper.c
+index 1e99e57..4be6ebc 100644
+--- a/xbmc/cores/DllLoader/ldt_keeper.c
++++ b/xbmc/cores/DllLoader/ldt_keeper.c
+@@ -20,6 +20,7 @@
+ 
+ // clang-format off
+ #if !defined(__aarch64__) && \
++    !defined(__alpha__) && \
+     !defined(__arc__) &&\
+     !defined(__arm__) && \
+     !defined(__mips__) && \
+diff --git a/xbmc/utils/MathUtils.h b/xbmc/utils/MathUtils.h
+index 4a09672..579151a 100644
+--- a/xbmc/utils/MathUtils.h
++++ b/xbmc/utils/MathUtils.h
+@@ -23,6 +23,7 @@
+ 
+ // clang-format off
+ #if defined(__aarch64__) || \
++    defined(__alpha__) || \
+     defined(__arc__) || \
+     defined(__arm__) || \
+     defined(_M_ARM) || \
--- kodi-19.2+dfsg1/debian/patches/kodi/0027-link-with-pthread.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0027-link-with-pthread.patch
@@ -0,0 +1,15 @@
+Description: properly link with -pthread instead of -lpthread
+Author: Aurelien Jarno <aurel32@debian.org>
+Forwarded: no
+Last-Update: 2021-10-14
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -106,6 +106,7 @@ if (NOT PLATFORMDEFS_DIR STREQUAL "")
+ endif()
+ 
+ find_package(PkgConfig)
++set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED QUIET)
+ list(APPEND DEPLIBS ${CMAKE_THREAD_LIBS_INIT})
+ 
--- kodi-19.2+dfsg1/debian/patches/kodi/0028-add-risc-v-support-to-system-info.patch
+++ kodi-19.2+dfsg1/debian/patches/kodi/0028-add-risc-v-support-to-system-info.patch
@@ -0,0 +1,34 @@
+Description: add RISC-V support to system info
+Author: Aurelien Jarno <aurel32@debian.org>
+Forwarded: add RISC-V support to system info 
+Last-Update: 2021-10-16
+
+--- a/xbmc/utils/SystemInfo.cpp
++++ b/xbmc/utils/SystemInfo.cpp
+@@ -933,7 +933,7 @@ int CSysInfo::GetKernelBitness(void)
+     {
+       std::string machine(un.machine);
+       if (machine == "x86_64" || machine == "amd64" || machine == "arm64" || machine == "aarch64" || machine == "ppc64" || machine == "ppc64el" || machine == "ppc64le" ||
+-          machine == "ia64" || machine == "mips64" || machine == "s390x")
++          machine == "ia64" || machine == "mips64" || machine == "s390x" || machine == "riscv64")
+         kernelBitness = 64;
+       else
+         kernelBitness = 32;
+@@ -988,6 +988,8 @@ const std::string& CSysInfo::GetKernelCp
+         kernelCpuFamily = "s390";
+       else if (machine.compare(0, 3, "ppc", 3) == 0 || machine.compare(0, 5, "power", 5) == 0)
+         kernelCpuFamily = "PowerPC";
++      else if (machine.compare(0, 5, "riscv", 5) == 0)
++        kernelCpuFamily = "RISC-V";
+     }
+ #endif
+     if (kernelCpuFamily.empty())
+@@ -1367,6 +1369,8 @@ std::string CSysInfo::GetBuildTargetCpuF
+   return "s390";
+ #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC)
+   return "PowerPC";
++#elif defined(__riscv)
++  return "RISC-V";
+ #else
+   return "unknown CPU family";
+ #endif
--- kodi-19.2+dfsg1/debian/patches/series
+++ kodi-19.2+dfsg1/debian/patches/series
@@ -3,10 +3,8 @@
 kodi/0003-privacy.patch
 kodi/0004-differentiate-from-vanilla-Kodi.patch
 kodi/0005-use-system-groovy.patch
-kodi/0006-fix-s390x-build.patch
 kodi/0007-fix-tests.patch
 kodi/0008-dont-use-openssl.patch
-kodi/0009-fix-alpha-build.patch
 kodi/0010-support-omitting-addons-service.patch
 kodi/0011-Find-test-fixtures-in-source-directory.patch
 kodi/0012-Skip-long-time-broken-test.patch
@@ -21,6 +19,11 @@
 kodi/0021-Detect-and-honor-big-endian-arch.patch
 kodi/0022-Add-metainfo.patch
 kodi/0023-reproducible-build-no-debugfission.patch
+kodi/0024-add-riscv-compile-defines.patch
+kodi/0025-fix-s390x-build.patch
+kodi/0026-fix-alpha-build.patch
+kodi/0027-link-with-pthread.patch
+kodi/0028-add-risc-v-support-to-system-info.patch
 libdvdnav/0001-xbmc-dvdnav-allow-get-set-vm-state.patch
 libdvdnav/0002-xbmc-dvdnav-expose-dvdnav_get_vm-dvdnav_get_button_i.patch
 libdvdnav/0003-xbmc-dvdnav-detection-of-dvd-name.patch
--- kodi-19.2+dfsg1/debian/rules
+++ kodi-19.2+dfsg1/debian/rules
@@ -58,6 +58,8 @@
 EXTRA_FLAGS := $(EXTRA_FLAGS) -DWITH_ARCH=mips
 else ifneq (,$(filter mips64el,$(DEB_HOST_ARCH)))
 EXTRA_FLAGS := $(EXTRA_FLAGS) -DWITH_ARCH=mips64
+else ifneq (,$(filter riscv64,$(DEB_HOST_ARCH)))
+EXTRA_FLAGS := $(EXTRA_FLAGS) -DWITH_ARCH=riscv64
 endif
 
 KODI_OPTS=\

Reply to: