From owner-freebsd-ports@FreeBSD.ORG Sat Aug 29 03:35:19 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 625F8106566B for ; Sat, 29 Aug 2009 03:35:19 +0000 (UTC) (envelope-from mezz7@cox.net) Received: from eastrmmtao107.cox.net (eastrmmtao107.cox.net [68.230.240.59]) by mx1.freebsd.org (Postfix) with ESMTP id 1EB888FC13 for ; Sat, 29 Aug 2009 03:35:18 +0000 (UTC) Received: from eastrmimpo03.cox.net ([68.1.16.126]) by eastrmmtao107.cox.net (InterMail vM.8.00.01.00 201-2244-105-20090324) with ESMTP id <20090829033518.GJNY19505.eastrmmtao107.cox.net@eastrmimpo03.cox.net>; Fri, 28 Aug 2009 23:35:18 -0400 Received: from localhost ([68.103.37.153]) by eastrmimpo03.cox.net with bizsmtp id a3bH1c0063JFCbG023bH4C; Fri, 28 Aug 2009 23:35:18 -0400 X-VR-Score: -160.00 X-Authority-Analysis: v=1.0 c=1 a=6I5d2MoRAAAA:8 a=kviXuzpPAAAA:8 a=cIMCsued5b5djsdP1-gA:9 a=42ENPCy_-RZX-MzRCwcA:7 a=ZHkFrg2S3ZnUwasnE_WJVuO7lFEA:4 a=4vB-4DCPJfMA:10 a=SV7veod9ZcQA:10 a=J72vE-i8LDgLcZWr:21 a=PH5LZkCbOxOEYEKh:21 X-CM-Score: 0.00 Date: Fri, 28 Aug 2009 22:36:58 -0500 To: "Dmitry Marakasov" From: "Jeremy Messenger" Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <20090829021824.GE26981@hades.panopticon> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <20090829021824.GE26981@hades.panopticon> User-Agent: Opera Mail/9.64 (Linux) Cc: nork@freebsd.org, freebsd-ports@freebsd.org Subject: Re: 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 03:35:19 -0000 On Fri, 28 Aug 2009 21:18:24 -0500, Dmitry Marakasov wrote: > 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: Search for 'nostdlib pthread' in google and you will see many results. Linux even has the same problem. > 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 Best to copy GECKO_PTHREAD's way of get library. Grep for GECKO_PTHREAD_LIBS in ports/Mk/bsd.gecko.mk. # cd /usr/ports/www/firefox3 # make -V GECKO_PTHREAD_LIBS -lpthread Cheers, Mezz > 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 > -- mezz7@cox.net - mezz@FreeBSD.org FreeBSD GNOME Team http://www.FreeBSD.org/gnome/ - gnome@FreeBSD.org