lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 048b530 1/4: Require compiler to provide


From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] master 048b530 1/4: Require compiler to provide operator<=>
Date: Wed, 12 May 2021 12:23:16 +0200

On Tue, 11 May 2021 22:53:13 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

GC> On 5/11/21 10:12 PM, Vadim Zeitlin wrote:
GC> > On Wed, 12 May 2021 00:00:04 +0200 I wrote:
GC> [...]
GC> > Me> commit 270aaa6ab1bd89bcf781d1c08d1662b2de447973
GC> > Me> Author: Vadim Zeitlin <vadim@tt-solutions.com>
GC> > Me> Date:   2021-05-11 17:51:35 +0200
GC> > Me> 
GC> > Me>     Add workaround for Boost.Regex compilation with clang 11
GC> > 
GC> >  Sorry, I've realized that nothing prevents me from defining this symbol 
in
GC> > configure, if necessary, as clang is only used with configure anyhow
GC> > currently,
GC> 
GC> I already tested it, so I pushed it anyway. It causes no harm.
GC> The header it changes is only a kludge.

 I had already put the alternative solution in place by the time I have
received the notification email about your commit so, just in case you
prefer it, the following commit could be applied after reverting f62151ab4
(Add workaround for Boost.Regex compilation with clang 11, 2021-05-11):

---------------------------------- >8 --------------------------------------
>From 4c477c1cd73087b249ef0fd3e2b9d7c324fd7dd7 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@tt-solutions.com>
Date: Wed, 12 May 2021 00:29:58 +0200
Subject: [PATCH] Work around std::allocator::size_type problem in clang 11
 libc++

This (and only this) version of libc++ has apparently mistakenly removed
std::allocator::size_type definition, which is still present in C++20,
and requires predefining a special symbol in order to do it -- which we
must do to compile boost/regex.hpp as it (indirectly) uses this type.

Add a configure test checking if we really need to do it and do define
it if it is required.
---
 configure.ac | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/configure.ac b/configure.ac
index 178861988..911138dbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,6 +365,36 @@ dnl Restore pre-wx CPPFLAGS value only now, we needed wx 
flags for
 dnl wxPdfDocument checks.
 CPPFLAGS=$save_CPPFLAGS

+dnl Add clang-specific workaround before checking for Boost, as its headers use
+dnl std::allocator::size_type.
+dnl
+dnl This is necessary because libc++ used by clang 11 mistakenly removed
+dnl std::allocator::size_type, which is finally not removed by C++20. Luckily,
+dnl we still can predefine _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS to
+dnl get its declaration, but we don't want to do this unconditionally because
+dnl this also reintroduces other, really removed, members in later clang
+dnl versions, so only do it if we need it.
+if test "$CLANG" = "yes"; then
+    m4_define([lmi_cxx_alloc_test], [[
+#include <memory>
+std::allocator<char*>::size_type s = 17;
+    ]])
+    AC_CACHE_CHECK([whether clang requires workaround for 
std::allocator::size_type],
+        lmi_cv_cxx_alloc_workaround_needed,
+        [
+            AC_LANG_PUSH([C++])
+            AC_COMPILE_IFELSE([AC_LANG_SOURCE([lmi_cxx_alloc_test])],
+                lmi_cv_cxx_alloc_workaround_needed=no,
+                [CXXFLAGS="$CXXFLAGS 
-D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS"
+                 AC_COMPILE_IFELSE([AC_LANG_SOURCE([lmi_cxx_alloc_test])],
+                    lmi_cv_cxx_alloc_workaround_needed=yes,
+                    AC_MSG_ERROR([std::allocator::size_type unavailable]))]
+            )
+            AC_LANG_POP([C++])
+        ]
+    )
+fi
+
 dnl --- Boost (required) ---
 if test "x$lmi_boost_headers" != "x"; then
     CPPFLAGS="$CPPFLAGS -I$lmi_boost_headers"
--
2.31.0
---------------------------------- >8 --------------------------------------

 Note that I've used git-format-patch to produce the text above, just in
case you want to git-apply it yourself (previously I've just shown the
output of git-show, which can't be applied directly, AFAIK, but is slightly
more readable, so I used it because I didn't think you'd want to apply it
immediately, sorry).

 Of course, I can also push this myself, with my other changes to
configure, please just let me know if I should. I do prefer this version
because, if nothing else, it has a better commit message: I somehow thought
that std::allocator<T>::size_type was indeed deprecated in C++20, but it
isn't actually the case, so I have no idea why did libc++ people removed
it. I _guess_ it might have been done in some draft, but I'm too lazy to
check it, to be honest.

 Anyhow, sorry again for wasting your time with this,
VZ

Attachment: pgpXTCW3bLAOc.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]