From 09bcb3e48175400311df5c55337f7c6ad89be201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Thu, 27 Aug 2015 00:54:48 +0200 Subject: [PATCH] mongodb: unbreak musl --- srcpkgs/mongodb/patches/musl-backtrace.patch | 31 ++++++++++++++++ .../patches/musl-elf_native_class.patch | 21 +++++++++++ .../mongodb/patches/musl-libc_version_h.patch | 37 +++++++++++++++++++ srcpkgs/mongodb/template | 10 ++++- 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/mongodb/patches/musl-backtrace.patch create mode 100644 srcpkgs/mongodb/patches/musl-elf_native_class.patch create mode 100644 srcpkgs/mongodb/patches/musl-libc_version_h.patch diff --git a/srcpkgs/mongodb/patches/musl-backtrace.patch b/srcpkgs/mongodb/patches/musl-backtrace.patch new file mode 100644 index 00000000000..95f90ccb23d --- /dev/null +++ b/srcpkgs/mongodb/patches/musl-backtrace.patch @@ -0,0 +1,31 @@ +There is no walkcontext(3) for musl libc, so we effectively +disable backtracing symbols without removing the functions. +They just always return zero symbols. + +--- src/mongo/platform/backtrace.cpp 2015-08-24 02:39:52.000000000 +0200 ++++ src/mongo/platform/backtrace.cpp 2015-08-26 19:27:26.738866698 +0200 +@@ -81,7 +81,7 @@ + // to Linux's display, but slightly different. + // + int addrtosymstr(void* address, char* outputBuffer, int outputBufferSize) { +- Dl_info_t symbolInfo; ++ Dl_info symbolInfo; + if (dladdr(address, &symbolInfo) == 0) { // no info: "[address]" + return snprintf(outputBuffer, outputBufferSize, "[0x%p]", address); + } +@@ -113,10 +113,15 @@ ++#if defined(__sunos__) + if (getcontext(&context) != 0) { + return 0; + } + int wcReturn = walkcontext( + &context, + reinterpret_cast(WalkcontextCallback::callbackFunction), + static_cast(&walkcontextCallback)); ++#else ++ // We have no walkcontext(3) for musl libc ++ int wcReturn = -1; ++#endif + if (wcReturn == 0) { + return walkcontextCallback.getCount(); + } diff --git a/srcpkgs/mongodb/patches/musl-elf_native_class.patch b/srcpkgs/mongodb/patches/musl-elf_native_class.patch new file mode 100644 index 00000000000..893a437ed01 --- /dev/null +++ b/srcpkgs/mongodb/patches/musl-elf_native_class.patch @@ -0,0 +1,21 @@ +Add a definition for the macro __ELF_NATIVE_CLASS which depends +on the native arch's word size. + +--- src/mongo/util/stacktrace_posix.cpp 2015-08-24 02:39:52.000000000 +0200 ++++ src/mongo/util/stacktrace_posix.cpp 2015-08-26 18:59:52.290831910 +0200 +@@ -37,6 +37,15 @@ + #include + #include + ++#if !defined(__GLIBC__) ++#if defined __x86_64__ && !defined __ILP32__ ++# define __WORDSIZE 64 ++#else ++# define __WORDSIZE 32 ++#endif ++#define __ELF_NATIVE_CLASS __WORDSIZE ++#endif ++ + #include "mongo/base/init.h" + #include "mongo/db/jsobj.h" + #include "mongo/platform/backtrace.h" diff --git a/srcpkgs/mongodb/patches/musl-libc_version_h.patch b/srcpkgs/mongodb/patches/musl-libc_version_h.patch new file mode 100644 index 00000000000..43cd8dad295 --- /dev/null +++ b/srcpkgs/mongodb/patches/musl-libc_version_h.patch @@ -0,0 +1,37 @@ +--- src/mongo/util/processinfo_linux2.cpp 2015-08-24 02:39:52.000000000 +0200 ++++ src/mongo/util/processinfo_linux2.cpp 2015-08-26 18:47:57.444816879 +0200 +@@ -34,7 +34,9 @@ + #include + #include + #include ++#if defined(__GLIBC__) + #include ++#endif + #include + + #include "processinfo.h" +@@ -420,12 +422,14 @@ + } + + void ProcessInfo::getExtraInfo(BSONObjBuilder& info) { ++#if defined(__GLIBC__) + // [dm] i don't think mallinfo works. (64 bit.) ?? + struct mallinfo malloc_info = + mallinfo(); // structure has same name as function that returns it. (see malloc.h) + info.append("heap_usage_bytes", + malloc_info.uordblks /*main arena*/ + malloc_info.hblkhd /*mmap blocks*/); + // docs claim hblkhd is included in uordblks but it isn't ++#endif + + LinuxProc p(_pid); + info.appendNumber("page_faults", static_cast(p._maj_flt)); +@@ -460,7 +464,9 @@ + + BSONObjBuilder bExtra; + bExtra.append("versionString", LinuxSysHelper::readLineFromFile("/proc/version")); ++#if defined(__GLIBC__) + bExtra.append("libcVersion", gnu_get_libc_version()); ++#endif + if (!verSig.empty()) + // optional + bExtra.append("versionSignature", verSig); diff --git a/srcpkgs/mongodb/template b/srcpkgs/mongodb/template index 4a337436d92..80d60e1b4dc 100644 --- a/srcpkgs/mongodb/template +++ b/srcpkgs/mongodb/template @@ -1,7 +1,7 @@ # Template file for 'mongodb' pkgname=mongodb version=3.0.6 -revision=1 +revision=2 hostmakedepends="scons" makedepends="boost-devel pcre-devel snappy-devel libressl-devel libpcap-devel gperftools-devel" conf_files="/etc/mongodb/mongodb.conf" @@ -36,6 +36,14 @@ do_configure() { find . -name SConstruct -print0 | xargs -0 sed -i "s/-Werror/-Wno-error/g" } +post_configure() { + case "$XBPS_TARGET_MACHINE" in + *-musl) # Disable strtouq(3) + sed -i src/third_party/wiredtiger/build_linux/wiredtiger_config.h \ + -e "s;#define HAVE_STRTOUQ 1;#undef HAVE_STRTOUQ;" + esac +} + do_build() { scons core ${makejobs} \ --cc=$CC \