Date: Sun, 28 Sep 2014 11:32:46 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Raphael Kubo da Costa <rakuco@FreeBSD.org> Cc: freebsd-threads@freebsd.org Subject: Re: Segfault from libthr.so. Message-ID: <20140928083246.GA26076@kib.kiev.ua> In-Reply-To: <86ppegg2e6.fsf@FreeBSD.org> References: <20140926150001.GF7885@Jetdail> <20140926164306.GE8870@kib.kiev.ua> <20140927065556.GH7885@Jetdail> <20140927083621.GJ8870@kib.kiev.ua> <86ppegg2e6.fsf@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 28, 2014 at 12:49:21AM +0300, Raphael Kubo da Costa wrote: > Konstantin Belousov <kostikbel@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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140928083246.GA26076>