From owner-freebsd-stable@FreeBSD.ORG Sat Jul 5 13:07:49 2014 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 137CF6D1; Sat, 5 Jul 2014 13:07:49 +0000 (UTC) Received: from albert.catwhisker.org (mx.catwhisker.org [198.144.209.73]) (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 B8DC22805; Sat, 5 Jul 2014 13:07:47 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.9/8.14.9) with ESMTP id s65D7d9T062331; Sat, 5 Jul 2014 06:07:39 -0700 (PDT) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.9/8.14.9/Submit) id s65D7d5O062330; Sat, 5 Jul 2014 06:07:39 -0700 (PDT) (envelope-from david) Date: Sat, 5 Jul 2014 06:07:39 -0700 From: David Wolfskill To: David Chisnall Subject: Re: [HEADS-UP] Problem with clang in 9-stable [was: r268244 (stable/9) seems to break "sysctl hw.ncpu"] Message-ID: <20140705130739.GH6056@albert.catwhisker.org> Mail-Followup-To: David Wolfskill , David Chisnall , stable@freebsd.org, "current@freebsd.org" References: <20140704123901.GR6056@albert.catwhisker.org> <53B6E218.5070009@selasky.org> <20140704174705.GS6056@albert.catwhisker.org> <53B6EDD1.8030506@selasky.org> <20140704181831.GV6056@albert.catwhisker.org> <909248A4-1B7C-4836-ADAA-F81A70A8AC3C@theravensnest.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="quhRrEslxwodne78" Content-Disposition: inline In-Reply-To: <909248A4-1B7C-4836-ADAA-F81A70A8AC3C@theravensnest.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: stable@freebsd.org, "current@freebsd.org" X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jul 2014 13:07:49 -0000 --quhRrEslxwodne78 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 05, 2014 at 01:49:44PM +0100, David Chisnall wrote: > On 4 Jul 2014, at 19:18, David Wolfskill wrote: >=20 > > clang -O2 -pipe -std=3Dgnu99 -Qunused-arguments -fstack-protector -Ws= ystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstri= ct-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-= pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variabl= e -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wn= o-unused-function -Wno-enum-conversion -o sysctl sysctl.o=20 >=20 > This compile line is turning off a lot of warnings. In particular, -Wno-= uninitialized and -Wno-parentheses-equality are likely to hide warnings tha= t refer to real errors. It sounds like this case was one of them - if thes= e warnings were on then we'd have got a build failure rather than an execut= able that depended on undefined behaviour. > .... So I checked src/sbin/sysctl/Makefile first; it's fairly "vanilla": # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD: stable/9/sbin/sysctl/Makefile 203917 2010-02-15 14:08:06Z uqs $ PROG=3D sysctl WARNS?=3D 3 MAN=3D sysctl.8 =2Einclude And the -Wno-uninitialized (at least) comes from bsd.sys.mk: =2Eif ${WARNS} >=3D 2 && ${WARNS} <=3D 4 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't # XXX always get it right. CWARNFLAGS+=3D -Wno-uninitialized =2Eendif # WARNS >=3D2 && WARNS <=3D 4 A bit later, we see the origin of -Wno-parentheses-equality: # Clang has more warnings enabled by default, and when using -Wall, so if W= ARNS # is set to low values, these have to be disabled explicitly. =2Eif ${COMPILER_TYPE} =3D=3D "clang" && !defined(EARLY_BUILD) =2Eif ${WARNS} <=3D 6 CWARNFLAGS+=3D -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-va= riable =2Eendif # WARNS <=3D 6 =2Eif ${WARNS} <=3D 3 CWARNFLAGS+=3D -Wno-tautological-compare -Wno-unused-value\ -Wno-parentheses-equality -Wno-unused-function -Wno-enum-co= nversion =2Eendif # WARNS <=3D 3 =2Eif ${WARNS} <=3D 2 CWARNFLAGS+=3D -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter =2Eendif # WARNS <=3D 2 =2Eif ${WARNS} <=3D 1 CWARNFLAGS+=3D -Wno-parentheses =2Eendif # WARNS <=3D 1 =2Eif defined(NO_WARRAY_BOUNDS) CWARNFLAGS+=3D -Wno-array-bounds =2Eendif # NO_WARRAY_BOUNDS =2Eendif # CLANG I don't know that there's likely to be a huge amount of interest in addressing the issue for stable/9, but stable/10 looks similar, and while I see some differences in head, the code in head's bsd.sys.mk may well be functionally equivalent. I'm happy to help test if someone wants to put together patches to (at least) reduce the extent to which we have executables depending on undefined behavior. Peace, david --=20 David H. Wolfskill david@catwhisker.org Taliban: Evil cowards with guns afraid of truth from a 14-year old girl. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --quhRrEslxwodne78 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJTt/iaXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RThEMDY4QTIxMjc1MDZFRDIzODYzRTc4 QTY3RjlDOERFRjQxOTNCAAoJEIpn+cje9Bk7Vg4P/2mIC8ymli+rmHeaTVgFcleq AZaCur6GqelcWswY5ck+zsiMv0b0AKCPwpltU7RZqWG8/xWSt584PipucMA3j3H3 MPrl4PCdZjlqY5A4I/CgfVNQmtQ938LZ0L8wBmrlTFNFWD5T3ksvaTC69A/oGWFm zhHQenJ2J5Bd3IgkrX98XpzHsIudL+XmkAkUHrD3JipBmt67S1cOaN5J/hNFcdLf 02tnvvE6VYgNMe5eOXO4tCocNMK36IlzydEL8VBj0rWtDPk9EYPXQqIFInApozRx emO7Gt/7Tsk3umJc4T48hmLYi1FhUh1L3LCa4or86gIYuWnOVePkOkR6tKXBO2fX S8Gnkg+097vacGJWgng7xrO2G3B5MycryxOJPgqqYCIcMAnK+njmg5TR2aNUoNnq rGJRsw/K48s3A+U/mGBk1uyC3UBZup7iYnZg16dO7fjnSNSCVaGYJRLRS+mJ5kyq WoJEcccbTTakmhF78sxRtDpnIxjZPEc+7SfaMBv+eMpx1sShPJRBmoBE8l2fr2u4 igNnO4FQGWvKhL640WcuVzUSBkN50rG141uSQpdudj7wFnWCzwSqN0qeq0SVhkv9 YBK5CYEm/MtXP2chfufxBVOFQwHcFIys8Ga2smpa2Z8So259dGKxwoLBYvS4mjaw n95KZSjqHnn8J3UGP12J =UNDT -----END PGP SIGNATURE----- --quhRrEslxwodne78--