Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Sep 2012 07:55:54 +0400 (MSK)
From:      Dmitry Marakasov <amdmi3@amdmi3.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/172108: [PATCH] graphics/ilmbase: libIlmThread is not linked with pthread library
Message-ID:  <20120927035554.2E909201@hades.panopticon>
Resent-Message-ID: <201209270400.q8R40H7h096357@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         172108
>Category:       ports
>Synopsis:       [PATCH] graphics/ilmbase: libIlmThread is not linked with pthread library
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 27 04:00:17 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Marakasov
>Release:        FreeBSD 9.0-RELEASE-p3 amd64
>Organization:
>Environment:
System: FreeBSD hades.panopticon 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Wed Jun 13 17:39:20 MSK 2012
>Description:
After recent update of ilmbase and OpenEXR, at least one dependent port (graphics/nvidia-texture-tools) was broken:

http://people.freebsd.org/~amdmi3/nvidia-texture-tools-2.0.8.1_1.log

this happened because libIlmImf is no longer linked with thread library

ilmbase-1.0.1/OpenEXR-1.6.1:
% ldd /usr/local/lib/libIlmImf.so
/usr/local/lib/libIlmImf.so:
	libthr.so.3 => /lib/libthr.so.3 (0x8012c2000) <--- gone after update
	libz.so.6 => /lib/libz.so.6 (0x8014e3000)
	libImath.so.6 => /usr/local/lib/libImath.so.6 (0x8016f8000)
	libHalf.so.6 => /usr/local/lib/libHalf.so.6 (0x8018fd000)
	libIlmThread.so.6 => /usr/local/lib/libIlmThread.so.6 (0x801b3f000)
	libIex.so.6 => /usr/local/lib/libIex.so.6 (0x801d46000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x801f5d000)
	libm.so.5 => /lib/libm.so.5 (0x80225a000)
	libc.so.7 => /lib/libc.so.7 (0x800848000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x80247b000)

ilmbase-1.0.2/OpenEXR-1.7.0:
/usr/local/lib/libIlmImf.so:
	libz.so.6 => /lib/libz.so.6 (0x8012d9000)
	libImath.so.6 => /usr/local/lib/libImath.so.6 (0x8014ee000)
	libHalf.so.6 => /usr/local/lib/libHalf.so.6 (0x8016f3000)
	libIlmThread.so.6 => /usr/local/lib/libIlmThread.so.6 (0x801935000)
	libIex.so.6 => /usr/local/lib/libIex.so.6 (0x801b3c000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x801d53000)
	libm.so.5 => /lib/libm.so.5 (0x802050000)
	libc.so.7 => /lib/libc.so.7 (0x800848000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x802271000)

But the problem is actually in libIlmThread, which is not linked
with libthr in both old and new versions:

/usr/local/lib/libIlmThread.so:
	libIex.so.6 => /usr/local/lib/libIex.so.6 (0x801207000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x80141e000)
	libm.so.5 => /lib/libm.so.5 (0x801727000)
	libc.so.7 => /lib/libc.so.7 (0x800848000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x801948000)

With that, any linking with it or other library using it without
explicit -pthread will fail:

% echo 'int main(){}' > test.c && gcc test.c -L/usr/local/lib -lIlmThread
/usr/local/lib/libIlmThread.so: undefined reference to `pthread_create'

And why it's not linked with libthr is somehow related to libtool
black magic, as though link command which produces this library
does have -pthread argument:

libtool: link: c++  -fPIC -DPIC -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.2/Iex/.libs -Wl,-rpath -Wl,/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/prefix/lib ../Iex/.libs/libIex.so -L/usr/lib -lstdc++ -lm -lc -lgcc_s /usr/lib/crtendS.o /usr/lib/crtn.o  -O2 -march=nocona -pthread -pthread   -pthread -Wl,-soname -Wl,libIlmThread.so.6 -o .libs/libIlmThread.so.6

the resulting library is not linked with libthr. If the command
is (manually) changed to `normal' way of creating a shared library

c++  -fPIC -DPIC -shared .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.2/Iex/.libs -Wl,-rpath -Wl,/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/prefix/lib ../Iex/.libs/libIex.so -L/usr/lib -lstdc++ -lm -O2 -march=nocona -pthread -pthread   -pthread -Wl,-soname -Wl,libIlmThread.so.6 -o .libs/libIlmThread.so.6_

it produces correct library:

% ldd .libs/libIlmThread.so.6 .libs/libIlmThread.so.6_
.libs/libIlmThread.so.6:
	libIex.so.6 => /usr/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/work/ilmbase-1.0.2/Iex/.libs/libIex.so.6 (0x801207000)
	libstdc++.so.6 => /usr/local/lib/gcc46/libstdc++.so.6 (0x80141e000)
	libm.so.5 => /lib/libm.so.5 (0x80171b000)
	libc.so.7 => /lib/libc.so.7 (0x800848000)
	libgcc_s.so.1 => /usr/local/lib/gcc46/libgcc_s.so.1 (0x80193c000)
.libs/libIlmThread.so.6_:
	libIex.so.6 => /usr/home/amdmi3/projects/freebsd/ports/graphics/ilmbase/work/ilmbase-1.0.2/Iex/.libs/libIex.so.6 (0x801207000)
	libstdc++.so.6 => /usr/local/lib/gcc46/libstdc++.so.6 (0x80141e000)
	libm.so.5 => /lib/libm.so.5 (0x80171b000)
	libgcc_s.so.1 => /usr/local/lib/gcc46/libgcc_s.so.1 (0x80193c000)
	libthr.so.3 => /lib/libthr.so.3 (0x801b51000)
	libc.so.7 => /lib/libc.so.7 (0x800848000)

I'm not familiar with libtool workings, but my guess is that it should be taught to not use `-nostdlib /usr/lib/crti.o /usr/lib/crtbeginS.o ... -lc -lgcc_s /usr/lib/crtendS.o /usr/lib/crtn.o' magic, so the library is linked correctly.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: ports)
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120927035554.2E909201>