[Qt-interest] Qt 4.7.4 build on Solaris 10 (amd64)

Xavier Roche roche+qt at exalead.com
Fri Sep 16 10:02:15 CEST 2011


On 09/15/2011 04:00 PM, Xavier Roche wrote:
> Just small hints on how to build Qt 4.7.4 on a Solaris 10 (AMD64) with
> GCC (GCC 3 or 4).

Another issue on Solaris 10:

The interfaceNames() function in 
src/network/kernel/qnetworkinterface_unix.cpp (static QSet<QByteArray> 
interfaceNames(int socket)) is using if_nameindex() 
(http://download.oracle.com/docs/cd/E19253-01/816-5170/6mbb5esce/index.html)

The functio if_freenameindex() aborts when called, if libumem is used.

An additional patch is necessary as a workaround if your program is 
linking against, or preloading, the libumem.so library:

--- src/network/kernel/qnetworkinterface_unix.cpp.orig  Fri Sep 16 
08:09:51 2011
+++ src/network/kernel/qnetworkinterface_unix.cpp       Fri Sep 16 
08:09:59 2011
@@ -70,6 +70,11 @@

   #include <qplatformdefs.h>

+// if_freenameindex() patch
+#include <pthread.h>
+#include <errno.h>
+
+
   QT_BEGIN_NAMESPACE

   static QHostAddress addressFromSockaddr(sockaddr *sa)
@@ -151,12 +156,34 @@
   #else
       Q_UNUSED(socket);

+    /* As if_freenameindex() crashes when libumem is enabled on Solaris 10
+      (tested patch level: 144489-17), we only query the list once and 
never
+      free it. /RX'2011 */
+    static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+    static struct if_nameindex *interfaceListStatic = NULL;
+    int code;
+    code = pthread_mutex_lock(&lock);
+    if (code != 0) {
+      errno = code;
+      perror("pthread_mutex_lock failed");
+    }
+    if (interfaceListStatic == NULL) {
+      interfaceListStatic = ::if_nameindex();
+    }
+    code = pthread_mutex_unlock(&lock);
+    if (code != 0) {
+      errno = code;
+      perror("pthread_mutex_unlock failed");
+    }
+
       // use if_nameindex
-    struct if_nameindex *interfaceList = ::if_nameindex();
+    struct if_nameindex *interfaceList = interfaceListStatic;
+    ////struct if_nameindex *interfaceList = ::if_nameindex();
       for (struct if_nameindex *ptr = interfaceList; ptr && 
ptr->if_name; ++ptr)
           result << ptr->if_name;

-    if_freenameindex(interfaceList);
+    ////if_freenameindex(interfaceList);
+
       return result;
   #endif
   }

See also the "if_nameindex()/if_freenameindex() allocator inconsistency 
on Solaris 10 (amd64) ?" thread in comp.unix.solaris:
http://groups.google.com/group/comp.unix.solaris/browse_thread/thread/a1cdb9b742a7bda6?pli=1

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: qt-everywhere-opensource-src-4.7.4.solaris.patch.final
Url: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110916/5537ccf1/attachment.pl 


More information about the Qt-interest-old mailing list