Date: Sat, 29 Aug 2009 06:18:24 +0400 From: Dmitry Marakasov <amdmi3@amdmi3.ru> To: freebsd-ports@FreeBSD.org, nork@FreeBSD.org Subject: libtool & pthread & ilmbase Message-ID: <20090829021824.GE26981@hades.panopticon>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090829021824.GE26981>