package/gcc: Fix compiling jsoncpp with musl
PATCH 1/2 package/gcc: Fix compiling jsoncpp with musl
[ 16%] Building CXX object src/lib_json/CMakeFiles/jsoncpp_lib.dir/json_value.cpp.o
In file included from /home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/xmmintrin.h:34:0,
from /home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/x86intrin.h:31,
from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/x86_64-buildroot-linux-musl/bits/opt_random.h:33,
from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/random:50,
from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/bits/stl_algo.h:66,
from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/algorithm:62,
from /home/fli4l/br3/output/build/jsoncpp-1.6.1/src/lib_json/json_value.cpp:20:
/home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/mm_malloc.h:34:64: error: declaration of 'int posix_memalign(void**, size_t, size_t) throw ()' has a different exception specifier
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
^
In file included from /home/fli4l/br3/output/build/jsoncpp-1.6.1/include/json/assertions.h:9:0,
from /home/fli4l/br3/output/build/jsoncpp-1.6.1/src/lib_json/json_value.cpp:7:
/home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/sysroot/usr/include/stdlib.h:98:5: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
int posix_memalign (void **, size_t, size_t);
^make[2]: *** [src/lib_json/CMakeFiles/jsoncpp_lib.dir/json_value.cpp.o] Error 1
--- .../gcc/4.7.4/901-musl-posix_memalign-c++.patch | 32 ++++++++++++++++++++ .../gcc/4.8.4/901-musl-posix_memalign-c++.patch | 32 ++++++++++++++++++++ .../gcc/4.9.2/901-musl-posix_memalign-c++.patch | 32 ++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 package/gcc/4.7.4/901-musl-posix_memalign-c++.patch create mode 100644 package/gcc/4.8.4/901-musl-posix_memalign-c++.patch create mode 100644 package/gcc/4.9.2/901-musl-posix_memalign-c++.patch
package/gcc/4.7.4/901-musl-posix_memalign-c++.patch new file +32 -0
@@ -0,0 +1,32 @@ +Downloaded from +http://git.alpinelinux.org/cgit/aports/tree/main/gcc/musl-posix_memalign-c++.patch + +Signed-off-by: Bernd Kuhls <[email protected]> +--- +Fix conflicting prototype of posix_memalign for c++ +http://www.openwall.com/lists/musl/2013/11/10/1 + +--- ./gcc/config/i386/pmm_malloc.h.orig ++++ ./gcc/config/i386/pmm_malloc.h +@@ -28,11 +28,7 @@ + + /* We can't depend on <stdlib.h> since the prototype of posix_memalign + may not be visible. */ +-#ifndef __cplusplus +-extern int posix_memalign (void **, size_t, size_t); +-#else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); +-#endif ++extern int __gcc_posix_memalign (void **, size_t, size_t) __asm__("posix_memalign"); + + static __inline void * + _mm_malloc (size_t size, size_t alignment) +@@ -42,7 +38,7 @@ + return malloc (size); + if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4)) + alignment = sizeof (void *); +- if (posix_memalign (&ptr, alignment, size) == 0) ++ if (__gcc_posix_memalign (&ptr, alignment, size) == 0) + return ptr; + else + return NULL;
package/gcc/4.8.4/901-musl-posix_memalign-c++.patch new file +32 -0
@@ -0,0 +1,32 @@ +Downloaded from +http://git.alpinelinux.org/cgit/aports/tree/main/gcc/musl-posix_memalign-c++.patch + +Signed-off-by: Bernd Kuhls <[email protected]> +--- +Fix conflicting prototype of posix_memalign for c++ +http://www.openwall.com/lists/musl/2013/11/10/1 + +--- ./gcc/config/i386/pmm_malloc.h.orig ++++ ./gcc/config/i386/pmm_malloc.h +@@ -28,11 +28,7 @@ + + /* We can't depend on <stdlib.h> since the prototype of posix_memalign + may not be visible. */ +-#ifndef __cplusplus +-extern int posix_memalign (void **, size_t, size_t); +-#else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); +-#endif ++extern int __gcc_posix_memalign (void **, size_t, size_t) __asm__("posix_memalign"); + + static __inline void * + _mm_malloc (size_t size, size_t alignment) +@@ -42,7 +38,7 @@ + return malloc (size); + if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4)) + alignment = sizeof (void *); +- if (posix_memalign (&ptr, alignment, size) == 0) ++ if (__gcc_posix_memalign (&ptr, alignment, size) == 0) + return ptr; + else + return NULL;
package/gcc/4.9.2/901-musl-posix_memalign-c++.patch new file +32 -0
@@ -0,0 +1,32 @@ +Downloaded from +http://git.alpinelinux.org/cgit/aports/tree/main/gcc/musl-posix_memalign-c++.patch + +Signed-off-by: Bernd Kuhls <[email protected]> +--- +Fix conflicting prototype of posix_memalign for c++ +http://www.openwall.com/lists/musl/2013/11/10/1 + +--- ./gcc/config/i386/pmm_malloc.h.orig ++++ ./gcc/config/i386/pmm_malloc.h +@@ -28,11 +28,7 @@ + + /* We can't depend on <stdlib.h> since the prototype of posix_memalign + may not be visible. */ +-#ifndef __cplusplus +-extern int posix_memalign (void **, size_t, size_t); +-#else +-extern "C" int posix_memalign (void **, size_t, size_t) throw (); +-#endif ++extern int __gcc_posix_memalign (void **, size_t, size_t) __asm__("posix_memalign"); + + static __inline void * + _mm_malloc (size_t size, size_t alignment) +@@ -42,7 +38,7 @@ + return malloc (size); + if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4)) + alignment = sizeof (void *); +- if (posix_memalign (&ptr, alignment, size) == 0) ++ if (__gcc_posix_memalign (&ptr, alignment, size) == 0) + return ptr; + else + return NULL;
Signature · 1 line
1.7.10.4
PATCH 2/2 package/jsoncpp: bump version to 1.6.1
--- package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch | 2 +- package/jsoncpp/jsoncpp.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch +1 -1
@@ -29,7 +29,7 @@ index 83102fd2bb86..f7ad1e21bbc0 100644 #if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below #define snprintf _snprintf --#else +-#elif __cplusplus >= 201103L -#define snprintf std::snprintf #endif
package/jsoncpp/jsoncpp.mk +1 -1
@@ -4,7 +4,7 @@ # ################################################################################ -JSONCPP_VERSION = 1.6.0 +JSONCPP_VERSION = 1.6.1 JSONCPP_SITE = $(call github,open-source-parsers,jsoncpp,$(JSONCPP_VERSION)) JSONCPP_LICENSE = Public Domain or MIT JSONCPP_LICENSE_FILES = LICENSE
Signature · 1 line
1.7.10.4
PATCH 1/2 package/gcc: Fix compiling jsoncpp with musl
In reply to Bernd KuhlsDear Bernd Kuhls,
Quoted 16 lines · Bernd Kuhls
[ 16%] Building CXX object
src/lib_json/CMakeFiles/jsoncpp_lib.dir/json_value.cpp.o
In file included from/home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/xmmintrin.h:34:0,from /home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/x86intrin.h:31, from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/x86_64-buildroot-linux-musl/bits/opt_random.h:33, from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/random:50, from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/bits/stl_algo.h:66, from /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/include/c++/4.9.2/algorithm:62, from /home/fli4l/br3/output/build/jsoncpp-1.6.1/src/lib_json/json_value.cpp:20: /home/fli4l/br3/output/host/usr/lib/gcc/x86_64-buildroot-linux-musl/4.9.2/include/mm_malloc.h:34:64: error: declaration of 'int posix_memalign(void**, size_t, size_t) throw ()' has a different exception specifier extern "C" int posix_memalign (void **, size_t, size_t) throw (); ^ In file included from /home/fli4l/br3/output/build/jsoncpp-1.6.1/include/json/assertions.h:9:0, from /home/fli4l/br3/output/build/jsoncpp-1.6.1/src/lib_json/json_value.cpp:7: /home/fli4l/br3/output/host/usr/x86_64-buildroot-linux-musl/sysroot/usr/include/stdlib.h:98:5: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)' int posix_memalign (void **, size_t, size_t); ^
Quoted 3 lines
make[2]: *** [
src/lib_json/CMakeFiles/jsoncpp_lib.dir/json_value.cpp.o] Error 1Signed-off-by Bernd Kuhls <[email protected]>
I think instead just make jsoncpp depends on !musl. Because while this patch fixes the problem for the internal toolchain backend, it will continue to fail with external musl toolchains.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com