* linux-next: build warning after merge of the kbuild tree @ 2011-05-02 2:18 Stephen Rothwell 2011-05-02 2:24 ` Dave Jones 0 siblings, 1 reply; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 2:18 UTC (permalink / raw) To: Michal Marek; +Cc: linux-next, linux-kernel, Dave Jones, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 483 bytes --] Hi Michal, After merging the kbuild tree, today's linux-next build (x86_64 allmodconfig) produced this warning: At top level: cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable" Presumably caused by commit af0e5d565d2f ("kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0") though I don't see why. I am using gcc version 4.4.5. -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 2:18 linux-next: build warning after merge of the kbuild tree Stephen Rothwell @ 2011-05-02 2:24 ` Dave Jones 2011-05-02 3:45 ` Stephen Rothwell 0 siblings, 1 reply; 15+ messages in thread From: Dave Jones @ 2011-05-02 2:24 UTC (permalink / raw) To: Stephen Rothwell; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg On Mon, May 02, 2011 at 12:18:17PM +1000, Stephen Rothwell wrote: > Hi Michal, > > After merging the kbuild tree, today's linux-next build (x86_64 > allmodconfig) produced this warning: > > At top level: > cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable" > > Presumably caused by commit af0e5d565d2f ("kbuild: Disable > -Wunused-but-set-variable for gcc 4.6.0") though I don't see why. I am > using gcc version 4.4.5. Which version of the patch got merged ? This should be guarded by cc-option checks. Dave ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 2:24 ` Dave Jones @ 2011-05-02 3:45 ` Stephen Rothwell 2011-05-02 4:02 ` Dave Jones 2011-05-02 4:24 ` Stephen Rothwell 0 siblings, 2 replies; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 3:45 UTC (permalink / raw) To: Dave Jones; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg Hi Dave, On Sun, 1 May 2011 22:24:18 -0400 Dave Jones <davej@redhat.com> wrote: > > Which version of the patch got merged ? This should be guarded by cc-option checks. It looks right to me (that's why I wrote "though I don't see why") but empirically we have a problem. This is what is in -next today: From: Dave Jones <davej@redhat.com> Date: Thu, 21 Apr 2011 17:28:13 -0400 Subject: [PATCH] kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0 Disable the new -Wunused-but-set-variable that was added in gcc 4.6.0 It produces more false positives than useful warnings. This can still be enabled using W=1 Signed-off-by: Dave Jones <davej@redhat.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Tested-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Michal Marek <mmarek@suse.cz> --- Makefile | 4 ++++ scripts/Makefile.build | 1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index e509cc7..4527dc2 100644 --- a/Makefile +++ b/Makefile @@ -567,6 +567,10 @@ ifndef CONFIG_CC_STACKPROTECTOR KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) endif +# This warning generated too much noise in a regular build. +# Use make W=1 to enable this warning (see scripts/Makefile.build) +KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable) + ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls else diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9c0c481..9fb19c0 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -66,6 +66,7 @@ warning-1 += -Wmissing-format-attribute warning-1 += -Wmissing-prototypes warning-1 += -Wold-style-definition warning-1 += $(call cc-option, -Wmissing-include-dirs) +warning-1 += $(call cc-option, -Wunused-but-set-variable) warning-2 := -Waggregate-return warning-2 += -Wcast-align -- 1.7.4.4 -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 3:45 ` Stephen Rothwell @ 2011-05-02 4:02 ` Dave Jones 2011-05-02 4:44 ` Stephen Rothwell 2011-05-02 4:24 ` Stephen Rothwell 1 sibling, 1 reply; 15+ messages in thread From: Dave Jones @ 2011-05-02 4:02 UTC (permalink / raw) To: Stephen Rothwell; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg On Mon, May 02, 2011 at 01:45:24PM +1000, Stephen Rothwell wrote: > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > index 9c0c481..9fb19c0 100644 > --- a/scripts/Makefile.build > +++ b/scripts/Makefile.build > @@ -66,6 +66,7 @@ warning-1 += -Wmissing-format-attribute > warning-1 += -Wmissing-prototypes > warning-1 += -Wold-style-definition > warning-1 += $(call cc-option, -Wmissing-include-dirs) > +warning-1 += $(call cc-option, -Wunused-but-set-variable) Subtly different from what I wrote.. the version I wrote did this .. +KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wunused-but-set-variable) I just tested with the gcc 4.4.5 on master.kernel.org, with a tip of Linus' tree with my original diff, and it didn't complain at all. What does gcc -v say ? gcc version 4.4.5 20101112 (Red Hat 4.4.5-2) (GCC) seems to be fine. (note the above hunk isn't relevant unless using W=1 builds anyway, so I'm at a loss as to what broke it..) Dave ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 4:02 ` Dave Jones @ 2011-05-02 4:44 ` Stephen Rothwell 0 siblings, 0 replies; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 4:44 UTC (permalink / raw) To: Dave Jones; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 1656 bytes --] Hi Dave, On Mon, 2 May 2011 00:02:16 -0400 Dave Jones <davej@redhat.com> wrote: > > Subtly different from what I wrote.. the version I wrote did this .. > > +KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wunused-but-set-variable) Due to other changes in the kbuild tree, I suspect. However, as you say, this part is not relevant to the warning I am getting. > I just tested with the gcc 4.4.5 on master.kernel.org, with a tip of Linus' > tree with my original diff, and it didn't complain at all. Also see my other email. For a i386 defconfig build, I get this warning only twice, for a sparc64 defconfig I get 4 and for a sparc32 defconfig, none: At top level: cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable" > What does gcc -v say ? > gcc version 4.4.5 20101112 (Red Hat 4.4.5-2) (GCC) seems to be fine. $ /opt/cross/gcc-4.4.5-nolibc/x86_64-linux/bin/x86_64-linux-gcc -v Using built-in specs. Target: x86_64-linux Configured with: /home/tony/buildall/src/gcc/configure --target=x86_64-linux --enable-targets=all --prefix=/home/tony/buildall/cross.x86_64/gcc-4.4.5-nolibc/x86_64-linux/ --enable-languages=c --with-newlib --without-headers --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --enable-checking=release --with-mpfr=/home/tony/buildall/src/sys-x86_64 --with-gmp=/home/tony/buildall/src/sys-x86_64 --disable-bootstrap Thread model: single gcc version 4.4.5 (GCC) -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 3:45 ` Stephen Rothwell 2011-05-02 4:02 ` Dave Jones @ 2011-05-02 4:24 ` Stephen Rothwell 2011-05-02 4:36 ` Dave Jones 2011-05-02 4:53 ` Stephen Rothwell 1 sibling, 2 replies; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 4:24 UTC (permalink / raw) To: Dave Jones; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 645 bytes --] Hi Dave, On Mon, 2 May 2011 13:45:24 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote: > > On Sun, 1 May 2011 22:24:18 -0400 Dave Jones <davej@redhat.com> wrote: > > > > Which version of the patch got merged ? This should be guarded by cc-option checks. > > It looks right to me (that's why I wrote "though I don't see why") but > empirically we have a problem. I do not get it for every compile fo a file, just a few times during a whole kernel build. Some config/arches do not produce any (like sparc32 defconfig). -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 4:24 ` Stephen Rothwell @ 2011-05-02 4:36 ` Dave Jones 2011-05-02 5:57 ` Stephen Rothwell 2011-05-02 4:53 ` Stephen Rothwell 1 sibling, 1 reply; 15+ messages in thread From: Dave Jones @ 2011-05-02 4:36 UTC (permalink / raw) To: Stephen Rothwell; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg On Mon, May 02, 2011 at 02:24:54PM +1000, Stephen Rothwell wrote: > Hi Dave, > > On Mon, 2 May 2011 13:45:24 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote: > > > > On Sun, 1 May 2011 22:24:18 -0400 Dave Jones <davej@redhat.com> wrote: > > > > > > Which version of the patch got merged ? This should be guarded by cc-option checks. > > > > It looks right to me (that's why I wrote "though I don't see why") but > > empirically we have a problem. > > I do not get it for every compile fo a file, just a few times during a > whole kernel build. Some config/arches do not produce any (like sparc32 > defconfig). That's interesting. That suggests that something isn't being built with KBUILD_CFLAGS. I did a full defconfig build on x86-64 successfully (allmodconfig is churning away). Can you point me at something that doesn't build ? Dave ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 4:36 ` Dave Jones @ 2011-05-02 5:57 ` Stephen Rothwell 0 siblings, 0 replies; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 5:57 UTC (permalink / raw) To: Dave Jones; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 2477 bytes --] Hi Dave, On Mon, 2 May 2011 00:36:43 -0400 Dave Jones <davej@redhat.com> wrote: > > That's interesting. That suggests that something isn't being built with KBUILD_CFLAGS. > I did a full defconfig build on x86-64 successfully (allmodconfig is churning away). > Can you point me at something that doesn't build ? I have just done an i386 defconfig build with V=1. Every compilation has that flag passed to it, but only one complains: i386-linux-gcc -Wp,-MD,kernel/.futex.o.d -nostdinc -isystem /opt/cross/gcc-4.4.5-nolibc/i386-linux/bin/../lib/gcc/i386-linux/4.4.5/include -I/scratch/sfr/next/arch/x86/include -Iarch/x86/include/generated -Iinclude -I/scratch/sfr/next/include -include include/generated/autoconf.h -I/scratch/sfr/next/kernel -Ikernel -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m32 -msoft-float -mregparm=3 -freg-struct-return -mpreferred-stack-boundary=2 -march=i686 -mtune=generic -Wa,-mtune=generic32 -ffreestanding -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(futex)" -D"KBUILD_MODNAME=KBUILD_STR(futex)" -c -o kernel/futex.o /scratch/sfr/next/kernel/futex.c /scratch/sfr/next/kernel/futex.c: In function 'fixup_pi_state_owner': /scratch/sfr/next/kernel/futex.c:1549: warning: 'curval' may be used uninitialized in this function /scratch/sfr/next/kernel/futex.c: In function 'futex_lock_pi_atomic': /scratch/sfr/next/kernel/futex.c:678: warning: 'curval' may be used uninitialized in this function /scratch/sfr/next/kernel/futex.c: In function 'handle_futex_death': /scratch/sfr/next/kernel/futex.c:2454: warning: 'nval' may be used uninitialized in this function At top level: cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable" I removed kernel/futex.o and recompiled to verify. futex.c doesn't seem to be built any differently to anything else. -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 4:24 ` Stephen Rothwell 2011-05-02 4:36 ` Dave Jones @ 2011-05-02 4:53 ` Stephen Rothwell 2011-05-02 11:13 ` Michal Marek 1 sibling, 1 reply; 15+ messages in thread From: Stephen Rothwell @ 2011-05-02 4:53 UTC (permalink / raw) To: Dave Jones; +Cc: Michal Marek, linux-next, linux-kernel, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 2495 bytes --] Hi Dave, hmmm, On my build machine: $ /opt/cross/gcc-4.4.5-nolibc/x86_64-linux/bin/x86_64-linux-gcc -Wno-unused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? 0 $ /opt/cross/gcc-4.4.5-nolibc/x86_64-linux/bin/x86_64-linux-gcc -Wunused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? cc1: error: unrecognized command line option "-Wunused-but-set-variable" 1 $ gcc -Wno-unused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? 0 $ gcc -Wunused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? cc1: error: unrecognized command line option "-Wunused-but-set-variable" 1 $ gcc -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.5 (Debian 4.4.5-8) On master.kernel.org: $ gcc -Wno-unused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? 0 $ gcc -Wunused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? 0 $ gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 4.4.5 20101112 (Red Hat 4.4.5-2) (GCC) -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 4:53 ` Stephen Rothwell @ 2011-05-02 11:13 ` Michal Marek 2011-05-02 12:13 ` [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ Michal Marek 2011-05-02 15:17 ` linux-next: build warning after merge of the kbuild tree Valdis.Kletnieks 0 siblings, 2 replies; 15+ messages in thread From: Michal Marek @ 2011-05-02 11:13 UTC (permalink / raw) To: Stephen Rothwell; +Cc: Dave Jones, linux-next, linux-kernel, Sam Ravnborg On Mon, May 02, 2011 at 02:53:38PM +1000, Stephen Rothwell wrote: > Hi Dave, > > hmmm, > > On my build machine: > $ /opt/cross/gcc-4.4.5-nolibc/x86_64-linux/bin/x86_64-linux-gcc -Wno-unused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? > 0 > $ /opt/cross/gcc-4.4.5-nolibc/x86_64-linux/bin/x86_64-linux-gcc -Wunused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? > cc1: error: unrecognized command line option "-Wunused-but-set-variable" > 1 > $ gcc -Wno-unused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? > 0 > $ gcc -Wunused-but-set-variable -c -xc /dev/null -o /tmp/xx.o; echo $? > cc1: error: unrecognized command line option "-Wunused-but-set-variable" > 1 I reproduced this myself with 4.5.1 and 4.6.0 and was about to file a bug at gcc.gnu.org, but I learned that this is a feature :-(, see here: http://gcc.gnu.org/PR28322 . It treats invalid -Wno-* options as warnings and it only issues them when there is another warning or error in the source. I have a patch below, but after learning the above, I'm going to rewrite it to some more generic cc-disable-warning fuction, because it can hit us anytime again. Michal Subject: [PATCH] kbuild: Fix passing -Wno-unused-but-set-variable to some gcc versions Some versions of gcc will happily accept -Wno-<anything> in the cc-option test and complain later when compiling some random file that -Wno-unused-but-set-variable is not recognized. Work around this by testing if gcc supports the -Wunused-but-set-variable option insteaed. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Michal Marek <mmarek@suse.cz> diff --git a/Makefile b/Makefile index 4527dc2..db6b6df 100644 --- a/Makefile +++ b/Makefile @@ -569,7 +569,12 @@ endif # This warning generated too much noise in a regular build. # Use make W=1 to enable this warning (see scripts/Makefile.build) -KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable) +# We test for support of the -Wunused-but-set-variable option, because +# some version of gcc will happily accept any -Wno-* switch and complain +# later during build. +ifeq ($(call cc-option-yn, -Wunused-but-set-variable), y) +KBUILD_CFLAGS += -Wno-unused-but-set-variable +endif ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ 2011-05-02 11:13 ` Michal Marek @ 2011-05-02 12:13 ` Michal Marek 2011-05-03 0:44 ` Stephen Rothwell 2011-05-02 15:17 ` linux-next: build warning after merge of the kbuild tree Valdis.Kletnieks 1 sibling, 1 reply; 15+ messages in thread From: Michal Marek @ 2011-05-02 12:13 UTC (permalink / raw) To: sfr; +Cc: davej, linux-next, linux-kernel, sam Starting with 4.4, gcc will happily accept -Wno-<anything> in the cc-option test and complain later when compiling a file that has some other warning. This rather unexpected behavior is intentional as per http://gcc.gnu.org/PR28322, so work around it by testing for support of the opposite option (without the no-). Introduce a new Makefile function cc-disable-warning that does this and update two uses of cc-option in the toplevel Makefile. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Michal Marek <mmarek@suse.cz> --- Documentation/kbuild/makefiles.txt | 12 ++++++++++++ Makefile | 4 ++-- scripts/Kbuild.include | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 835b64a..47435e5 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -501,6 +501,18 @@ more details, with real examples. gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used. Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options + cc-disable-warning + cc-disable-warning checks if gcc supports a given warning and returns + the commandline switch to disable it. This special function is needed, + because gcc 4.4 and later accept any unknown -Wno-* option and only + warn about it if there is another warning in the source file. + + Example: + KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) + + In the above example, -Wno-unused-but-set-variable will be added to + KBUILD_CFLAGS only if gcc really accepts it. + cc-version cc-version returns a numerical version of the $(CC) compiler version. The format is <major><minor> where both are two digits. So for example diff --git a/Makefile b/Makefile index 4527dc2..f919209 100644 --- a/Makefile +++ b/Makefile @@ -569,7 +569,7 @@ endif # This warning generated too much noise in a regular build. # Use make W=1 to enable this warning (see scripts/Makefile.build) -KBUILD_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls @@ -616,7 +616,7 @@ CHECKFLAGS += $(NOSTDINC_FLAGS) KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) # disable pointer signed / unsigned warnings in gcc 4.0 -KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) +KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index fae2d8d..c034dd7 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\ cc-option-align = $(subst -functions=0,,\ $(call cc-option,-falign-functions=0,-malign-functions=0)) +# cc-disable-warning +# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) +cc-disable-warning = $(call try-run,\ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1))) + # cc-version # Usage gcc-ver := $(call cc-version) cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ 2011-05-02 12:13 ` [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ Michal Marek @ 2011-05-03 0:44 ` Stephen Rothwell 2011-05-03 8:52 ` Michal Marek 0 siblings, 1 reply; 15+ messages in thread From: Stephen Rothwell @ 2011-05-03 0:44 UTC (permalink / raw) To: Michal Marek; +Cc: davej, linux-next, linux-kernel, sam [-- Attachment #1: Type: text/plain, Size: 862 bytes --] HI Michal, On Mon, 2 May 2011 14:13:01 +0200 Michal Marek <mmarek@suse.cz> wrote: > > Starting with 4.4, gcc will happily accept -Wno-<anything> in the > cc-option test and complain later when compiling a file that has some > other warning. This rather unexpected behavior is intentional as per > http://gcc.gnu.org/PR28322, so work around it by testing for support of > the opposite option (without the no-). Introduce a new Makefile function > cc-disable-warning that does this and update two uses of cc-option in > the toplevel Makefile. > > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> > Signed-off-by: Michal Marek <mmarek@suse.cz> This fixed things for me, thanks. Tested-by: Stephen Rothwell <sfr@canb.auug.org.au> -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ 2011-05-03 0:44 ` Stephen Rothwell @ 2011-05-03 8:52 ` Michal Marek 0 siblings, 0 replies; 15+ messages in thread From: Michal Marek @ 2011-05-03 8:52 UTC (permalink / raw) To: Stephen Rothwell; +Cc: davej, linux-next, linux-kernel, sam On 3.5.2011 02:44, Stephen Rothwell wrote: > HI Michal, > > On Mon, 2 May 2011 14:13:01 +0200 Michal Marek<mmarek@suse.cz> wrote: >> >> Starting with 4.4, gcc will happily accept -Wno-<anything> in the >> cc-option test and complain later when compiling a file that has some >> other warning. This rather unexpected behavior is intentional as per >> http://gcc.gnu.org/PR28322, so work around it by testing for support of >> the opposite option (without the no-). Introduce a new Makefile function >> cc-disable-warning that does this and update two uses of cc-option in >> the toplevel Makefile. >> >> Reported-by: Stephen Rothwell<sfr@canb.auug.org.au> >> Signed-off-by: Michal Marek<mmarek@suse.cz> > > This fixed things for me, thanks. > > Tested-by: Stephen Rothwell<sfr@canb.auug.org.au> Thanks for spotting the warnings and for testing. I pushed this to kbuild-2.6.git#kbuild. Michal ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 11:13 ` Michal Marek 2011-05-02 12:13 ` [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ Michal Marek @ 2011-05-02 15:17 ` Valdis.Kletnieks 2011-05-02 15:31 ` Michal Marek 1 sibling, 1 reply; 15+ messages in thread From: Valdis.Kletnieks @ 2011-05-02 15:17 UTC (permalink / raw) To: Michal Marek Cc: Stephen Rothwell, Dave Jones, linux-next, linux-kernel, Sam Ravnborg [-- Attachment #1: Type: text/plain, Size: 460 bytes --] On Mon, 02 May 2011 13:13:37 +0200, Michal Marek said: > +# We test for support of the -Wunused-but-set-variable option, because > +# some version of gcc will happily accept any -Wno-* switch and complain > +# later during build. > +ifeq ($(call cc-option-yn, -Wunused-but-set-variable), y) > +KBUILD_CFLAGS += -Wno-unused-but-set-variable > +endif Do we need to do this more generically for all the other -Wno-foo options under the various W={123} options? [-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: linux-next: build warning after merge of the kbuild tree 2011-05-02 15:17 ` linux-next: build warning after merge of the kbuild tree Valdis.Kletnieks @ 2011-05-02 15:31 ` Michal Marek 0 siblings, 0 replies; 15+ messages in thread From: Michal Marek @ 2011-05-02 15:31 UTC (permalink / raw) To: Valdis.Kletnieks Cc: Stephen Rothwell, Dave Jones, linux-next, linux-kernel, Sam Ravnborg On 2.5.2011 17:17, Valdis.Kletnieks@vt.edu wrote: > On Mon, 02 May 2011 13:13:37 +0200, Michal Marek said: > >> +# We test for support of the -Wunused-but-set-variable option, because >> +# some version of gcc will happily accept any -Wno-* switch and complain >> +# later during build. >> +ifeq ($(call cc-option-yn, -Wunused-but-set-variable), y) >> +KBUILD_CFLAGS += -Wno-unused-but-set-variable >> +endif > > Do we need to do this more generically for all the other -Wno-foo > options under the various W={123} options? I only see -Wno-unused-parameter in scripts/Makefile.build and that should be supported by any gcc version. Also please have a look at http://marc.info/?l=linux-kernel&m=130433840412201&w=2, which is an updated version. Michal ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2011-05-03 8:52 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-05-02 2:18 linux-next: build warning after merge of the kbuild tree Stephen Rothwell 2011-05-02 2:24 ` Dave Jones 2011-05-02 3:45 ` Stephen Rothwell 2011-05-02 4:02 ` Dave Jones 2011-05-02 4:44 ` Stephen Rothwell 2011-05-02 4:24 ` Stephen Rothwell 2011-05-02 4:36 ` Dave Jones 2011-05-02 5:57 ` Stephen Rothwell 2011-05-02 4:53 ` Stephen Rothwell 2011-05-02 11:13 ` Michal Marek 2011-05-02 12:13 ` [PATCH] kbuild: Fix passing -Wno-* options to gcc 4.4+ Michal Marek 2011-05-03 0:44 ` Stephen Rothwell 2011-05-03 8:52 ` Michal Marek 2011-05-02 15:17 ` linux-next: build warning after merge of the kbuild tree Valdis.Kletnieks 2011-05-02 15:31 ` Michal Marek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).