[PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

Jonathan Wakely jwakely@redhat.com
Tue Jan 7 15:43:00 GMT 2020


On 07/01/20 15:40 +0000, Jonathan Wakely wrote:
>On 07/01/20 01:30 +0100, Kamil Rytarowski wrote:
>>On 07.01.2020 01:26, Jonathan Wakely wrote:
>>>On 06/01/20 23:20 +0100, Kamil Rytarowski wrote:
>>>>On 06.01.2020 16:24, Jonathan Wakely wrote:
>>>>>On 22/12/19 09:36 +1000, Gerald Pfeifer wrote:
>>>>>>Hi Matthew,
>>>>>>
>>>>>>On Mon, 4 Feb 2019, Matthew Bauer wrote:
>>>>>>>The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>>>>>>>have changed their ctype.h definition. It was updated in their intree
>>>>>>>libstdc++-v3 but not in the GCC one. My understanding is this is a
>>>>>>>straightforward rewrite. I've attached my own patch, but the file can
>>>>>>>be obtained directly here:
>>>>>>>
>>>>>>>http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>With the attached patch, libstdc++-v3 can succesfully be built with
>>>>>>>NetBSD headers (along with --disable-libcilkrts).
>>>>>>
>>>>>>I noticed this has not been applied yet, nor seen a follow-up?, and
>>>>>>also
>>>>>>noticed it went to the gcc-patches list, but not libstdc++@gcc.gnu.org.
>>>>>>
>>>>>>Let me re-address this to libstdc++@gcc.gnu.org in the hope the
>>>>>>maintainers there will have a look.
>>>>>>
>>>>>>Gerald
>>>>>
>>>>>>diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>>b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>>index ff3ec893974..21eccf9fde1 100644
>>>>>>--- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>>+++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>>@@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>>>>  /// @brief  Base class for ctype.
>>>>>>  struct ctype_base
>>>>>>  {
>>>>>>-    // Non-standard typedefs.
>>>>>>-    typedef const unsigned char*    __to_type;
>>>>>>
>>>>>>    // NB: Offsets into ctype<char>::_M_table force a particular size
>>>>>>    // on the mask type. Because of this, we don't use an enum.
>>>>>>-    typedef unsigned char          mask;
>>>>>>
>>>>>>#ifndef _CTYPE_U
>>>>>>-    static const mask upper        = _U;
>>>>>>-    static const mask lower     = _L;
>>>>>>-    static const mask alpha     = _U | _L;
>>>>>>-    static const mask digit     = _N;
>>>>>>-    static const mask xdigit     = _N | _X;
>>>>>>-    static const mask space     = _S;
>>>>>>-    static const mask print     = _P | _U | _L | _N | _B;
>>>>>>-    static const mask graph     = _P | _U | _L | _N;
>>>>>>-    static const mask cntrl     = _C;
>>>>>>-    static const mask punct     = _P;
>>>>>>-    static const mask alnum     = _U | _L | _N;
>>>>>>+    // Non-standard typedefs.
>>>>>>+    typedef const unsigned char*    __to_type;
>>>>>>+
>>>>>>+    typedef unsigned char    mask;
>>>>>>+
>>>>>>+    static const mask upper    = _U;
>>>>>>+    static const mask lower    = _L;
>>>>>>+    static const mask alpha    = _U | _L;
>>>>>>+    static const mask digit    = _N;
>>>>>>+    static const mask xdigit    = _N | _X;
>>>>>>+    static const mask space    = _S;
>>>>>>+    static const mask print    = _P | _U | _L | _N | _B;
>>>>>>+    static const mask graph    = _P | _U | _L | _N;
>>>>>>+    static const mask cntrl    = _C;
>>>>>>+    static const mask punct    = _P;
>>>>>>+    static const mask alnum    = _U | _L | _N;
>>>>>>#else
>>>>>>-    static const mask upper        = _CTYPE_U;
>>>>>>-    static const mask lower     = _CTYPE_L;
>>>>>>-    static const mask alpha     = _CTYPE_U | _CTYPE_L;
>>>>>>-    static const mask digit     = _CTYPE_N;
>>>>>>-    static const mask xdigit     = _CTYPE_N | _CTYPE_X;
>>>>>>-    static const mask space     = _CTYPE_S;
>>>>>>-    static const mask print     = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>>>>_CTYPE_N | _CTYPE_B;
>>>>>>-    static const mask graph     = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>>>>_CTYPE_N;
>>>>>>-    static const mask cntrl     = _CTYPE_C;
>>>>>>-    static const mask punct     = _CTYPE_P;
>>>>>>-    static const mask alnum     = _CTYPE_U | _CTYPE_L | _CTYPE_N;
>>>>>>+    typedef const unsigned short*    __to_type;
>>>>>>+
>>>>>>+    typedef unsigned short    mask;
>>>>>
>>>>>I seem to recall looking at this previously and noting that the change
>>>>>to ctype_base::mask is an ABI break. It means that code compiled with
>>>>>old versions of GCC or on old versions of NetBSD will not be ABI
>>>>>compatible with code compiled by a new GCC on a new version of NetBSD.
>>>>>
>>>>>If the NetBSD maintainers are OK with that, then we can go ahead and
>>>>>change it.
>>>>>
>>>>>
>>>>
>>>>We are fine with ABI breaks as we bump libstdc++ major on each upgrade
>>>>in base.
>>>
>>>That affects the libstdc++ built from NetBSD ports collection, but if
>>>somebody builds GCC themselves using the upstream sources (which is
>>>what these patches are trying to change) then they don't get that
>>>bumped major version.
>>>
>>>So if somebody builds GCC 9 themselves, and then builds GCC 10
>>>themselves on the same machine, they'll get two versions of
>>>libstdc++.so that are not ABI compatible.
>>>
>>>
>>
>>I know, but we don't support this in NetBSD. We ship with our own major
>>numbers for GCC. If someone wants to maintain out of base or out of
>>pkgsrc it will have likely more problems than ABI breakage.
>
>But that's exactly what upstream GCC sources are (out of pkgsrc), and
>that's where I'm being asked to include this patch.
>
>NetBSD is free to not support it, of course, but we (GCC) have
>different schedules and different priorities.
>
>And if older versions of NetBSD are not supported, can we just drop
>the `#ifndef _CTYPE_U` branch in config/os/bsd/netbsd/ctype_base.h ?
>
>It seems wrong to keep support for old systems in one file and drop it
>in another file.

For Jason and Krister's benefit, that last comment was referring to
an earlier suggestion to not try to support old NetBSD releases, see
https://gcc.gnu.org/ml/libstdc++/2020-01/msg00026.html

>I think we need the netbsd target maintainers (CC'd) to decide whether
>GCC should still support older releases or drop that support for GCC
>10. Usually I'd say we need a period of deprecation, but if GCC
>doesn't currently build on NetBSD then maybe that's unnecessary.
>
>
>



More information about the Libstdc++ mailing list