diff mbox

[1/1] package/mpd: add patch to fix musl gcc5 build issue

Message ID 1438771429-15145-1-git-send-email-joerg.krause@embedded.rocks
State Accepted
Headers show

Commit Message

Jörg Krause Aug. 5, 2015, 10:43 a.m. UTC
Add a patch from the Alpine Linux project [1] to fix a musl build issue with
gcc 5:

```
error: temporary of non-literal type ‘pthread_mutex_t’ in a constant expression
  constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {}
```

Problem has been reported by the Alpine team upstream and was closed by the MPD
maintainer with WONTFIX:
http://bugs.musicpd.org/view.php?id=4387
http://bugs.musicpd.org/view.php?id=4110

However...

POSIX does not permit using PTHREAD_COND_INITIALIZER except for static
initialization, and certainly does not permit using it as a value.

Also POSIX does not specify the type of the object (it's opaque) so if
there are any types for which their code would be invalid C++, then their
code is invalid.

Also, volatile in the type is necessary. without that, LTO can break the code.

[1]
http://git.alpinelinux.org/cgit/aports/log/main/mpd/musl-gcc5-fixes.patch

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
 package/mpd/0002-musl-gcc5-fixes.patch | 56 ++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 package/mpd/0002-musl-gcc5-fixes.patch

Comments

Thomas Petazzoni Aug. 6, 2015, 6:47 a.m. UTC | #1
Dear Jörg Krause,

On Wed,  5 Aug 2015 12:43:49 +0200, Jörg Krause wrote:
> Add a patch from the Alpine Linux project [1] to fix a musl build issue with
> gcc 5:
> 
> ```
> error: temporary of non-literal type ‘pthread_mutex_t’ in a constant expression
>   constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {}
> ```
> 
> Problem has been reported by the Alpine team upstream and was closed by the MPD
> maintainer with WONTFIX:
> http://bugs.musicpd.org/view.php?id=4387
> http://bugs.musicpd.org/view.php?id=4110
> 
> However...
> 
> POSIX does not permit using PTHREAD_COND_INITIALIZER except for static
> initialization, and certainly does not permit using it as a value.
> 
> Also POSIX does not specify the type of the object (it's opaque) so if
> there are any types for which their code would be invalid C++, then their
> code is invalid.
> 
> Also, volatile in the type is necessary. without that, LTO can break the code.
> 
> [1]
> http://git.alpinelinux.org/cgit/aports/log/main/mpd/musl-gcc5-fixes.patch
> 
> Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
> ---
>  package/mpd/0002-musl-gcc5-fixes.patch | 56 ++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
>  create mode 100644 package/mpd/0002-musl-gcc5-fixes.patch

Applied, thanks. To be honest, I hesitated quite a bit before applying
this patch. A Buildroot rule is that we don't go against upstream. And
here upstream clearly say that they don't want to do the necessary
effort to support musl, so what we should have done instead is to also
make mpd not available with the musl C library.

But the patch is quite simple, so I made an exception. However, if more
patches are needed in mpd to fix musl build problems, I will reject
them and mark the package as not available in musl. Unhappy users can
go complain to the mpd developers that their decision of not supporting
musl by doing a configure-time check is stupid.

Thanks!

Thomas
diff mbox

Patch

diff --git a/package/mpd/0002-musl-gcc5-fixes.patch b/package/mpd/0002-musl-gcc5-fixes.patch
new file mode 100644
index 0000000..a4c65cc
--- /dev/null
+++ b/package/mpd/0002-musl-gcc5-fixes.patch
@@ -0,0 +1,56 @@ 
+musl gcc5 fixes
+
+Fetch from:
+http://git.alpinelinux.org/cgit/aports/plain/main/mpd/musl-gcc5-fixes.patch
+
+Problem has been reported upstream and closed with WONTFIX:
+http://bugs.musicpd.org/view.php?id=4387
+http://bugs.musicpd.org/view.php?id=4110
+
+however...
+
+POSIX does not permit using PTHREAD_COND_INITIALIZER except for static
+initialization, and certainly does not permit using it as a value
+
+also POSIX does not specify the type of the object (it's opaque) so if
+there are any types for which their code would be invalid C++, then their
+code is invalid
+
+also, volatile in the type is necessary. without that, LTO can break the code.
+
+Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
+
+--- ./src/notify.hxx.orig
++++ ./src/notify.hxx
+@@ -28,7 +28,7 @@
+ 	Cond cond;
+ 	bool pending;
+ 
+-#if !defined(WIN32) && !defined(__NetBSD__) && !defined(__BIONIC__)
++#if defined(__GLIBC__)
+ 	constexpr
+ #endif
+ 	notify():pending(false) {}
+--- ./src/thread/PosixCond.hxx.orig
++++ ./src/thread/PosixCond.hxx
+@@ -41,7 +41,7 @@
+ 	pthread_cond_t cond;
+ 
+ public:
+-#if defined(__NetBSD__) || defined(__BIONIC__)
++#if !defined(__GLIBC__)
+ 	/* NetBSD's PTHREAD_COND_INITIALIZER is not compatible with
+ 	   "constexpr" */
+ 	PosixCond() {
+--- ./src/thread/PosixMutex.hxx.orig
++++ ./src/thread/PosixMutex.hxx
+@@ -41,7 +41,7 @@
+ 	pthread_mutex_t mutex;
+ 
+ public:
+-#if defined(__NetBSD__) || defined(__BIONIC__)
++#if !defined(__GLIBC__)
+ 	/* NetBSD's PTHREAD_MUTEX_INITIALIZER is not compatible with
+ 	   "constexpr" */
+ 	PosixMutex() {
+