From owner-freebsd-current@FreeBSD.ORG Sat Jul 21 11:43:26 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D5B5B106566B; Sat, 21 Jul 2012 11:43:26 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6EDA18FC0A; Sat, 21 Jul 2012 11:43:26 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q6LBhTtZ006693; Sat, 21 Jul 2012 14:43:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q6LBhGpv037554; Sat, 21 Jul 2012 14:43:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q6LBhG43037553; Sat, 21 Jul 2012 14:43:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 21 Jul 2012 14:43:16 +0300 From: Konstantin Belousov To: Dimitry Andric Message-ID: <20120721114316.GY2676@deviant.kiev.zoral.com.ua> References: <50097BF0.9010103@FreeBSD.org> <20120720163352.GS2676@deviant.kiev.zoral.com.ua> <9EBB4101-3117-4FE0-AD08-1053423BECD6@FreeBSD.org> <20120720231604.GT2676@deviant.kiev.zoral.com.ua> <500A93FE.1080700@FreeBSD.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aSb4XDBEo1qAP/IB" Content-Disposition: inline In-Reply-To: <500A93FE.1080700@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Kim Culhan , freebsd-current@freebsd.org, David Chisnall Subject: Re: -current build failure X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2012 11:43:27 -0000 --aSb4XDBEo1qAP/IB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 21, 2012 at 01:35:26PM +0200, Dimitry Andric wrote: > On 2012-07-21 01:16, Konstantin Belousov wrote: > > On Fri, Jul 20, 2012 at 10:07:05PM +0100, David Chisnall wrote: > >> On 20 Jul 2012, at 17:33, Konstantin Belousov wrote: > >> > >>> It is not related to dtrace at all, and indeed OFFSETOF_CURTHREAD is = 0. > >>> This is a bug in clang, we compile our kernel in freestanding environ= ment. > >> > >> The copies of the C spec that I have do not differentiate between > >> freestanding and hosted environments for the validity of dereferencing > >> a pointer value of 0. Doing so is undefined in all cases and any > >> standards-compliant compiler is quite at liberty to eat your dog in > >> such situations - it is explicitly not guaranteed to read the memory at > >> linear address 0 (this is undefined for at least two reasons that I can > >> think of from the C spec, and probably more). > >=20 > > Ok, I stand corrected. But the standard does not say what you claim > > either. It only specifies that NULL pointer is unequal to any pointer > > to object or function (implicitely saying that you can create a C object > > or function pointer to which is equal to NULL). > >=20 > > So, lets reformulate it other way: freestanding implementation in clang > > has no use, at least for general purpose kernel. Especially ridiculous > > is the fact that clang throws it hands for asm inline wanting to get > > null address, on the machine with linearly addressable memory. >=20 > Oh come on, that's just hyperbole. Everybody understands that directly > dereferencing a NULL pointer is very unusual, in any environment. It's > perfectly sane to warn about it. Is it such a big problem to simply > insert a cast to tell the compiler you really want to do this, even if > it is highly unusual? The point of existence of the inline __pure2 __curthread() is to allow a compiler to cache the result of the call. Basically, the curthread dereference uses %gs basing, which typically adds a measurable penalty on the frontend and sometimes on the execution as well. Putting a volatile somewhere prevents the caching, right ? I am probably fine with something along the lines of #ifdef CLANG /* XXX what to put there */ #define VOLATILE volatile #else #define VOLATILE #endif and then use VOLATILE in the cast. Could you recomment the best #if test ? How to test the change ? Is CC=3Dclang make buildkernel enough ? --aSb4XDBEo1qAP/IB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlAKldQACgkQC3+MBN1Mb4gy4ACgrfWAQU17xAURP6Ku9JMeZ1sX uQ4AoMan5lkR572n0BeHWRjy9s1CEzy/ =4ZPB -----END PGP SIGNATURE----- --aSb4XDBEo1qAP/IB--