[poc] buildkernel + clang + -Werror
Alexander Best
arundel at freebsd.org
Sat Nov 5 10:21:02 UTC 2011
i'm sending this mail to the mailinglist simply to prevent my work being list.
i've experimented with the -Werror and -Wno-error= options and got to the point
where i was able to compile GENERIC on amd64 with clang:
#
# XXX The following options might indicate real problems and need to be
# investigated:
# array-bounds, conversion, format, format-security, shift-count-overflow,
# and shift-overflow.
#
.if ${CC:T:Mclang} == "clang"
WERROR?= -Werror -Wno-error=array-bounds -Wno-error=conversion \
-Wno-error=empty-body -Wno-error=format -Wno-error=format-extra-args \
-Wno-error=format-invalid-specifier -Wno-error=format-security \
-Wno-error=shift-count-negative -Wno-error=shift-count-overflow \
-Wno-error=shift-overflow -Wno-error=tautological-compare
.else
WERROR?= -Werror
.endif
a few drawbacks...
1) this will only work with clang tot, since the clang version that ships with
HEAD atm doesn't understand 'shift-count-negative'; it is being implied by
-Werror and cannot be turned off seperately.
2) there is a bug in the clang version that ships with HEAD, where -Wno-error=X
implies -WX. this is not correct (see gcc(1) man page) and was fixed in
clang tot.
3) the 'format-*' options are only necessary for clang tot, since it doesn't
understand '-fformat-extensions'. if 1) and 2) can be fixed and the clang
release that ships with HEAD can be used for compilation, the 'format-*'
options can probably be removed.
4) as noted in the comment, a few flags might indicate *real* issues in the
code. i've merely enabled these to prove that clang can in fact compile the
src with -Werror being set. however these options probably shouldn't be set,
but rather investigated.
cheers.
alex
ps: maybe the vendor commits that fixed 1) and 2) could be imported into the
the clang version in HEAD.
More information about the freebsd-toolchain
mailing list