From owner-freebsd-threads@FreeBSD.ORG Sun Sep 28 08:32:53 2014 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A6CFD48; Sun, 28 Sep 2014 08:32:53 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0D713E3; Sun, 28 Sep 2014 08:32:52 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s8S8WkUV025765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 28 Sep 2014 11:32:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s8S8WkUV025765 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s8S8WkkN025764; Sun, 28 Sep 2014 11:32:46 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 28 Sep 2014 11:32:46 +0300 From: Konstantin Belousov To: Raphael Kubo da Costa Subject: Re: Segfault from libthr.so. Message-ID: <20140928083246.GA26076@kib.kiev.ua> References: <20140926150001.GF7885@Jetdail> <20140926164306.GE8870@kib.kiev.ua> <20140927065556.GH7885@Jetdail> <20140927083621.GJ8870@kib.kiev.ua> <86ppegg2e6.fsf@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86ppegg2e6.fsf@FreeBSD.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-threads@freebsd.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Sep 2014 08:32:53 -0000 On Sun, Sep 28, 2014 at 12:49:21AM +0300, Raphael Kubo da Costa wrote: > Konstantin Belousov 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.