Segfault from libthr.so.

Konstantin Belousov kostikbel at gmail.com
Sun Sep 28 08:32:53 UTC 2014


On Sun, Sep 28, 2014 at 12:49:21AM +0300, Raphael Kubo da Costa wrote:
> Konstantin Belousov <kostikbel at gmail.com> writes:
> 
> >> In my app, i dont directly start any thread, lower libs do. So it
> >> doesnt seem logical to add -lpthread before declaring the deps. So
> >> should i just remove this m4 macro that seems to be use on quite some
> >> projects, so it works on BSD ?
> >>
> >> What is the best way to do it, in your opinion ?
> >
> > Just put -lpthread last in the command line (automake variable) for linker.
> > This should work portable on all systems I know.
> 
> Alternatively, you could pass -pthread instead of -lpthread: the
> compiler should then take care of passing -lpthread in the right
> position -- it's what we use in the ports tree, for example.

As far as you checked that compiler accepts this flag and does what you
think the compiler should do.  I believe that -pthread is only supported
by (some configurations of) gcc and compilers which try to sincerely
copy the gcc behaviour, i.e. clang.  AFAIR, native Unix compilers,
e.g. SunPro, and possibly even icc, do not support the -pthread.

In other words, -lpthread is more portable, which does not matter for
ports, where only gcc and clang are target compilers, but important
for generic autoconfigured source.


More information about the freebsd-threads mailing list