This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bug with PI mutex and static linking


On Thu, Feb 11, 2016 at 10:48 AM, Warlich, Christof
<christof.warlich@siemens.com> wrote:
> We are running Ubuntu 14.04 with self-built cross-toolchains for various architectures, amongst them x86_64.
>
> Assuming you haven't missed to do a _static_ build to reproduce the issue, the problem seems to most
> likely be with our toolchain build. So at least we now know where to start searching :-).

I suspect you are running into bug 5784 and your build or distribution
aren't helping you fix it:
https://sourceware.org/bugzilla/show_bug.cgi?id=5784

[carlos@athas ~]$ gcc -Wall -pedantic -static -pthread -o pi-mutex pi-mutex.c
[carlos@athas ~]$ ./pi-mutex
locked b

Works fine here.

In Fedora we (I am one of the Fedora glibc maintainers) use
--whole-archive to rebuild libpthread.a.

e.g.
pushd $RPM_BUILD_ROOT%{_prefix}/%{_lib}/
$GCC -r -nostdlib -o libpthread.o -Wl,--whole-archive ./libpthread.a
rm libpthread.a
ar rcs libpthread.a libpthread.o
rm libpthread.o
popd

We do this to avoid an possible object dependency issues which could
result from other code expecting that either all of the functions are
there ore none of them are there but not a mix (which happens with
static linking).

Thus we fix bug 5784 at the distribution level, but no consensus for a
solution exists upstream.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]