NetBSD Problem Report #56102
From www@netbsd.org Mon Apr 12 00:27:38 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C65711A9217
for <gnats-bugs@gnats.NetBSD.org>; Mon, 12 Apr 2021 00:27:38 +0000 (UTC)
Message-Id: <20210412002737.7272E1A9239@mollari.NetBSD.org>
Date: Mon, 12 Apr 2021 00:27:37 +0000 (UTC)
From: tobiasu@tmux.org
Reply-To: tobiasu@tmux.org
To: gnats-bugs@NetBSD.org
Subject: libstc++ missing locale_t if _XOPEN_SOURCE defined
X-Send-Pr-Version: www-1.0
>Number: 56102
>Category: toolchain
>Synopsis: libstc++ missing locale_t if _XOPEN_SOURCE defined
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Apr 12 00:30:01 +0000 2021
>Last-Modified: Mon Apr 12 01:40:01 +0000 2021
>Originator: Tobias Ulmer
>Release: NetBSD 9.99.81
>Organization:
>Environment:
NetBSD wind.tmux.org 9.99.81 NetBSD 9.99.81 (GENERIC) #0: Sat Apr 10 15:34:05 UTC 2021 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
>Description:
Trying to build https://github.com/abseil/abseil-cpp from source (because youcompleteme), it fails.
In pkgsrc this is fixed by removing _XOPEN_SOURCE: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/abseil/patches/patch-absl_time_internal_cctz_src_time__zone__format.cc?rev=1.1&content-type=text/x-cvsweb-markup
But come on guys, that's not a fix. Let me paste you the error message:
--8<--
[ 5%] Building CXX object absl/absl/time/CMakeFiles/absl_time_zone.dir/internal/cctz/src/time_zone_format.cc.o
In file included from /usr/include/g++/bits/localefwd.h:40,
from /usr/include/g++/string:43,
from /home/tobiasu/.vimruntime/YouCompleteMe_/third_party/ycmd/cpp/absl/absl/time/internal/cctz/include/cctz/time_zone.h:25,
from /home/tobiasu/.vimruntime/YouCompleteMe_/third_party/ycmd/cpp/absl/absl/time/internal/cctz/src/time_zone_format.cc:28:
/usr/include/g++/bits/c++locale.h: In function ‘int std::__convert_from_v(int* const&, char*, int, const char*, ...)’:
/usr/include/g++/bits/c++locale.h:82:51: error: ‘locale_t’ was not declared in this scope
82 | const int __ret = vsnprintf_l(__out, __size, (locale_t)__cloc, __fmt,
| ^~~~~~~~
/usr/include/g++/bits/c++locale.h:82:23: error: ‘vsnprintf_l’ was not declared in this scope; did you mean ‘vsnprintf’?
82 | const int __ret = vsnprintf_l(__out, __size, (locale_t)__cloc, __fmt,
| ^~~~~~~~~~~
| vsnprintf
--8<--
/usr/include/g++/bits/c++locale.h modified by NetBSD quite a bit.
locale_t is not defined in this situation because it's guarded everywhere:
#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
_POSIX_C_SOURCE is not defined because C++, duh
_NETBSD_SOURCE is not defined because sys/featuretest.h prevents its definition if _XOPEN_SOURCE is already defined.
>How-To-Repeat:
Build this with g++:
#define _XOPEN_SOURCE 1
#include <string>
int main() { return 0; }
>Fix:
Maybe include locale.h and define __SETLOCALE_SOURCE__ internally?
>Audit-Trail:
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: toolchain/56102: libstc++ missing locale_t if _XOPEN_SOURCE
defined
Date: Mon, 12 Apr 2021 02:49:43 +0200
On Mon, Apr 12, 2021 at 12:30:01AM +0000, tobiasu@tmux.org wrote:
> In pkgsrc this is fixed by removing _XOPEN_SOURCE: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/abseil/patches/patch-absl_time_internal_cctz_src_time__zone__format.cc?rev=1.1&content-type=text/x-cvsweb-markup
>
> But come on guys, that's not a fix. Let me paste you the error message:
Source is definitely wrong. locale_t shouldn't be present for
_XOPEN_SOURCE<700. Now likely should care about it for
_XOPEN_SOURCE=700, but then you can just use _POSIX_C_SOURCE=200809L in
that case...
Joerg
From: Tobias Ulmer <tobiasu@tmux.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: toolchain/56102: libstc++ missing locale_t if _XOPEN_SOURCE
defined
Date: Mon, 12 Apr 2021 03:35:55 +0200
On Mon, Apr 12, 2021 at 12:50:01AM +0000, Joerg Sonnenberger wrote:
> The following reply was made to PR toolchain/56102; it has been noted by GNATS.
>
> From: Joerg Sonnenberger <joerg@bec.de>
> To: gnats-bugs@netbsd.org
> Cc:
> Subject: Re: toolchain/56102: libstc++ missing locale_t if _XOPEN_SOURCE
> defined
> Date: Mon, 12 Apr 2021 02:49:43 +0200
>
> On Mon, Apr 12, 2021 at 12:30:01AM +0000, tobiasu@tmux.org wrote:
> > In pkgsrc this is fixed by removing _XOPEN_SOURCE: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/abseil/patches/patch-absl_time_internal_cctz_src_time__zone__format.cc?rev=1.1&content-type=text/x-cvsweb-markup
> >
> > But come on guys, that's not a fix. Let me paste you the error message:
>
> Source is definitely wrong. locale_t shouldn't be present for
> _XOPEN_SOURCE<700. Now likely should care about it for
> _XOPEN_SOURCE=700, but then you can just use _POSIX_C_SOURCE=200809L in
> that case...
>
> Joerg
>
I'm not buying it. This is an internal method of libstdc++.
It's an implementation detail that I should not have to care about even
one bit.
The reproducer doesn't even use or call anything. C++ has locales
regardless of what C or crusty old unix standards say.
But in the end it's your decision and I'm not attached enough to this
OS to fight for it.
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.