Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: profiles/features/musl/, net-im/telegram-desktop/, ...
Date: Wed, 23 Feb 2022 04:25:37
Message-Id: 1645590143.56239ca5e225079d4b8605f577031339f077bdfa.gyakovlev@gentoo
1 commit: 56239ca5e225079d4b8605f577031339f077bdfa
2 Author: Esteve Varela Colominas <esteve.varela <AT> gmail <DOT> com>
3 AuthorDate: Sat Feb 19 21:03:39 2022 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Wed Feb 23 04:22:23 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=56239ca5
7
8 net-im/telegram-desktop: Add musl support
9
10 Signed-off-by: Esteve Varela Colominas <esteve.varela <AT> gmail.com>
11 Closes: https://github.com/gentoo/gentoo/pull/24278
12 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
13
14 .../tdesktop-3.5.2-jemalloc-only-telegram.patch | 14 ++---
15 .../files/tdesktop-3.5.2-jemalloc-optional.patch | 71 ++++++++++++++++++++++
16 .../files/tdesktop-3.5.2-musl.patch | 33 ++++++++++
17 ...5.2.ebuild => telegram-desktop-3.5.2-r1.ebuild} | 30 +++++----
18 profiles/base/package.use.force | 6 ++
19 profiles/features/musl/package.use | 4 ++
20 profiles/features/musl/package.use.force | 4 ++
21 7 files changed, 144 insertions(+), 18 deletions(-)
22
23 diff --git a/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-only-telegram.patch b/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-only-telegram.patch
24 index 837cfaf38b7c..4f5c7017e6ac 100644
25 --- a/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-only-telegram.patch
26 +++ b/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-only-telegram.patch
27 @@ -7,19 +7,19 @@ improve runtime memory use, it's unnecessary to use it for anything else.
28
29 --- tdesktop-3.5.2-full.orig/Telegram/CMakeLists.txt
30 +++ tdesktop-3.5.2-full/Telegram/CMakeLists.txt
31 -@@ -1335,6 +1335,12 @@
32 - endif()
33 +@@ -1357,6 +1357,12 @@
34 + desktop-app::external_kwayland
35 + )
36 endif()
37 - else()
38 ++
39 + target_link_libraries(Telegram
40 + PRIVATE
41 + desktop-app::linux_jemalloc_helper
42 + $<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
43 + )
44 -+
45 - if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
46 - target_link_libraries(Telegram
47 - PRIVATE
48 + endif()
49 +
50 + if (build_macstore)
51 --- tdesktop-3.5.2-full.orig/cmake/options_linux.cmake
52 +++ tdesktop-3.5.2-full/cmake/options_linux.cmake
53 @@ -64,8 +64,6 @@
54
55 diff --git a/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-optional.patch b/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-optional.patch
56 new file mode 100644
57 index 000000000000..bd3595858c20
58 --- /dev/null
59 +++ b/net-im/telegram-desktop/files/tdesktop-3.5.2-jemalloc-optional.patch
60 @@ -0,0 +1,71 @@
61 +Optionally disable jemalloc
62 +
63 +Telegram upstream heavily insists you use the jemalloc allocator. This is due
64 +to the high memory usage resulting from the glibc allocator. It is unknown why
65 +this affects telegram the way it does, but upstream solved the issue by using a
66 +different allocator. Initially they used mallocng, now jemalloc.
67 +
68 +However, other libcs don't necessarily need this, and as such this should be
69 +optional. As mallocng is a fork of musl's allocator, and this was used before
70 +the switch to jemalloc, the musl allocator should still be OK.
71 +
72 +Please warn glibc users about disabling jemalloc, don't report bugs about
73 +memory usage upstream unless you're using jemalloc.
74 +
75 +Related info:
76 +https://github.com/telegramdesktop/tdesktop/issues/16084
77 +https://github.com/desktop-app/cmake_helpers/pull/91#issuecomment-881788003
78 +
79 +--- tdesktop-3.5.2-full.orig/Telegram/CMakeLists.txt
80 ++++ tdesktop-3.5.2-full/Telegram/CMakeLists.txt
81 +@@ -1358,11 +1358,13 @@
82 + )
83 + endif()
84 +
85 +- target_link_libraries(Telegram
86 +- PRIVATE
87 +- desktop-app::linux_jemalloc_helper
88 +- $<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
89 +- )
90 ++ if (NOT DESKTOP_APP_DISABLE_JEMALLOC)
91 ++ target_link_libraries(Telegram
92 ++ PRIVATE
93 ++ desktop-app::linux_jemalloc_helper
94 ++ $<TARGET_OBJECTS:desktop-app::linux_jemalloc_helper>
95 ++ )
96 ++ endif()
97 + endif()
98 +
99 + if (build_macstore)
100 +--- tdesktop-3.5.2-full.orig/cmake/CMakeLists.txt
101 ++++ tdesktop-3.5.2-full/cmake/CMakeLists.txt
102 +@@ -5,7 +5,7 @@
103 + # https://github.com/desktop-app/legal/blob/master/LEGAL
104 +
105 + add_subdirectory(external)
106 +-if (LINUX)
107 ++if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
108 + add_subdirectory(linux_jemalloc_helper)
109 + endif()
110 + if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
111 +--- tdesktop-3.5.2-full.orig/cmake/external/CMakeLists.txt
112 ++++ tdesktop-3.5.2-full/cmake/external/CMakeLists.txt
113 +@@ -37,7 +37,7 @@
114 + add_checked_subdirectory(hunspell)
115 + endif()
116 + add_checked_subdirectory(iconv)
117 +-if (LINUX)
118 ++if (LINUX AND NOT DESKTOP_APP_DISABLE_JEMALLOC)
119 + add_checked_subdirectory(jemalloc)
120 + endif()
121 + add_checked_subdirectory(jpeg)
122 +--- tdesktop-3.5.2-full.orig/cmake/variables.cmake
123 ++++ tdesktop-3.5.2-full/cmake/variables.cmake
124 +@@ -26,6 +26,7 @@
125 + option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled patched ones." OFF)
126 + option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled patched one." OFF)
127 + option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF)
128 ++option(DESKTOP_APP_DISABLE_JEMALLOC "Disable use of the jemalloc allocator (Linux only)." OFF)
129 + option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target})
130 + option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate})
131 + option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
132
133 diff --git a/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch b/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch
134 new file mode 100644
135 index 000000000000..4c34d107913e
136 --- /dev/null
137 +++ b/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch
138 @@ -0,0 +1,33 @@
139 +Stub out some glibc-specific functions
140 +
141 +This allows support for alternative libcs like musl
142 +
143 +--- tdesktop-3.5.2-full.orig/Telegram/lib_base/base/platform/linux/base_info_linux.cpp
144 ++++ tdesktop-3.5.2-full/Telegram/lib_base/base/platform/linux/base_info_linux.cpp
145 +@@ -22,7 +22,7 @@
146 +
147 + #include <sys/utsname.h>
148 +
149 +-#ifdef Q_OS_LINUX
150 ++#if defined(Q_OS_LINUX) && defined(__GLIBC__)
151 + #include <gnu/libc-version.h>
152 + #endif // Q_OS_LINUX
153 +
154 +@@ -200,7 +200,7 @@
155 + }
156 +
157 + QString GetLibcName() {
158 +-#ifdef Q_OS_LINUX
159 ++#if defined(Q_OS_LINUX) && defined(__GLIBC__)
160 + return "glibc";
161 + #endif // Q_OS_LINUX
162 +
163 +@@ -208,7 +208,7 @@
164 + }
165 +
166 + QString GetLibcVersion() {
167 +-#ifdef Q_OS_LINUX
168 ++#if defined(Q_OS_LINUX) && defined(__GLIBC__)
169 + static const auto result = [&] {
170 + const auto version = QString::fromLatin1(gnu_get_libc_version());
171 + return QVersionNumber::fromString(version).isNull() ? QString() : version;
172
173 diff --git a/net-im/telegram-desktop/telegram-desktop-3.5.2.ebuild b/net-im/telegram-desktop/telegram-desktop-3.5.2-r1.ebuild
174 similarity index 82%
175 rename from net-im/telegram-desktop/telegram-desktop-3.5.2.ebuild
176 rename to net-im/telegram-desktop/telegram-desktop-3.5.2-r1.ebuild
177 index 8a4ae5891361..98ffdd9164d6 100644
178 --- a/net-im/telegram-desktop/telegram-desktop-3.5.2.ebuild
179 +++ b/net-im/telegram-desktop/telegram-desktop-3.5.2-r1.ebuild
180 @@ -17,7 +17,7 @@ S="${WORKDIR}/${MY_P}"
181 LICENSE="BSD GPL-3-with-openssl-exception LGPL-2+"
182 SLOT="0"
183 KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
184 -IUSE="+dbus enchant +hunspell screencast +spell wayland +X"
185 +IUSE="+dbus enchant +hunspell +jemalloc screencast +spell wayland +X"
186 REQUIRED_USE="
187 spell? (
188 ^^ ( enchant hunspell )
189 @@ -28,7 +28,6 @@ RDEPEND="
190 !net-im/telegram-desktop-bin
191 app-arch/lz4:=
192 dev-cpp/abseil-cpp:=
193 - dev-libs/jemalloc:=[-lazy-lock]
194 dev-libs/libdispatch
195 dev-libs/openssl:=
196 dev-libs/xxhash
197 @@ -54,6 +53,7 @@ RDEPEND="
198 )
199 enchant? ( app-text/enchant:= )
200 hunspell? ( >=app-text/hunspell-1.7:= )
201 + jemalloc? ( dev-libs/jemalloc:=[-lazy-lock] )
202 wayland? ( kde-frameworks/kwayland:= )
203 X? ( x11-libs/libxcb:= )
204 "
205 @@ -71,6 +71,8 @@ BDEPEND="
206 PATCHES=(
207 "${FILESDIR}/tdesktop-3.5.2-jemalloc-only-telegram.patch"
208 "${FILESDIR}/tdesktop-3.3.0-fix-enchant.patch"
209 + "${FILESDIR}/tdesktop-3.5.2-musl.patch"
210 + "${FILESDIR}/tdesktop-3.5.2-jemalloc-optional.patch"
211 )
212
213 # Current desktop-file-utils-0.26 does not understand Version=1.5
214 @@ -95,17 +97,20 @@ src_prepare() {
215 }
216
217 src_configure() {
218 - # gtk is really needed for image copy-paste due to https://bugreports.qt.io/browse/QTBUG-56595
219 local mycmakeargs=(
220 -DTDESKTOP_LAUNCHER_BASENAME="${PN}"
221 -DCMAKE_DISABLE_FIND_PACKAGE_tl-expected=ON # header only lib, some git version. prevents warnings.
222 -DDESKTOP_APP_QT6=OFF
223
224 - -DDESKTOP_APP_DISABLE_X11_INTEGRATION=$(usex X no yes)
225 - -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=$(usex wayland no yes)
226 - -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION=$(usex dbus no yes)
227 - -DDESKTOP_APP_DISABLE_SPELLCHECK=$(usex spell no yes) # enables hunspell (recommended)
228 + -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION=$(usex !dbus)
229 + -DDESKTOP_APP_DISABLE_X11_INTEGRATION=$(usex !X)
230 + -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=$(usex !wayland)
231 + -DDESKTOP_APP_DISABLE_SPELLCHECK=$(usex !spell) # enables hunspell (recommended)
232 -DDESKTOP_APP_USE_ENCHANT=$(usex enchant) # enables enchant and disables hunspell
233 +
234 + # This option is heavily discouraged by upstream.
235 + # See files/tdesktop-*-jemalloc-optional.patch
236 + -DDESKTOP_APP_DISABLE_JEMALLOC=$(usex !jemalloc)
237 )
238
239 if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then
240 @@ -131,10 +136,6 @@ src_configure() {
241 )
242 fi
243
244 - # Fix for RISCV, as well as any other platforms that might generate libatomic calls
245 - # Upstreamed in >3.4.3
246 - append-ldflags '-pthread'
247 -
248 cmake_src_configure
249 }
250
251 @@ -142,10 +143,17 @@ pkg_postinst() {
252 xdg_pkg_postinst
253 if ! use X && ! use screencast; then
254 elog "both the 'X' and 'screencast' useflags are disabled, screen sharing won't work!"
255 + elog
256 fi
257 if has_version '<dev-qt/qtcore-5.15.2-r10'; then
258 ewarn "Versions of dev-qt/qtcore lower than 5.15.2-r10 might cause telegram"
259 ewarn "to crash when pasting big images from the clipboard."
260 + ewarn
261 + fi
262 + if ! use jemalloc && use elibc_glibc; then
263 + ewarn "Disabling USE=jemalloc on glibc systems may cause very high RAM usage!"
264 + ewarn "Do NOT report issues about RAM usage without enabling this flag first."
265 + ewarn
266 fi
267 optfeature_header
268 optfeature "shop payment support (requires USE=dbus enabled)" net-libs/webkit-gtk
269
270 diff --git a/profiles/base/package.use.force b/profiles/base/package.use.force
271 index 579e9e3cac43..abd8fbe4ffb3 100644
272 --- a/profiles/base/package.use.force
273 +++ b/profiles/base/package.use.force
274 @@ -1,6 +1,12 @@
275 # Copyright 1999-2022 Gentoo Authors
276 # Distributed under the terms of the GNU General Public License v2
277
278 +# Esteve Varela Colominas <esteve.varela@×××××.com> (2022-02-19)
279 +# Use the jemalloc allocator for telegram, as recommended by upstream,
280 +# to reduce memory usage, at least on glibc.
281 +# See the ebuild for more info.
282 +net-im/telegram-desktop jemalloc
283 +
284 # Sam James <sam@g.o> (2022-02-11)
285 # Always build with PIE-default, just like GCC.
286 sys-devel/clang pie
287
288 diff --git a/profiles/features/musl/package.use b/profiles/features/musl/package.use
289 index 9f8906ae5648..686670ae9ef4 100644
290 --- a/profiles/features/musl/package.use
291 +++ b/profiles/features/musl/package.use
292 @@ -1,6 +1,10 @@
293 # Copyright 1999-2018 Gentoo Foundation.
294 # Distributed under the terms of the GNU General Public License v2
295
296 +# Esteve Varela Colominas <esteve.varela@×××××.com> (2022-02-19)
297 +# The musl allocator works well with telegram
298 +net-im/telegram-desktop -jemalloc
299 +
300 # Anthony G. Basile <blueness@g.o> (2016-07-14)
301 # We need this to break a circular dependency with
302 # 'sys-libs/libcap pam' in stage3 catalyst builds
303
304 diff --git a/profiles/features/musl/package.use.force b/profiles/features/musl/package.use.force
305 index f11de170c840..c5f7ed10b1ea 100644
306 --- a/profiles/features/musl/package.use.force
307 +++ b/profiles/features/musl/package.use.force
308 @@ -1,6 +1,10 @@
309 # Copyright 1999-2021 Gentoo Authors.
310 # Distributed under the terms of the GNU General Public License v2
311
312 +# Esteve Varela Colominas <esteve.varela@×××××.com> (2022-02-19)
313 +# The musl allocator works well with telegram
314 +net-im/telegram-desktop -jemalloc
315 +
316 # Andreas K. Hüttel <dilfridge@g.o> (2021-07-14)
317 # Do not force system install for libxcrypt here
318 >=sys-libs/libxcrypt-4.4.23-r1 -system -compat