bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glthread weak symbols handling for POSIX threads fails with recent binut


From: Colin Watson
Subject: glthread weak symbols handling for POSIX threads fails with recent binutils and "ld --as-needed"
Date: Mon, 7 Oct 2013 12:40:14 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

We've had a few cases recently in Ubuntu of packages that use Gnulib
failing to build with test-lock and test-thread_create failures.  Here's
one:

  
https://launchpadlibrarian.net/152673088/buildlog_ubuntu-saucy-i386.gnutls26_2.12.23-1ubuntu3_FAILEDTOBUILD.txt.gz

I got concerned about this today and tried to track it down.  I believe
that the proximate cause is a binutils change that landed in recent
snapshots from the 2.24 branch:
https://sourceware.org/ml/binutils/2013-01/msg00188.html changed "ld
--as-needed" to require a non-weak symbol.  Ubuntu links with
--as-needed by default.  glthread/thread.h (if USE_POSIX_THREADS_WEAK)
uses weak symbols, according to the comments, to avoid pulling
libpthread into programs that only care about using libintl.  But
nothing causes test-lock and test-thread_create to link against
libpthread for any other reason, so they fail.

There are a few possible fixes to this that I can see:

 1) Link test-lock and test-thread_create (at least) with -pthread
    rather than just -lpthread; -pthread adds an -lpthread outside
    --as-needed, forcing the link even though there are no non-weak
    references.

 2) Link these tests with --Wl,--no-as-needed.

 3) Make glthread_create not use a weak symbol (which would also require
    turning gl_thread_create into a macro).

I like 3) best because using glthread_create seems to be a pretty good
indication that you actually want to use threads, and this change seems
to make glthread more standalone, rather than requiring the program
using it to somehow know about pthreads explicitly.  As far as I can see
libintl doesn't use glthread_create so this wouldn't affect it, although
of course that would have to be checked.  But I'm new to this code;
could somebody with more experience comment?

Thanks,

-- 
Colin Watson                                       address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]