From c48974c9527159dc2f643d83d24d44c0defe367d Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 1 Jun 2017 08:31:55 -0500 Subject: qt4: Add patch for socklen_t on musl, from alpine --- pkgs/development/libraries/qt-4.x/4.8/default.nix | 8 +++- .../qt-4.x/4.8/patch-qthread-stacksize.diff | 54 ++++++++++++++++++++++ .../4.8/qsettings-recursive-global-mutex.patch | 17 +++++++ .../qt-4.x/4.8/qt-musl-iconv-no-bom.patch | 11 +++++ .../development/libraries/qt-4.x/4.8/qt-musl.patch | 14 ++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff create mode 100644 pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch create mode 100644 pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch create mode 100644 pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix index 488306fc1ce25..a9bd25ed28bc4 100644 --- a/pkgs/development/libraries/qt-4.x/4.8/default.nix +++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix @@ -106,7 +106,13 @@ stdenv.mkDerivation rec { ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch { url = "https://src.fedoraproject.org/rpms/qt/raw/ecf530486e0fb7fe31bad26805cde61115562b2b/f/qt-aarch64.patch"; sha256 = "1fbjh78nmafqmj7yk67qwjbhl3f6ylkp6x33b1dqxfw9gld8b3gl"; - }); + }) + ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ./qt-musl.patch + ./qt-musl-iconv-no-bom.patch + ./patch-qthread-stacksize.diff + ./qsettings-recursive-global-mutex.patch + ]; preConfigure = '' export LD_LIBRARY_PATH="`pwd`/lib:$LD_LIBRARY_PATH" diff --git a/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff b/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff new file mode 100644 index 0000000000000..53a4c70ac3ae6 --- /dev/null +++ b/pkgs/development/libraries/qt-4.x/4.8/patch-qthread-stacksize.diff @@ -0,0 +1,54 @@ +--- a/src/corelib/thread/qthread_unix.cpp.orig 2015-11-23 19:05:40.000000000 +0100 ++++ b/src/corelib/thread/qthread_unix.cpp 2015-11-24 11:22:31.000000000 +0100 +@@ -79,6 +79,7 @@ + #endif + ++#include // getrlimit/setrlimit + #if defined(Q_OS_MAC) + # ifdef qDebug + # define old_qDebug qDebug + # undef qDebug +@@ -649,6 +650,43 @@ + #endif // QT_HAS_THREAD_PRIORITY_SCHEDULING + + ++ if (d->stackSize == 0) { ++ // Fix the default (too small) stack size for threads on OS X, ++ // which also affects the thread pool. ++ // See also: ++ // https://bugreports.qt.io/browse/QTBUG-2568 ++ // This fix can also be found in Chromium: ++ // https://chromium.googlesource.com/chromium/src.git/+/master/base/threading/platform_thread_mac.mm#186 ++ ++ // The Mac OS X default for a pthread stack size is 512kB. ++ // Libc-594.1.4/pthreads/pthread.c's pthread_attr_init uses ++ // DEFAULT_STACK_SIZE for this purpose. ++ // ++ // 512kB isn't quite generous enough for some deeply recursive threads that ++ // otherwise request the default stack size by specifying 0. Here, adopt ++ // glibc's behavior as on Linux, which is to use the current stack size ++ // limit (ulimit -s) as the default stack size. See ++ // glibc-2.11.1/nptl/nptl-init.c's __pthread_initialize_minimal_internal. To ++ // avoid setting the limit below the Mac OS X default or the minimum usable ++ // stack size, these values are also considered. If any of these values ++ // can't be determined, or if stack size is unlimited (ulimit -s unlimited), ++ // stack_size is left at 0 to get the system default. ++ // ++ // Mac OS X normally only applies ulimit -s to the main thread stack. On ++ // contemporary OS X and Linux systems alike, this value is generally 8MB ++ // or in that neighborhood. ++ size_t default_stack_size = 0; ++ struct rlimit stack_rlimit; ++ if (pthread_attr_getstacksize(&attr, &default_stack_size) == 0 && ++ getrlimit(RLIMIT_STACK, &stack_rlimit) == 0 && ++ stack_rlimit.rlim_cur != RLIM_INFINITY) { ++ default_stack_size = ++ std::max(std::max(default_stack_size, ++ static_cast(PTHREAD_STACK_MIN)), ++ static_cast(stack_rlimit.rlim_cur)); ++ } ++ d->stackSize = default_stack_size; ++ } + if (d->stackSize > 0) { + #if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0 > 0) + int code = pthread_attr_setstacksize(&attr, d->stackSize); diff --git a/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch b/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch new file mode 100644 index 0000000000000..229123c54f763 --- /dev/null +++ b/pkgs/development/libraries/qt-4.x/4.8/qsettings-recursive-global-mutex.patch @@ -0,0 +1,17 @@ +Calling qsettings before constructing qapplications causes a dead-lock. + +http://sourceforge.net/tracker/?func=detail&aid=3168620&group_id=4932&atid=104932 +http://developer.qt.nokia.com/forums/viewthread/10365 + + +--- ./src/corelib/io/qsettings.cpp.orig ++++ ./src/corelib/io/qsettings.cpp +@@ -122,7 +122,7 @@ + Q_GLOBAL_STATIC(ConfFileCache, unusedCacheFunc) + Q_GLOBAL_STATIC(PathHash, pathHashFunc) + Q_GLOBAL_STATIC(CustomFormatVector, customFormatVectorFunc) +-Q_GLOBAL_STATIC(QMutex, globalMutex) ++Q_GLOBAL_STATIC_WITH_ARGS(QMutex, globalMutex, (QMutex::Recursive)) + static QSettings::Format globalDefaultFormat = QSettings::NativeFormat; + + #ifndef Q_OS_WIN diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch b/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch new file mode 100644 index 0000000000000..35380ad6714d6 --- /dev/null +++ b/pkgs/development/libraries/qt-4.x/4.8/qt-musl-iconv-no-bom.patch @@ -0,0 +1,11 @@ +--- qt-everywhere-opensource-src-4.8.5/src/corelib/codecs/qiconvcodec.cpp.orig ++++ qt-everywhere-opensource-src-4.8.5/src/corelib/codecs/qiconvcodec.cpp +@@ -62,7 +62,7 @@ + #elif defined(Q_OS_AIX) + # define NO_BOM + # define UTF16 "UCS-2" +-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) ++#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) || (defined(Q_OS_LINUX) && !defined(__GLIBC__)) + # define NO_BOM + # if Q_BYTE_ORDER == Q_BIG_ENDIAN + # define UTF16 "UTF-16BE" diff --git a/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch b/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch new file mode 100644 index 0000000000000..90b9ccda08c92 --- /dev/null +++ b/pkgs/development/libraries/qt-4.x/4.8/qt-musl.patch @@ -0,0 +1,14 @@ +--- qt-everywhere-opensource-src-4.8.5/mkspecs/linux-g++/qplatformdefs.h.orig ++++ qt-everywhere-opensource-src-4.8.5/mkspecs/linux-g++/qplatformdefs.h +@@ -86,11 +86,7 @@ + + #undef QT_SOCKLEN_T + +-#if defined(__GLIBC__) && (__GLIBC__ >= 2) + #define QT_SOCKLEN_T socklen_t +-#else +-#define QT_SOCKLEN_T int +-#endif + + #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) + #define QT_SNPRINTF ::snprintf -- cgit 1.4.1