From owner-freebsd-ports@FreeBSD.ORG Sat Aug 29 02:18:27 2009 Return-Path: Delivered-To: freebsd-ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5FF1106566C for ; Sat, 29 Aug 2009 02:18:27 +0000 (UTC) (envelope-from amdmi3@amdmi3.ru) Received: from smtp.timeweb.ru (smtp.timeweb.ru [217.170.79.85]) by mx1.freebsd.org (Postfix) with ESMTP id 66DF38FC1D for ; Sat, 29 Aug 2009 02:18:27 +0000 (UTC) Received: from [213.148.20.85] (helo=hive.panopticon) by smtp.timeweb.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.69) (envelope-from ) id 1MhDWM-0000JV-PW; Sat, 29 Aug 2009 06:18:26 +0400 Received: from hades.panopticon (hades.panopticon [192.168.0.32]) by hive.panopticon (Postfix) with ESMTP id 12DACB84D; Sat, 29 Aug 2009 06:18:25 +0400 (MSD) Received: by hades.panopticon (Postfix, from userid 1000) id D7400108842; Sat, 29 Aug 2009 06:18:24 +0400 (MSD) Date: Sat, 29 Aug 2009 06:18:24 +0400 From: Dmitry Marakasov To: freebsd-ports@FreeBSD.org, nork@FreeBSD.org Message-ID: <20090829021824.GE26981@hades.panopticon> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: libtool & pthread & ilmbase X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 02:18:28 -0000 Hi! I've asked about this issue before, but though Daniel Eischen nicely explained me some stuff regarding threads, I was haven't had a clear idea how to fix this. Now I've ran into this again, so I'll raise this once more. The problem: graphics/ilmbase is built with thread support by default (see port). However, while libs are linked with -pthread as they should: libtool: link: c++ -shared -nostdlib /usr/lib/crti.o /usr/lib/crtbeginS.o .libs/IlmThreadPool.o .libs/IlmThread.o .libs/IlmThreadSemaphore.o .libs/IlmThreadMutex.o .libs/IlmThreadPosix.o .libs/IlmThreadSemaphorePosix.o .libs/IlmThreadSemaphorePosixCompat.o .libs/IlmThreadMutexPosix.o -Wl,-rpath -Wl,/usr/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/work/ilmbase-1.0.1/Iex/.libs -Wl,-rpath -Wl,/usr/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/prefix/lib ../Iex/.libs/libIex.so -pthread -L/usr/lib -lstdc++ -lm -lc -lgcc_s /usr/lib/crtendS.o /usr/lib/crtn.o -march=prescott -pthread -pthread -pthread -pthread -Wl,-soname -Wl,libIlmThread.so.6 -o .libs/libIlmThread.so.6 the resulting libraries have no dependency on real threading lib (-lthr): % ldd /usr/local/lib/libIlmThread.so /usr/local/lib/libIlmThread.so: libIex.so.6 => /usr/local/lib/libIex.so.6 (0x281b0000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x28300000) libm.so.5 => /lib/libm.so.5 (0x281c1000) libc.so.7 => /lib/libc.so.7 (0x2808f000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x281da000) thus, I won't be able to link with this library directly: % gcc 1.c -lIlmThread -L/usr/local/lib /usr/local/lib/libIlmThread.so: undefined reference to `pthread_create' unless I specify -pthread. While this may be expected for libIlm_Thread_, there are other (essentially thread-unaware) libs that depend on it. OpenEXR: % gcc 1.c -lIlmImf -L/usr/local/lib /usr/local/lib/libIlmThread.so.6: undefined reference to `pthread_create' nvidia-texture-tools (depends on OpenEXR): % gcc 1.c -lnvimage -L/usr/local/lib /usr/local/lib/libIlmThread.so.6: undefined reference to `pthread_create' DevIL (conditionally depends on nvidia-texture-tools): % gcc 1.c -lIL -L/usr/local/lib /usr/local/lib/libIlmThread.so.6: undefined reference to `pthread_create' Now, when I build CEGUI (which depends on devil), it won't really build DevIL plugin, as configure check for link with DevIL will fail. Finally, because of that, secretmaryochronicles segfault on startup. This took some time to unwind, and I want this to be fixed once and forever. The solutions: 1) Add -pthread to linker flags in ALL dependent ports. I think this is a no-go, as we'll then be forcing threads in too many ports, which are essentially thread-unaware. Also, we'll be forcing threads regardless of whether ilmbase is built threaded or not, also regardless of whether we actually depend in ilmbase or not. 2) Fix it in ilmbase. I believe, like this: .if ${OSVERSION} < 700041 PTHREAD_LIBS+= -lpthread .else PTHREAD_LIBS+= -lthr .endif this may not be so good, as only libIlmThread should be linked to threads actually. So another solution: 3) Fix it in OpenEXR. The same way as above, as just CONFIGURE_ARGS="${PTHREAD_LIBS}" doesn't seem to have any effect. I'm for #3. I've submitted a PR for this in April ([1]), but nork@ didn't respond, so I'd like to commit this after some tinderboxing if no one sees any additionak caveats. [1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/133291 -- Dmitry Marakasov . 55B5 0596 FF1E 8D84 5F56 9510 D35A 80DD F9D2 F77D amdmi3@amdmi3.ru ..: jabber: amdmi3@jabber.ru http://www.amdmi3.ru