This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: bug with PI mutex and static linking
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: "Warlich, Christof" <christof dot warlich at siemens dot com>
- Cc: "Sudler, Simon" <simon dot sudler at siemens dot com>, "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Thu, 11 Feb 2016 16:35:48 -0500
- Subject: Re: bug with PI mutex and static linking
- Authentication-results: sourceware.org; auth=none
- References: <6D83E89737156549AEA25EF9ED712C5D18EDE2 at DEFTHW99EK1MSX dot ww902 dot siemens dot net> <CAE2sS1gnYZDc0uwx+W2xY+f7SH=i1cFF7o==EUyF9SNXWWqHzA at mail dot gmail dot com> <6D83E89737156549AEA25EF9ED712C5D18EF29 at DEFTHW99EK1MSX dot ww902 dot siemens dot net>
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.