Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jul 2014 06:07:39 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        David Chisnall <theraven@theravensnest.org>
Cc:        stable@freebsd.org, "current@freebsd.org" <current@freebsd.org>
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>
In-Reply-To: <909248A4-1B7C-4836-ADAA-F81A70A8AC3C@theravensnest.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>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <david@catwhisker.org> 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 <bsd.prog.mk>

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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140705130739.GH6056>