Subject: bug#76991: [PATCH 3/3] gnu: telegram-desktop: Update to version 5.12.3.

From: Arseniy Zaostrovnykh <[email-masked]>
Date: Mon, 17 Mar 2025 09:07:53 +0100

Add three patches to fix the compilation errors raised by gcc 11.
Note: https://github.com/desktop-app/cmake_helpers/pull/320 was merged,
so telegram-desktop-unbundle-gsl.patch is no longer needed.

* gnu/packages/telegram.scm (%telegram-version): Update to 5.12.3.
(codegen-for-telegram-desktop): Update to revision used by v5.12.3.
(lib-base-for-telegram-desktop): Likewise.
(lib-lottie-for-telegram-desktop): Likewise.
(lib-rpl-for-telegram-desktop): Likewise.
(lib-spellcheck-for-telegram-desktop): Likewise.
(lib-ui-for-telegram-desktop): Likewise.
(lib-webrtc-for-telegram-desktop): Likewise.
(cmake-helpers-for-telegram-desktop): Likewise;
Remove the obsolete patch.
(lib-tl-for-telegram-desktop):
Apply a patch to fix gcc-11 compilation error.
(telegram-desktop): Update to v5.12.3;
Apply patches to make it compile.
* gnu/packages/patches/telegram-desktop-unbundle-gsl.patch: Remove.
* gnu/packages/patches/lib-tl-for-telegram-memcpy.patch: New file.
* gnu/packages/patches/telegram-desktop-hashmap-incomplete-value.patch:
New file.
* gnu/packages/patches/telegram-desktop-qguiapp.patch: New file.
* gnu/local.mk: Adjust accordingly.

Change-Id: Iaa34ff2cd3f55aa92b1d9ba61a2ff66a72eb1132
---
 gnu/local.mk                                  |  4 +-
 .../patches/lib-tl-for-telegram-memcpy.patch  | 26 ++++++++
 ...ram-desktop-hashmap-incomplete-value.patch | 59 +++++++++++++++++++
 .../patches/telegram-desktop-qguiapp.patch    | 26 ++++++++
 .../telegram-desktop-unbundle-gsl.patch       | 31 ----------
 gnu/packages/telegram.scm                     | 51 ++++++++--------
 6 files changed, 141 insertions(+), 56 deletions(-)
 create mode 100644 gnu/packages/patches/lib-tl-for-telegram-memcpy.patch
 create mode 100644 gnu/packages/patches/telegram-desktop-hashmap-incomplete-value.patch
 create mode 100644 gnu/packages/patches/telegram-desktop-qguiapp.patch
 delete mode 100644 gnu/packages/patches/telegram-desktop-unbundle-gsl.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4cb60ade0f..be04ee9afd 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1840,6 +1840,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/mcrypt-CVE-2012-4527.patch			\
   %D%/packages/patches/libmemcached-build-with-gcc7.patch	\
   %D%/packages/patches/libmhash-hmac-fix-uaf.patch		\
+  %D%/packages/patches/lib-tl-for-telegram-memcpy.patch	\
   %D%/packages/patches/llama-cpp-vulkan-optional.patch	\
   %D%/packages/patches/llhttp-ponyfill-object-fromentries.patch	\
   %D%/packages/patches/lvm2-no-systemd.patch    		\
@@ -2299,8 +2300,9 @@ dist_patch_DATA =						\
   %D%/packages/patches/texinfo-headings-single.patch		\
   %D%/packages/patches/texinfo-5-perl-compat.patch		\
   %D%/packages/patches/telegram-desktop-allow-disable-libtgvoip.patch   \
+  %D%/packages/patches/telegram-desktop-hashmap-incomplete-value.patch	\
+  %D%/packages/patches/telegram-desktop-qguiapp.patch		\
   %D%/packages/patches/telegram-desktop-unbundle-cppgir.patch   \
-  %D%/packages/patches/telegram-desktop-unbundle-gsl.patch      \
   %D%/packages/patches/telegram-purple-adjust-test.patch	\
   %D%/packages/patches/telepathy-glib-fix-test.patch	\
   %D%/packages/patches/teuchos-remove-duplicate-using.patch	\
diff --git a/gnu/packages/patches/lib-tl-for-telegram-memcpy.patch b/gnu/packages/patches/lib-tl-for-telegram-memcpy.patch
new file mode 100644
index 0000000000..5980c70fb2
--- /dev/null
+++ b/gnu/packages/patches/lib-tl-for-telegram-memcpy.patch
@@ -0,0 +1,26 @@
+From 7e08865a01b265bd884bb9e39ecc86497bcf5203 Mon Sep 17 00:00:00 2001
+From: Arseniy Zaostrovnykh <[email-masked]>
+Date: Sun, 16 Mar 2025 20:56:37 +0100
+Subject: [PATCH] tl/tl_basic_types.h: Fix compile error for missing memcpy.
+
+ * tl/tl_basic_types.h: Add include for cstring to fix the compilation
+      error about missing memcpy raised by gcc 11.
+---
+ tl/tl_basic_types.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tl/tl_basic_types.h b/tl/tl_basic_types.h
+index 5eadf62..e9b6da5 100644
+--- a/tl/tl_basic_types.h
++++ b/tl/tl_basic_types.h
+@@ -11,6 +11,7 @@
+ #include "base/bytes.h"
+ 
+ #include <QtCore/QVector>
++#include <cstring>
+ 
+ namespace tl {
+ namespace details {
+-- 
+2.48.1
+
diff --git a/gnu/packages/patches/telegram-desktop-hashmap-incomplete-value.patch b/gnu/packages/patches/telegram-desktop-hashmap-incomplete-value.patch
new file mode 100644
index 0000000000..f162adf269
--- /dev/null
+++ b/gnu/packages/patches/telegram-desktop-hashmap-incomplete-value.patch
@@ -0,0 +1,59 @@
+From 3865a179b3aed172bac4a3dcd1f320270de16dcf Mon Sep 17 00:00:00 2001
+From: Arseniy Zaostrovnykh <[email-masked]>
+Date: Sun, 16 Mar 2025 20:49:16 +0100
+Subject: [PATCH] dialogs_inner_widget: Fix use-before-def compile error.
+
+ * Telegram/SourceFiles/dialogs/dialogs_inner_widget.h: Include headers
+      and eagerly define TagCache to avoid using under-defined types for
+      std::unsigned_map values.
+ * Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp: Remove the
+      definition of TagCache that is now in the header.
+---
+ Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp | 5 -----
+ Telegram/SourceFiles/dialogs/dialogs_inner_widget.h   | 7 ++++++-
+ 2 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp
+index 39e047897..9687405aa 100644
+--- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp
++++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp
+@@ -247,11 +247,6 @@ struct InnerWidget::PeerSearchResult {
+ 	BasicRow row;
+ };
+ 
+-struct InnerWidget::TagCache {
+-	Ui::ChatsFilterTagContext context;
+-	QImage frame;
+-};
+-
+ Key InnerWidget::FilterResult::key() const {
+ 	return row->key();
+ }
+diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h
+index 2500f43d1..c85c5ce32 100644
+--- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h
++++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h
+@@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+ #include "ui/effects/animations.h"
+ #include "ui/rp_widget.h"
+ #include "ui/userpic_view.h"
++#include "dialogs/dialogs_common.h"
++#include "ui/chat/chats_filter_tag.h"
+ 
+ namespace style {
+ struct DialogRow;
+@@ -226,7 +228,10 @@ private:
+ 	struct CollapsedRow;
+ 	struct HashtagResult;
+ 	struct PeerSearchResult;
+-	struct TagCache;
++	struct TagCache {
++		Ui::ChatsFilterTagContext context;
++		QImage frame;
++	};
+ 
+ 	enum class JumpSkip {
+ 		PreviousOrBegin,
+-- 
+2.48.1
+
diff --git a/gnu/packages/patches/telegram-desktop-qguiapp.patch b/gnu/packages/patches/telegram-desktop-qguiapp.patch
new file mode 100644
index 0000000000..a5d8e32443
--- /dev/null
+++ b/gnu/packages/patches/telegram-desktop-qguiapp.patch
@@ -0,0 +1,26 @@
+From 1f0dd322053c462c1ac291948a42f7187cfd37ae Mon Sep 17 00:00:00 2001
+From: Arseniy Zaostrovnykh <[email-masked]>
+Date: Sun, 16 Mar 2025 20:45:06 +0100
+Subject: [PATCH] current_geo_location_linux.cpp: Add a missing include.
+
+* Telegram/SourceFiles/platform/linux/current_geo_location_linux.cpp:
+    Fix the missing class compilation failure reported by gcc-11.
+---
+ .../SourceFiles/platform/linux/current_geo_location_linux.cpp    | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Telegram/SourceFiles/platform/linux/current_geo_location_linux.cpp b/Telegram/SourceFiles/platform/linux/current_geo_location_linux.cpp
+index 7015af739..326ccbf28 100644
+--- a/Telegram/SourceFiles/platform/linux/current_geo_location_linux.cpp
++++ b/Telegram/SourceFiles/platform/linux/current_geo_location_linux.cpp
+@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+ #include "core/current_geo_location.h"
+ #include "base/platform/linux/base_linux_library.h"
+ 
++#include <QGuiApplication>
+ #include <gio/gio.h>
+ 
+ namespace Platform {
+-- 
+2.48.1
+
diff --git a/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch b/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch
deleted file mode 100644
index f89d326a5c..0000000000
--- a/gnu/packages/patches/telegram-desktop-unbundle-gsl.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From a3ac6df0441b4caca28b1df87febc420e18942ce Mon Sep 17 00:00:00 2001
-From: Zephyr Lykos <[email-masked]>
-Date: Mon, 23 Oct 2023 15:55:24 +0800
-Subject: [PATCH] Revert "Force usage of GSL fork because of a libstdc++ bug."
-
-This reverts commit 982546b169df3d479e6511425870327559b38a89.
-<https://github.com/microsoft/GSL/commit/e64c97fc2cfc11992098bb38eda932de275e3f4d>
----
- external/gsl/CMakeLists.txt | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/external/gsl/CMakeLists.txt b/external/gsl/CMakeLists.txt
-index 8eaf19c5..344f9488 100644
---- a/external/gsl/CMakeLists.txt
-+++ b/external/gsl/CMakeLists.txt
-@@ -7,7 +7,6 @@
- add_library(external_gsl INTERFACE IMPORTED GLOBAL)
- add_library(desktop-app::external_gsl ALIAS external_gsl)
- 
--#[[
- if (DESKTOP_APP_USE_PACKAGED)
-     if (DESKTOP_APP_USE_PACKAGED_LAZY)
-         find_package(Microsoft.GSL 4.0.0 QUIET)
-@@ -20,7 +19,6 @@ if (DESKTOP_APP_USE_PACKAGED)
-         return()
-     endif()
- endif()
--]]
- 
- # https://gitlab.kitware.com/cmake/cmake/-/issues/25222
- if (NOT EXISTS ${third_party_loc}/GSL/include)
diff --git a/gnu/packages/telegram.scm b/gnu/packages/telegram.scm
index c0b2122bf5..37772fa274 100644
--- a/gnu/packages/telegram.scm
+++ b/gnu/packages/telegram.scm
@@ -83,7 +83,7 @@ (define-module (gnu packages telegram)
   #:use-module (guix build-system python)
   #:use-module (guix build-system qt))
 
-(define %telegram-version "5.5.5")
+(define %telegram-version "5.12.3")
 
 (define libyuv-for-telegram-desktop
   (let ((commit "04821d1e7d60845525e8db55c7bcd41ef5be9406")
@@ -105,41 +105,39 @@ (define cmake-helpers-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/cmake_helpers.git")
-          (commit "05a7db2e2d2a59ecf42483debca4944d09154b5b")))
+          (commit "90e6d73100a9fd2dc4c30a270c3bbc1d35924f32")))
     (file-name
      (git-file-name "cmake-helpers-for-telegram-desktop" %telegram-version))
     (patches
-     ;; https://github.com/desktop-app/cmake_helpers/pull/320
      ;; https://github.com/desktop-app/cmake_helpers/pull/305
-     (search-patches "telegram-desktop-unbundle-gsl.patch"
-                     "telegram-desktop-unbundle-cppgir.patch"))
+     (search-patches "telegram-desktop-unbundle-cppgir.patch"))
     (sha256
      (base32
-      "1gapyk5a8rsl8vigbz0l8h9858f2lkhkd2pjy72zivp0mrq8w0hr"))))
+      "0mpz0adsyzsr5crxcjfr96x133yl4j55nm5f3gv5w1q1g1vk283r"))))
 
 (define codegen-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/codegen.git")
-          (commit "0af136124083369073b8fdaf45f0816fd2b10bad")))
+          (commit "4155b9ae2d4c5a37b9738afa8ef9fa20d8fdcb44")))
     (file-name
      (git-file-name "codegen-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "057bwn9smrgnyfb1vraf50ihbkhjc4d72msl7vnbqc4h5sg8dav9"))))
+      "1h45rsi4nrkr3j312ji8qlkbzsb948nszmnylwimh5v65n90p21a"))))
 
 (define lib-base-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_base.git")
-          (commit "547e7f2914d9b5548dd17e70a3a7bf5d6606afc3")))
+          (commit "b28088164b7a46c70ae2cfd9daf865f6425610b2")))
     (file-name
      (git-file-name "lib-base-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0sgm2prhd4fw89afh62k7i4i7mj60n170kqz50b0mad927zngxvn"))))
+      "1dwqdnasn3igr7i14hkx1glxj0gn6rd852bj0w3k1ai9j295wnfz"))))
 
 (define lib-crl-for-telegram-desktop
   (origin
@@ -158,12 +156,12 @@ (define lib-lottie-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_lottie.git")
-          (commit "1a700e5a0d7c3e2f617530354ff2a47c5c72bb4a")))
+          (commit "3eb4a97f1dd038bc4b6bd2884262242382a37e79")))
     (file-name
      (git-file-name "lib-lottie-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "18w35sz6k3wcv07v0szx3avpfdl0rjby6yqm1fzmx7fqw2jn6wpl"))))
+      "04sgbspp0wngpr5w2wjfl1hwk1kiy8kwk2sz841f1yj231s7v6xw"))))
 
 (define lib-qr-for-telegram-desktop
   (origin
@@ -182,24 +180,24 @@ (define lib-rpl-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_rpl.git")
-          (commit "8b1015d1bd57ef03fcd07a3eeddd3f5a9b688ade")))
+          (commit "9a3ce435f4054e6cbd45e1c6e3e27cfff515c829")))
     (file-name
      (git-file-name "lib-rpl-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "12sdhaqby5vlvd5jsj12b3xsqiaknqvijv9ydlyxclx8zail64lv"))))
+      "02g84i1d1hb5kqnhfr90fnw8nq1khqky95x52v2kx8zz05i1r8vs"))))
 
 (define lib-spellcheck-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_spellcheck.git")
-          (commit "e76981e133a1d29f3ceb557f53850a8d822f439a")))
+          (commit "8809cc72d07087ec61a1e8569de4da95aac45474")))
     (file-name
      (git-file-name "lib-spellcheck-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0dslsy3d6gmxaj6yv49zjgl2b2mh75j7fpnbynglr02h3m2fdj96"))))
+      "0zxk7vxr29f8scdi2ymvvz4zh9zkln8r57y1n65x0vfi8vdihn1a"))))
 
 (define lib-storage-for-telegram-desktop
   (origin
@@ -221,6 +219,8 @@ (define lib-tl-for-telegram-desktop
           (commit "237cbeb9d1c637759f89a508c1d854caf16e1984")))
     (file-name
      (git-file-name "lib-tl-for-telegram-desktop" %telegram-version))
+    (patches
+     (search-patches "lib-tl-for-telegram-memcpy.patch"))
     (sha256
      (base32
       "1ji3gypy4yf9knsgylnyz5gc2kii7lls5ymj1rkf0daixdz931cm"))))
@@ -230,36 +230,36 @@ (define lib-ui-for-telegram-desktop
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_ui.git")
-          (commit "c4e3a08e6fb90a6174c8b592d9eb747dd4d3f9c5")))
+          (commit "ba969667301ae4d8da2c2f6c4528bea63443f607")))
     (file-name
      (git-file-name "lib-ui-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "1lbfy4fbb52lklfwn6kxny3mwl653r4vc80k922kwjfgbcy9c25f"))))
+      "17h6awwna9qn98a0zk85xhh8ibgh3g7665khpgd752pya4jg27jw"))))
 
 (define lib-webrtc-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_webrtc.git")
-          (commit "8751e27d50d2f26b5d20673e5ddba38e90953570")))
+          (commit "169ba6b1d5e58e9d1cfa7b7d5c85c119e6c6e2db")))
     (file-name
      (git-file-name "lib-webrtc-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "0f05pqb83qckghzlhnwqbi9qfi9xw7qsv8jampl4qyaq9q0w9p20"))))
+      "0xh24qdy82j9mricja4ahzrsw9bgiklqy2mc0r891cblmmm2d90j"))))
 
 (define lib-webview-for-telegram-desktop
   (origin
     (method git-fetch)
     (uri (git-reference
           (url "https://github.com/desktop-app/lib_webview.git")
-          (commit "2de655f58dc327e40d5d9df71300a0d0fdb39c9f")))
+          (commit "f546969919a5946d49a504f8159041fa5b55c3df")))
     (file-name
      (git-file-name "lib-webview-for-telegram-desktop" %telegram-version))
     (sha256
      (base32
-      "12vrif0685vb068mj5sd7cknav1n66jysp18j21nlp0am9pw7ydj"))))
+      "178mf6lvgj4y5lscb68pc0yn3jcn66g04zszj74hpya18zjbmavw"))))
 
 (define tgcalls-for-telegram-desktop
   (origin
@@ -433,11 +433,14 @@ (define-public telegram-desktop
        (file-name
         (git-file-name name version))
        (sha256
-        (base32 "12fdybn085s3i3a8hwi0bmdns7jxvg0k662n04jgffirgsz8n54m"))
+        (base32 "16dfk36xfsizrxmxcid9kwj2dvxfp42382hqcan9rsrgjlqm6ymy"))
        (patches
         (search-patches
          ;; https://github.com/telegramdesktop/tdesktop/pull/24126
-         "telegram-desktop-allow-disable-libtgvoip.patch"))
+         "telegram-desktop-allow-disable-libtgvoip.patch"
+         ;; Make it compatible with GCC 11.
+         "telegram-desktop-qguiapp.patch"
+         "telegram-desktop-hashmap-incomplete-value.patch"))
        (modules '((guix build utils)
                   (ice-9 ftw)
                   (srfi srfi-1)))
-- 
2.48.1