Mailinglist Archive: opensuse-packaging (182 mails)

< Previous Next >
[opensuse-packaging] Re: --as-needed and pthread
  • From: Cristian Morales Vega <cmorve69@xxxxxxxx>
  • Date: Fri, 19 Jun 2009 05:53:35 +0200
  • Message-id: <8235e6f40906182053t191d8748n4009bb07fb9fe2fc@xxxxxxxxxxxxxx>
Good explanation.

2009/6/19 Michael Matz <matz@xxxxxxx>:

[including some random mailing list, so that the text isn't lost :) ]

On Thu, 18 Jun 2009, Cristian Rodríguez wrote:

there are some packages that fail to build because they miss phtread
symbols. I have always have the doubt about why there is the
"-pthread" gcc flag... somewhere I read that's the correct thing to
do, that using -lpthread is wrong, but without explanations. What
should I use in these cases? I suppose use -lpthread would be the
equivalent to what they did without --as-needed... but perhaps the
behavior without --as-needed was already wrong.

matz is the right person to answer your question, as far as I know, the
right way is using -lpthread instead of -pthread , is that correct ?

Nope, -pthread is better than -lpthread (see below).  It's completely
possible that something is broken with as-needed vs. pthreads.  Those
cases have to be identified and then worked around
(export SUSE_AS_NEEDED=0), or better, analyzed for the root cause.

I didn't get the complete thread, only this forward, so I don't know what
the nature of the breakage is, so I can give only speculations:
I would think that if something with pthread and as-needed breaks it
doesn't get exposed as missing symbols or the like (so that apps don't
even start) but rather mysterious breakages related to non-thread-aware
functions being used even though -pthread was given as compile and link

They are just link failures... because "-lpthread" is before the
object code that uses it (I didn't saw the -lpthread and though there
were some magic happening).

If there is any problem using -pthread with --as-needed I understand
it would be because libc would be linked before libpthread, true? If
so, a "ldd -u -r" would say libpthread is an unneeded direct
dependency? Would be an easy way to detect it.
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >