Subject: [bug#71897] [PATCH v8 8/8] gnu: telegram-desktop: Update to 5.5.5.

From: dan <[email-masked]>
Date: Sun, 22 Sep 2024 12:09:50 +0800

Hi Maxim,

Maxim Cournoyer <[email-masked]> writes:

>> +               (add-after 'use-system-xdg-desktop-portal 
>> 'patch-libwebview
>> +                 (lambda _
>> +                   (substitute* 
>> "Telegram/lib_webview/webview/webview_interface.h"
>> +                     (("constexpr ") ""))))
>
> GCC should know about constexpr; perhaps the wrong C++ standard 
> (can be
> provided via a CMake flag) is being selected, or alternatively 
> you could
> provide a newer gcc compiler native inputs?

The original compilation error is:
--8<---------------cut here---------------start------------->8---
/tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/webview_interface.h:34:38: 
error: call to non-?constexpr? function ?typename 
__gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type 
std::operator==(const std::__cxx11::basic_string<_CharT>&, const 
std::__cxx11::basic_string<_CharT>&) [with _CharT = char; typename 
__gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type 
= bool]?
   34 |         friend inline constexpr bool operator==(
      |                                      ^~~~~~~~
In file included from 
/gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/string:55,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/locale_classes.h:40,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/ios_base.h:41,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/streambuf:41,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/streambuf_iterator.h:35,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/iterator:66,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/ranges_algobase.h:36,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/ranges_algo.h:35,
                 from 
                 /gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/algorithm:64,
                 from 
                 /gnu/store/mz9sf8vsp2qksx1vb4fz8mrz4pkypfmc-qtbase-5.15.10/include/qt5/QtCore/qglobal.h:142,
                 from 
                 /gnu/store/mz9sf8vsp2qksx1vb4fz8mrz4pkypfmc-qtbase-5.15.10/include/qt5/QtCore/qiterator.h:43,
                 from 
                 /gnu/store/mz9sf8vsp2qksx1vb4fz8mrz4pkypfmc-qtbase-5.15.10/include/qt5/QtCore/qmap.h:43,
                 from 
                 /gnu/store/mz9sf8vsp2qksx1vb4fz8mrz4pkypfmc-qtbase-5.15.10/include/qt5/QtCore/QMap:1,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_base/base/ordered_set.h:9,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_base/base/basic_types.h:10,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/webview_common.h:9,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/webview_interface.h:9,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/platform/linux/webview_linux.h:9,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/platform/linux/webview_linux_webkitgtk.h:9,
                 from 
                 /tmp/guix-build-telegram-desktop-5.5.5.drv-0/source/Telegram/lib_webview/webview/platform/linux/webview_linux_webkitgtk.cpp:7:
/gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/basic_string.h:6234:5: 
note: ?typename 
__gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type 
std::operator==(const std::__cxx11::basic_string<_CharT>&, const 
std::__cxx11::basic_string<_CharT>&) [with _CharT = char; typename 
__gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type 
= bool]? declared here
 6234 |     operator==(const basic_string<_CharT>& __lhs,
      |     ^~~~~~~~
--8<---------------cut here---------------end--------------->8---

The problematic code in telegram-desktop is:
--8<---------------cut here---------------start------------->8---
struct NavigationHistoryState {
	std::string url;
	std::string title;
	bool canGoBack : 1 = false;
	bool canGoForward : 1 = false;

	friend inline constexpr bool operator==(
		NavigationHistoryState,
		NavigationHistoryState) = default;
};
--8<---------------cut here---------------end--------------->8---

And the code in 
/gnu/store/86fc8bi3mciljxz7c79jx8zr4wsx7xw8-gcc-11.4.0/include/c++/bits/basic_string.h 
is:
--8<---------------cut here---------------start------------->8---
  template<typename _CharT>
    inline
    typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, 
    bool>::__type
    operator==(const basic_string<_CharT>& __lhs,
	       const basic_string<_CharT>& __rhs) 
	       _GLIBCXX_NOEXCEPT
    { return (__lhs.size() == __rhs.size()
	      && !std::char_traits<_CharT>::compare(__lhs.data(), 
	      __rhs.data(),
						    __lhs.size())); 
						    }
--8<---------------cut here---------------end--------------->8---

In gcc-12, the code looks like this:
--8<---------------cut here---------------start------------->8---
  template<typename _CharT>
    _GLIBCXX20_CONSTEXPR
    inline
    typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, 
    bool>::__type
    operator==(const basic_string<_CharT>& __lhs,
	       const basic_string<_CharT>& __rhs) 
	       _GLIBCXX_NOEXCEPT
    { return (__lhs.size() == __rhs.size()
	      && !std::char_traits<_CharT>::compare(__lhs.data(), 
	      __rhs.data(),
						    __lhs.size())); 
						    }
--8<---------------cut here---------------end--------------->8---
Which indeed has the constexpr.

But as I explained in previous reply, I failed at using a newer 
version of gcc.  Thus, I think trivially remove the constexpr from 
telegram-desktop's source is the easiest fix here.

-- 
dan