Gentoo Archives: gentoo-commits

From: "Jakov Smolić" <jsmolic@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-tv/kodi/files/, media-tv/kodi/
Date: Fri, 26 Aug 2022 14:38:12
Message-Id: 1661524689.7342318ebb39976b31c697e4cfe7221d348e5ed6.jsmolic@gentoo
1 commit: 7342318ebb39976b31c697e4cfe7221d348e5ed6
2 Author: Yixun Lan <dlan <AT> gentoo <DOT> org>
3 AuthorDate: Thu Aug 25 13:36:16 2022 +0000
4 Commit: Jakov Smolić <jsmolic <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 26 14:38:09 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7342318e
7
8 media-tv/kodi: fix missing atomic library issue
9
10 Upstream: https://github.com/xbmc/xbmc/pull/21743
11 Closes: https://bugs.gentoo.org/864421
12 Signed-off-by: Yixun Lan <dlan <AT> gentoo.org>
13 Closes: https://github.com/gentoo/gentoo/pull/27016
14 Signed-off-by: Jakov Smolić <jsmolic <AT> gentoo.org>
15
16 media-tv/kodi/files/kodi-19.4-atomic.patch | 108 +++++++++++++++++++++++++++++
17 media-tv/kodi/kodi-19.4-r2.ebuild | 1 +
18 2 files changed, 109 insertions(+)
19
20 diff --git a/media-tv/kodi/files/kodi-19.4-atomic.patch b/media-tv/kodi/files/kodi-19.4-atomic.patch
21 new file mode 100644
22 index 000000000000..3811fda8886d
23 --- /dev/null
24 +++ b/media-tv/kodi/files/kodi-19.4-atomic.patch
25 @@ -0,0 +1,108 @@
26 +From ac3213e683e4c62c50dc02fef3b168d883245094 Mon Sep 17 00:00:00 2001
27 +From: Yixun Lan <dlan@g.o>
28 +Date: Tue, 9 Aug 2022 16:45:09 +0800
29 +Subject: [PATCH] [cmake] link atomic library for certain CPU architectures
30 +
31 +For those CPU architectures:
32 +RISC-V lack 8-bit and 16-bit atomic instructions, and
33 +ARM/MIPS/PPC lack 64-bit atomic instruction.
34 +
35 +GCC is supposed to convert these atomics via masking and shifting
36 +like LLVM, which means anything that wants to use these instructions
37 +needs the link option -latomic.
38 +
39 +In this patch, we will try to detect if 8-bit, 64-bit atomic instructions exist,
40 +otherwise the atomic library will append to the DEPLIBS list.
41 +
42 +Original issue:
43 +* https://gitlab.kitware.com/cmake/cmake/-/issues/23021#note_1098733
44 +
45 +For reference:
46 +* https://gcc.gnu.org/wiki/Atomic/GCCMM
47 +
48 +riscv64 specific:
49 +* https://lists.debian.org/debian-riscv/2022/01/msg00009.html
50 +
51 +Signed-off-by: Yixun Lan <dlan@g.o>
52 +---
53 + cmake/modules/FindAtomic.cmake | 56 +++++++++++++++++++++++++++++
54 + cmake/scripts/linux/ArchSetup.cmake | 3 ++
55 + 2 files changed, 59 insertions(+)
56 + create mode 100644 cmake/modules/FindAtomic.cmake
57 +
58 +diff --git a/cmake/modules/FindAtomic.cmake b/cmake/modules/FindAtomic.cmake
59 +new file mode 100644
60 +index 0000000000..8ea3c815d7
61 +--- /dev/null
62 ++++ b/cmake/modules/FindAtomic.cmake
63 +@@ -0,0 +1,56 @@
64 ++#.rst:
65 ++# FindAtomic
66 ++# -----
67 ++# Finds the ATOMIC library
68 ++#
69 ++# This will define the following variables::
70 ++#
71 ++# ATOMIC_FOUND - system has ATOMIC
72 ++# ATOMIC_LIBRARIES - the ATOMIC libraries
73 ++#
74 ++# and the following imported targets::
75 ++#
76 ++# ATOMIC::ATOMIC - The ATOMIC library
77 ++
78 ++
79 ++include(CheckCXXSourceCompiles)
80 ++
81 ++set(atomic_code
82 ++ "
83 ++ #include <atomic>
84 ++ #include <cstdint>
85 ++ std::atomic<uint8_t> n8 (0); // riscv64
86 ++ std::atomic<uint64_t> n64 (0); // armel, mipsel, powerpc
87 ++ int main() {
88 ++ ++n8;
89 ++ ++n64;
90 ++ return 0;
91 ++ }")
92 ++
93 ++check_cxx_source_compiles("${atomic_code}" ATOMIC_LOCK_FREE_INSTRUCTIONS)
94 ++
95 ++if(ATOMIC_LOCK_FREE_INSTRUCTIONS)
96 ++ set(ATOMIC_FOUND TRUE)
97 ++ set(ATOMIC_LIBRARIES)
98 ++else()
99 ++ set(CMAKE_REQUIRED_LIBRARIES "-latomic")
100 ++ check_cxx_source_compiles("${atomic_code}" ATOMIC_IN_LIBRARY)
101 ++ set(CMAKE_REQUIRED_LIBRARIES)
102 ++ if(ATOMIC_IN_LIBRARY)
103 ++ set(ATOMIC_LIBRARY atomic)
104 ++ include(FindPackageHandleStandardArgs)
105 ++ find_package_handle_standard_args(Atomic DEFAULT_MSG ATOMIC_LIBRARY)
106 ++ set(ATOMIC_LIBRARIES ${ATOMIC_LIBRARY})
107 ++ if(NOT TARGET ATOMIC::ATOMIC)
108 ++ add_library(ATOMIC::ATOMIC UNKNOWN IMPORTED)
109 ++ set_target_properties(ATOMIC::ATOMIC PROPERTIES
110 ++ IMPORTED_LOCATION "${ATOMIC_LIBRARY}")
111 ++ endif()
112 ++ unset(ATOMIC_LIBRARY)
113 ++ else()
114 ++ if(Atomic_FIND_REQUIRED)
115 ++ message(FATAL_ERROR "Neither lock free instructions nor -latomic found.")
116 ++ endif()
117 ++ endif()
118 ++endif()
119 ++unset(atomic_code)
120 +diff --git a/cmake/scripts/linux/ArchSetup.cmake b/cmake/scripts/linux/ArchSetup.cmake
121 +index 35ab1402f5..848723af1f 100644
122 +--- a/cmake/scripts/linux/ArchSetup.cmake
123 ++++ b/cmake/scripts/linux/ArchSetup.cmake
124 +@@ -199,3 +199,6 @@ if(NOT USE_INTERNAL_LIBS)
125 + set(USE_INTERNAL_LIBS OFF)
126 + endif()
127 + endif()
128 ++
129 ++# Atomic library
130 ++list(APPEND PLATFORM_REQUIRED_DEPS Atomic)
131 +--
132 +2.35.1
133 +
134
135 diff --git a/media-tv/kodi/kodi-19.4-r2.ebuild b/media-tv/kodi/kodi-19.4-r2.ebuild
136 index 060512a9f02d..eb948b74ad25 100644
137 --- a/media-tv/kodi/kodi-19.4-r2.ebuild
138 +++ b/media-tv/kodi/kodi-19.4-r2.ebuild
139 @@ -35,6 +35,7 @@ inherit autotools cmake desktop linux-info pax-utils python-single-r1 xdg
140
141 PATCHES=(
142 "${FILESDIR}/${P}-fmt-9.patch"
143 + "${FILESDIR}/${P}-atomic.patch"
144 )
145
146 DESCRIPTION="A free and open source media-player and entertainment hub"