From dan@kulesh.obluda.cz  Mon May 29 15:01:07 2006
Return-Path: <dan@kulesh.obluda.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3E20116A640
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 May 2006 15:01:07 +0000 (UTC)
	(envelope-from dan@kulesh.obluda.cz)
Received: from smtp1.kolej.mff.cuni.cz (smtp1.kolej.mff.cuni.cz [195.113.24.4])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 93BFF43D55
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 May 2006 15:01:06 +0000 (GMT)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (openvpn.ms.mff.cuni.cz [195.113.20.87])
	by smtp1.kolej.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k4TF12qM066574
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 May 2006 17:01:04 +0200 (CEST)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (localhost [127.0.0.1] (may be forged))
	by kulesh.obluda.cz (8.13.6/8.13.6) with ESMTP id k4TF12Qj077862
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 May 2006 17:01:02 +0200 (CEST)
	(envelope-from dan@kulesh.obluda.cz)
Received: (from root@localhost)
	by kulesh.obluda.cz (8.13.6/8.13.6/Submit) id k4TF11wn077841;
	Mon, 29 May 2006 17:01:01 +0200 (CEST)
	(envelope-from dan)
Message-Id: <200605291501.k4TF11wn077841@kulesh.obluda.cz>
Date: Mon, 29 May 2006 17:01:01 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [ patch ] Makefile style of mfi kernel module broke the WARNS/NO_WERROR logic
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         98091
>Category:       kern
>Synopsis:       [mfi] [patch] Makefile style of mfi kernel module broke the WARNS/NO_WERROR logic
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    scottl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 29 15:10:12 GMT 2006
>Closed-Date:    Sun Dec 12 15:26:29 UTC 2010
>Last-Modified:  Sun Dec 12 15:26:29 UTC 2010
>Originator:     Dan Lukes
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
Obludarium
>Environment:
System: FreeBSD kulesh.obluda.cz 6.1-STABLE FreeBSD 6.1-STABLE #3: Mon May 15 02:41:49 CEST 2006 dan@kulesh.obluda.cz:/usr/obj/usr/src/sys/KULESH i386
src/sys/modules/mfi/Makefile,v 1.1.2.1 2006/04/04 03:24:49 scottl

>Description:
	The forced use of -Werror in CFLAGS made module uncompilable in some environments 
(when -O3 and requested, for example):
/usr/src/sys/modules/mfi/../../dev/mfi/mfi.c: In function 
fi_attach':
@/dev/mfi/mfivar.h:259: warning: inlining failed in call to 'mfi_dequeue_free': --param in
line-unit-growth limit reached
/usr/src/sys/modules/mfi/../../dev/mfi/mfi.c:434: warning: called from here
@/dev/mfi/mfivar.h:259: warning: inlining failed in call to 'mfi_dequeue_free': --param in
line-unit-growth limit reached
/usr/src/sys/modules/mfi/../../dev/mfi/mfi.c:475: warning: called from here
*** Error code 1
	


>How-To-Repeat:
	Add -O3 to CFLAGS then try to build the module
>Fix:

	Use WARNS logic included in on mod.sys.mk, not direct setting of CFLAGS

	It allow the user to customize CFLAGS using the NO_WERROR if necesarry.

--- sys/modules/mfi/Makefile.ORIG	Mon May 29 16:37:21 2006
+++ sys/modules/mfi/Makefile	Mon May 29 16:38:19 2006
@@ -6,7 +6,7 @@
 SRCS=	mfi.c mfi_pci.c mfi_disk.c
 SRCS+=	opt_mfi.h
 SRCS+=	device_if.h bus_if.h pci_if.h
-CFLAGS+= -Wall -Werror
+WARNS=	2
 
 # To enable debug output from the driver, uncomment these two lines.
 #CFLAGS+= -DMFI_DEBUG=2

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->scottl 
Responsible-Changed-By: ru 
Responsible-Changed-When: Mon May 29 15:40:27 UTC 2006 
Responsible-Changed-Why:  
Scott, please fix it as per style.Makefile manpage: 

o   Do not use GCCisms (such as -g and -Wall) in CFLAGS. 

o   WARNS comes before CFLAGS, as it is basically a CFLAGS modifier.  It 
comes before CFLAGS rather than after CFLAGS so it does not get lost 
in a sea of CFLAGS statements as WARNS is an important thing.  The 
usage of WARNS is spelled ``WARNS?= '', so that it may be overridden 
on the command line or in make.conf(5). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98091 

From: Bruce Evans <bde@zeta.org.au>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, scottl@FreeBSD.org
Subject: Re: kern/98091: [ patch ] Makefile style of mfi kernel module broke
 the WARNS/NO_WERROR logic
Date: Tue, 30 May 2006 04:38:41 +1000 (EST)

 On Mon, 29 May 2006, Ruslan Ermilov wrote:
 
 > Synopsis: [ patch ] Makefile style of mfi kernel module broke the WARNS/NO_WERROR logic
 >     o   Do not use GCCisms (such as -g and -Wall) in CFLAGS.
 >
 >     o   WARNS comes before CFLAGS, as it is basically a CFLAGS modifier.  It
 >         comes before CFLAGS rather than after CFLAGS so it does not get lost
 >         in a sea of CFLAGS statements as WARNS is an important thing.  The
 >         usage of WARNS is spelled ``WARNS?= '', so that it may be overridden
 >         on the command line or in make.conf(5).
 
 WARNS is often misplaced relative to CFLAGS, including in style.Makefile.5.
 A correct version says:
 
       o   WARNS goes after CFLAGS, as it is basically a relatively unimportant
           modifier of CFLAGS.  Normal usage of WARNS is ``WARNS?= '' in a top
           level Makefile.inc, so that it can be set for whole subtrees but
           overridden as necessary.  Leaf makefiles should only use it for tem-
           porary overrides.  If they use it, then they should also assign to it
           using ``?='' so that it may be overridden by even more temporary
           overrides in the usual places (on the command line, in the environ-
           ment or in /etc/make.conf).
 
 Using WARNS at all in modules is another style bug which is covered
 by the above saying not to put WARNS in individual Makefiles.  Putting
 it in individual Makefiles in /usr/src is unfortunately necessary
 because the src tree has a highly variable quality, but kernel code
 is more uniform and has been compiled at a high warning level (nearly
 WARNS=6) for many years.  Only 9 Makefiles in the sys/modules tree set
 WARNS.  All of these set WARNS to 2 using "?=".  This has only null
 and negative effects (see below).
 
 kernels and modules also use a different mechanism for setting warning
 flags.  bsd.kern.mk sets a bunch of flags in CWARNFLAGS unless CWARNFLAGS
 is already set.  WARNS=2 currently just adds the following flags after
 the flags set by CWARNFLAGS:
 
      -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitalized
 
 This has only null and negative effects:
 
 - -Wsystem-headers has no effect since system headers are not used for
    kernels and modules, modulo bugs.
 - -Werror and -Wall are already in CFLAGS.  Adding them just bloats
    command lines.
 - -Wnoformat-y2k is irrelevant in kernels (I think).
 - -Wno-uninitialized just clobbers -Wunitialized.  Clobbering -Wuninitialized
    is a hack in bsd.sys.mk for WARNS between 2 and 4 inclusive.  It is
    used because -Wuninitialized doesn't work quite right and there is
    a lot of code that doesn't work around its bugs.  IIRC, -Wuninitialized
    used to be part of -W and this made -W too strict for kernels.  -W
    has been marked as the "next up for working" on in bsd.kern.mk for
    about 10 years.  -Wall now gives some warnings about uninitialized
    variables (perhaps it always did, but not as many as -W).  Anyway,
    kernels have been building with -Wall for many years so turning off
    any warnings set by -Wall in Makefiles for new modules is just a
    bug.
 
 The correct fix for mfi/Makefile is to remove the gccisms without adding
 WARNS.
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: uqs 
State-Changed-When: Sun Dec 12 15:25:36 UTC 2010 
State-Changed-Why:  
CFLAGS was removed in r159044, PR no longer applies. 

Thanks for the submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98091 
>Unformatted:
