NetBSD Problem Report #49989
From www@NetBSD.org Sat Jun 20 15:01:18 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 588CDA654F
for <gnats-bugs@gnats.NetBSD.org>; Sat, 20 Jun 2015 15:01:18 +0000 (UTC)
Message-Id: <20150620150117.16A6CA65E4@mollari.NetBSD.org>
Date: Sat, 20 Jun 2015 15:01:17 +0000 (UTC)
From: pooka@iki.fi
Reply-To: pooka@iki.fi
To: gnats-bugs@NetBSD.org
Subject: libc++ fails to build with g++ 5.1 due to libpthread volatiles
X-Send-Pr-Version: www-1.0
>Number: 49989
>Category: lib
>Synopsis: libc++ fails to build with g++ 5.1 due to libpthread volatiles
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 20 15:05:00 +0000 2015
>Closed-Date: Thu Aug 27 12:35:04 +0000 2015
>Last-Modified: Thu Aug 27 12:35:04 +0000 2015
>Originator: Antti Kantee
>Release: some future NetBSD
>Organization:
>Environment:
>Description:
libc++ fails to build with g++ 5.1 due to the following types of errors:
=== snip ===
libc++/dist/libcxx/include/__mutex_base:32:69: error: temporary of non-literal type '__pthread_mutex_st' in a constant expression
constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
[...]
include/pthread_types.h:101:8: note: '__pthread_mutex_st' is not literal because:
struct __pthread_mutex_st {
^
include/pthread_types.h:103:17: note: non-static data member '__pthread_mutex_st::ptm_errorcheck' has volatile type
pthread_spin_t ptm_errorcheck;
=== snip ===
For a full build log including the full g++ error output, see:
https://gist.githubusercontent.com/anonymous/566a26a930fa2d902894/raw/6824c3c138580bff415caddec3bdf1062d560a31/build.log
(via rumprun issue #33)
>How-To-Repeat:
On a(n x86) system with g++ 5.1, git clone repo.rumpkernel.org/rumprun and run "./build-rr.sh hw".
>Fix:
No idea, I don't speak C++. Not sure if this is a libpthread problem or a libc++ problem. (it might even be a g++ problem, in which case it's not a NetBSD bug and this report can be closed, but my money is on the first two and hence submitting it here)
>Release-Note:
>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread volatiles
Date: Sat, 20 Jun 2015 12:04:52 -0400
On Jun 20, 3:05pm, pooka@iki.fi (pooka@iki.fi) wrote:
-- Subject: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread v
Index: pthread_types.h
===================================================================
RCS file: /cvsroot/src/lib/libpthread/pthread_types.h,v
retrieving revision 1.13
diff -u -u -r1.13 pthread_types.h
--- pthread_types.h 2 Aug 2008 19:46:30 -0000 1.13
+++ pthread_types.h 20 Jun 2015 16:03:04 -0000
@@ -84,6 +84,23 @@
};
/*
+ * libc++ expects to be using PTHREAD_MUTEX_INITIALIZER as a member
+ * initializer. This does not work for volatile types. Since c++
+ * does not touch the guts of those types, we redefine them as non-volatile
+ */
+#ifdef __cplusplus
+# ifdef __CPU_SIMPLE_LOCK_PAD
+# define __pthread_mutex_spin_t unsigned char
+# else
+# define __pthread_mutex_spin_t unsigned int
+# endif
+# define __pthread_mutex_volatile
+#else
+# define __pthread_mutex_spin_t pthread_spin_t
+# define __pthread_mutex_volatile volatile
+#endif
+
+/*
* ptm_owner is the actual lock field which is locked via CAS operation.
* This structure's layout is designed to compatible with the previous
* version used in SA pthreads.
@@ -100,16 +117,16 @@
#endif
struct __pthread_mutex_st {
unsigned int ptm_magic;
- pthread_spin_t ptm_errorcheck;
+ __pthread_mutex_spin_t ptm_errorcheck;
#ifdef __CPU_SIMPLE_LOCK_PAD
uint8_t ptm_pad1[3];
#endif
- pthread_spin_t ptm_interlock; /* unused - backwards compat */
+ __pthread_mutex_spin_t ptm_interlock; /* unused - backwards compat */
#ifdef __CPU_SIMPLE_LOCK_PAD
uint8_t ptm_pad2[3];
#endif
- volatile pthread_t ptm_owner;
- pthread_t * volatile ptm_waiters;
+ __pthread_mutex_volatile pthread_t ptm_owner;
+ pthread_t * __pthread_mutex_volatile ptm_waiters;
unsigned int ptm_recursed;
void *ptm_spare2; /* unused - backwards compat */
};
From: Antti Kantee <pooka@iki.fi>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread
volatiles
Date: Sat, 20 Jun 2015 16:12:15 +0000
Thanks, Christos!
I'll ask the submitter to test.
On 20/06/15 16:05, Christos Zoulas wrote:
> Index: pthread_types.h
> ===================================================================
> RCS file: /cvsroot/src/lib/libpthread/pthread_types.h,v
> retrieving revision 1.13
> diff -u -u -r1.13 pthread_types.h
> --- pthread_types.h 2 Aug 2008 19:46:30 -0000 1.13
> +++ pthread_types.h 20 Jun 2015 16:03:04 -0000
> @@ -84,6 +84,23 @@
> };
>
> /*
> + * libc++ expects to be using PTHREAD_MUTEX_INITIALIZER as a member
> + * initializer. This does not work for volatile types. Since c++
> + * does not touch the guts of those types, we redefine them as non-volatile
> + */
> +#ifdef __cplusplus
> +# ifdef __CPU_SIMPLE_LOCK_PAD
> +# define __pthread_mutex_spin_t unsigned char
> +# else
> +# define __pthread_mutex_spin_t unsigned int
> +# endif
> +# define __pthread_mutex_volatile
> +#else
> +# define __pthread_mutex_spin_t pthread_spin_t
> +# define __pthread_mutex_volatile volatile
> +#endif
> +
> +/*
> * ptm_owner is the actual lock field which is locked via CAS operation.
> * This structure's layout is designed to compatible with the previous
> * version used in SA pthreads.
> @@ -100,16 +117,16 @@
> #endif
> struct __pthread_mutex_st {
> unsigned int ptm_magic;
> - pthread_spin_t ptm_errorcheck;
> + __pthread_mutex_spin_t ptm_errorcheck;
> #ifdef __CPU_SIMPLE_LOCK_PAD
> uint8_t ptm_pad1[3];
> #endif
> - pthread_spin_t ptm_interlock; /* unused - backwards compat */
> + __pthread_mutex_spin_t ptm_interlock; /* unused - backwards compat */
> #ifdef __CPU_SIMPLE_LOCK_PAD
> uint8_t ptm_pad2[3];
> #endif
> - volatile pthread_t ptm_owner;
> - pthread_t * volatile ptm_waiters;
> + __pthread_mutex_volatile pthread_t ptm_owner;
> + pthread_t * __pthread_mutex_volatile ptm_waiters;
> unsigned int ptm_recursed;
> void *ptm_spare2; /* unused - backwards compat */
> };
>
>
From: "Brian G." <drakain@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: lib/49989
Date: Sat, 20 Jun 2015 18:47:53 -0400
--001a113ce222c326e60518fad434
Content-Type: text/plain; charset=UTF-8
This patch fixes the problem for me when I also replace pthread_spin_t with
__pthread_mutex_spin_t inside __pthread_cond_st and rwlock_t.
--001a113ce222c326e60518fad434
Content-Type: text/html; charset=UTF-8
<p dir="ltr">This patch fixes the problem for me when I also replace pthread_spin_t with __pthread_mutex_spin_t inside __pthread_cond_st and rwlock_t.<br></p>
--001a113ce222c326e60518fad434--
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread
volatiles
Date: Tue, 23 Jun 2015 12:33:51 +0200
On Sat, Jun 20, 2015 at 03:05:00PM +0000, pooka@iki.fi wrote:
> === snip ===
> libc++/dist/libcxx/include/__mutex_base:32:69: error: temporary of non-literal type '__pthread_mutex_st' in a constant expression
> constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
> [...]
> include/pthread_types.h:101:8: note: '__pthread_mutex_st' is not literal because:
> struct __pthread_mutex_st {
> ^
> include/pthread_types.h:103:17: note: non-static data member '__pthread_mutex_st::ptm_errorcheck' has volatile type
> pthread_spin_t ptm_errorcheck;
This is likely an interaction of GCC not believing this to be a system
hader and a bug in the C++11 specs when it comes to volatile in nested
elements.
Joerg
From: Antti Kantee <pooka@iki.fi>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread
volatiles
Date: Tue, 23 Jun 2015 11:56:15 +0000
On 23/06/15 10:35, Joerg Sonnenberger wrote:
> The following reply was made to PR lib/49989; it has been noted by GNATS.
>
> From: Joerg Sonnenberger <joerg@britannica.bec.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread
> volatiles
> Date: Tue, 23 Jun 2015 12:33:51 +0200
>
> On Sat, Jun 20, 2015 at 03:05:00PM +0000, pooka@iki.fi wrote:
> > === snip ===
> > libc++/dist/libcxx/include/__mutex_base:32:69: error: temporary of non-literal type '__pthread_mutex_st' in a constant expression
> > constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
> > [...]
> > include/pthread_types.h:101:8: note: '__pthread_mutex_st' is not literal because:
> > struct __pthread_mutex_st {
> > ^
> > include/pthread_types.h:103:17: note: non-static data member '__pthread_mutex_st::ptm_errorcheck' has volatile type
> > pthread_spin_t ptm_errorcheck;
>
> This is likely an interaction of GCC not believing this to be a system
> hader and a bug in the C++11 specs when it comes to volatile in nested
> elements.
Ok, so we'll use Christos' patch with the small additions as per Brian's
test.
From: Martin Husemann <martin@duskware.de>
To: Antti Kantee <pooka@iki.fi>
Cc: gnats-bugs@NetBSD.org
Subject: Re: lib/49989: libc++ fails to build with g++ 5.1 due to libpthread volatiles
Date: Tue, 23 Jun 2015 15:19:40 +0200
On Tue, Jun 23, 2015 at 11:56:15AM +0000, Antti Kantee wrote:
> Ok, so we'll use Christos' patch with the small additions as per Brian's
> test.
Isn't this actually a gcc bug?
Martin
State-Changed-From-To: open->closed
State-Changed-By: pooka@NetBSD.org
State-Changed-When: Fri, 26 Jun 2015 01:33:35 +0000
State-Changed-Why:
fixed
From: "Antti Kantee" <pooka@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49989 CVS commit: src/lib/libpthread
Date: Fri, 26 Jun 2015 01:33:09 +0000
Module Name: src
Committed By: pooka
Date: Fri Jun 26 01:33:09 UTC 2015
Modified Files:
src/lib/libpthread: pthread_types.h
Log Message:
C++ (namely libc++) expects to be using PTHREAD_FOO_INITIALIZER as a
member initializer. This does not work for volatile types. Since C++
does not touch the guts of those types, redefine them as non-volatile.
Fixes libc++ compilation with g++ 5.1, as reported in PR lib/49989.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libpthread/pthread_types.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Antti Kantee" <pooka@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49989 CVS commit: src/doc
Date: Fri, 26 Jun 2015 10:25:41 +0000
Module Name: src
Committed By: pooka
Date: Fri Jun 26 10:25:41 UTC 2015
Modified Files:
src/doc: HACKS
Log Message:
document g++ 5.1 + libpthread volatile workaround (PR lib/49989)
To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/doc/HACKS
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: closed->open
State-Changed-By: pooka@NetBSD.org
State-Changed-When: Fri, 26 Jun 2015 13:47:03 +0000
State-Changed-Why:
well that didn't work. ports are too divergent for us to be able to
make a simple deduction on what __cpu_simplelock_t really looks like.
From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: lib-bug-people@netbsd.org, netbsd-bugs@netbsd.org,
gnats-admin@netbsd.org, pooka@NetBSD.org, pooka@iki.fi
Subject: re: lib/49989 (libc++ fails to build with g++ 5.1 due to libpthread volatiles)
Date: Sun, 28 Jun 2015 22:11:26 +1000
> well that didn't work. ports are too divergent for us to be able to
> make a simple deduction on what __cpu_simplelock_t really looks like.
... the whole point of opaque types is to be opaque? :-)
State-Changed-From-To: open->closed
State-Changed-By: pooka@NetBSD.org
State-Changed-When: Thu, 27 Aug 2015 12:35:04 +0000
State-Changed-Why:
fixed (again, hope it stays fixed this time)
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.