public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jakov Smolić" <jsmolic@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: media-tv/kodi/files/, media-tv/kodi/
Date: Fri, 26 Aug 2022 14:38:08 +0000 (UTC)	[thread overview]
Message-ID: <1661524689.7342318ebb39976b31c697e4cfe7221d348e5ed6.jsmolic@gentoo> (raw)

commit:     7342318ebb39976b31c697e4cfe7221d348e5ed6
Author:     Yixun Lan <dlan <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 25 13:36:16 2022 +0000
Commit:     Jakov Smolić <jsmolic <AT> gentoo <DOT> org>
CommitDate: Fri Aug 26 14:38:09 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7342318e

media-tv/kodi: fix missing atomic library issue

Upstream: https://github.com/xbmc/xbmc/pull/21743
Closes: https://bugs.gentoo.org/864421
Signed-off-by: Yixun Lan <dlan <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/27016
Signed-off-by: Jakov Smolić <jsmolic <AT> gentoo.org>

 media-tv/kodi/files/kodi-19.4-atomic.patch | 108 +++++++++++++++++++++++++++++
 media-tv/kodi/kodi-19.4-r2.ebuild          |   1 +
 2 files changed, 109 insertions(+)

diff --git a/media-tv/kodi/files/kodi-19.4-atomic.patch b/media-tv/kodi/files/kodi-19.4-atomic.patch
new file mode 100644
index 000000000000..3811fda8886d
--- /dev/null
+++ b/media-tv/kodi/files/kodi-19.4-atomic.patch
@@ -0,0 +1,108 @@
+From ac3213e683e4c62c50dc02fef3b168d883245094 Mon Sep 17 00:00:00 2001
+From: Yixun Lan <dlan@gentoo.org>
+Date: Tue, 9 Aug 2022 16:45:09 +0800
+Subject: [PATCH] [cmake] link atomic library for certain CPU architectures
+
+For those CPU architectures:
+RISC-V lack 8-bit and 16-bit atomic instructions, and
+ARM/MIPS/PPC lack 64-bit atomic instruction.
+
+GCC is supposed  to convert these atomics via masking and shifting
+like LLVM, which means anything that wants to use these instructions
+needs the link option -latomic.
+
+In this patch, we will try to detect if 8-bit, 64-bit atomic instructions exist,
+otherwise the atomic library will append to the DEPLIBS list.
+
+Original issue:
+* https://gitlab.kitware.com/cmake/cmake/-/issues/23021#note_1098733
+
+For reference:
+* https://gcc.gnu.org/wiki/Atomic/GCCMM
+
+riscv64 specific:
+* https://lists.debian.org/debian-riscv/2022/01/msg00009.html
+
+Signed-off-by: Yixun Lan <dlan@gentoo.org>
+---
+ cmake/modules/FindAtomic.cmake      | 56 +++++++++++++++++++++++++++++
+ cmake/scripts/linux/ArchSetup.cmake |  3 ++
+ 2 files changed, 59 insertions(+)
+ create mode 100644 cmake/modules/FindAtomic.cmake
+
+diff --git a/cmake/modules/FindAtomic.cmake b/cmake/modules/FindAtomic.cmake
+new file mode 100644
+index 0000000000..8ea3c815d7
+--- /dev/null
++++ b/cmake/modules/FindAtomic.cmake
+@@ -0,0 +1,56 @@
++#.rst:
++# FindAtomic
++# -----
++# Finds the ATOMIC library
++#
++# This will define the following variables::
++#
++# ATOMIC_FOUND - system has ATOMIC
++# ATOMIC_LIBRARIES - the ATOMIC libraries
++#
++# and the following imported targets::
++#
++#   ATOMIC::ATOMIC    - The ATOMIC library
++
++
++include(CheckCXXSourceCompiles)
++
++set(atomic_code
++    "
++     #include <atomic>
++     #include <cstdint>
++     std::atomic<uint8_t> n8 (0); // riscv64
++     std::atomic<uint64_t> n64 (0); // armel, mipsel, powerpc
++     int main() {
++       ++n8;
++       ++n64;
++       return 0;
++     }")
++
++check_cxx_source_compiles("${atomic_code}" ATOMIC_LOCK_FREE_INSTRUCTIONS)
++
++if(ATOMIC_LOCK_FREE_INSTRUCTIONS)
++  set(ATOMIC_FOUND TRUE)
++  set(ATOMIC_LIBRARIES)
++else()
++  set(CMAKE_REQUIRED_LIBRARIES "-latomic")
++  check_cxx_source_compiles("${atomic_code}" ATOMIC_IN_LIBRARY)
++  set(CMAKE_REQUIRED_LIBRARIES)
++  if(ATOMIC_IN_LIBRARY)
++    set(ATOMIC_LIBRARY atomic)
++    include(FindPackageHandleStandardArgs)
++    find_package_handle_standard_args(Atomic DEFAULT_MSG ATOMIC_LIBRARY)
++    set(ATOMIC_LIBRARIES ${ATOMIC_LIBRARY})
++    if(NOT TARGET ATOMIC::ATOMIC)
++      add_library(ATOMIC::ATOMIC UNKNOWN IMPORTED)
++      set_target_properties(ATOMIC::ATOMIC PROPERTIES
++	      IMPORTED_LOCATION "${ATOMIC_LIBRARY}")
++    endif()
++    unset(ATOMIC_LIBRARY)
++  else()
++    if(Atomic_FIND_REQUIRED)
++      message(FATAL_ERROR "Neither lock free instructions nor -latomic found.")
++    endif()
++  endif()
++endif()
++unset(atomic_code)
+diff --git a/cmake/scripts/linux/ArchSetup.cmake b/cmake/scripts/linux/ArchSetup.cmake
+index 35ab1402f5..848723af1f 100644
+--- a/cmake/scripts/linux/ArchSetup.cmake
++++ b/cmake/scripts/linux/ArchSetup.cmake
+@@ -199,3 +199,6 @@ if(NOT USE_INTERNAL_LIBS)
+     set(USE_INTERNAL_LIBS OFF)
+   endif()
+ endif()
++
++# Atomic library
++list(APPEND PLATFORM_REQUIRED_DEPS Atomic)
+-- 
+2.35.1
+

diff --git a/media-tv/kodi/kodi-19.4-r2.ebuild b/media-tv/kodi/kodi-19.4-r2.ebuild
index 060512a9f02d..eb948b74ad25 100644
--- a/media-tv/kodi/kodi-19.4-r2.ebuild
+++ b/media-tv/kodi/kodi-19.4-r2.ebuild
@@ -35,6 +35,7 @@ inherit autotools cmake desktop linux-info pax-utils python-single-r1 xdg
 
 PATCHES=(
 	"${FILESDIR}/${P}-fmt-9.patch"
+	"${FILESDIR}/${P}-atomic.patch"
 )
 
 DESCRIPTION="A free and open source media-player and entertainment hub"


             reply	other threads:[~2022-08-26 14:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 14:38 Jakov Smolić [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-14 20:12 [gentoo-commits] repo/gentoo:master commit in: media-tv/kodi/files/, media-tv/kodi/ Andreas Sturmlechner
2024-08-25 16:10 Sam James
2024-06-02  7:10 Sam James
2024-05-23 18:01 Matt Turner
2024-01-21  4:41 Sam James
2023-05-31  3:07 Sam James
2023-01-30  3:27 Sam James
2022-12-17 19:38 Craig Andrews
2020-08-04 20:43 Craig Andrews
2020-06-23 18:44 Craig Andrews
2019-12-06 17:07 Craig Andrews
2019-09-05 17:30 Craig Andrews
2019-09-02 20:42 Craig Andrews
2019-02-18  3:01 Craig Andrews
2018-11-28 16:33 Craig Andrews
2018-06-25 17:37 Craig Andrews
2017-10-23 13:36 Craig Andrews
2017-01-20 16:52 Jory Pratt
2017-01-17 19:38 David Seifert
2017-01-17 18:57 David Seifert
2016-02-24 10:00 Alexis Ballier
2015-08-26  5:27 Mike Frysinger
2015-08-26  5:23 Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1661524689.7342318ebb39976b31c697e4cfe7221d348e5ed6.jsmolic@gentoo \
    --to=jsmolic@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox