From owner-freebsd-toolchain@FreeBSD.ORG Sat Nov 5 10:21:02 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id 1E7FA1065670; Sat, 5 Nov 2011 10:21:02 +0000 (UTC) Date: Sat, 5 Nov 2011 10:21:02 +0000 From: Alexander Best To: freebsd-toolchain@freebsd.org Message-ID: <20111105102102.GA54596@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [poc] buildkernel + clang + -Werror X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Nov 2011 10:21:02 -0000 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.