Rather out of my depth but I ran into another instance of the problem
that's come up before with ctypes/C++ headers/xlocale (see also
https://marc.info/?l=openbsd-bugs&m=157758838031146&w=2 and
https://marc.info/?l=openbsd-bugs&m=161528248931449&w=2), i.e.
the C++ headers unconditionally depend on something which is
only defined conditionally.

In this case it was with a port which wanted to use _XOPEN_SOURCE=600,
so __BSD_VISIBLE is defined to 0, so the definition of vasprintf() in
stdio.h is hidden, but it's used here:

/usr/include/c++/v1/__bsd_locale_fallbacks.h:
    117 inline
    118 int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format
, ...) {
    119     va_list __va;
    120     va_start(__va, __format);
    121     __libcpp_locale_guard __current(__l);
    122     int __res = vasprintf(__s, __format, __va);
    123     va_end(__va);
    124     return __res;
    125 }

Unfortunately for this one it's not just providing a definition in
the locale header but is actually used in code:

/usr/include/c++/v1/locale:
   1566 template <class _CharT, class _OutputIterator>
   1567 _OutputIterator
   1568 num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __io
b,
   1569                                          char_type __fl, double __v) c
onst
   1570 {
...
   1585     if (__nc > static_cast<int>(__nbuf-1))
   1586     {
   1587         if (__specify_precision)
   1588             __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, 
__fmt, (int)__iob.precision(), __v);
   1589         else
   1590             __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, 
__fmt, __v);
   1591         if (__nc == -1)
   1592             __throw_bad_alloc();
   1593         __nbh.reset(__nb);

As well as the vasprintf it also hit the usual "unknown type name
'locale_t'" for the various functions in __strtonum_fallback.h.

For the port concerned (games/gargoyle) patching to remove _XOPEN_SOURCE
was enough to workaround but that's not always the case (and it's rather
non-obvious from the errors).

I tried forward-porting jsg's diff in the earlier thread, but the files
changed a bit in the meantime with libc++ updates, and it seems the
locale_t-related #ifdefs miss many of the entries in the file anyway
- and adding them to the other cases is going to make the header
rather non-functional.

Does anyone have ideas about how we could handle this? Or should we
just ignore for now and continue to throw rocks at ports where we run
into it? ;)

Reply via email to