Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 363935 - sys-kernel/gentoo-source-2.6.38-r2 - with gcc 4.6.0 - /usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable-ppc64.h:260:16: error: variable ‘old’ set but not used [-Werror=unused-but-set-variable]
Summary: sys-kernel/gentoo-source-2.6.38-r2 - with gcc 4.6.0 - /usr/src/linux-2.6.38-g...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: PPC64 Linux
: Normal normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: gcc-4.6
  Show dependency tree
 
Reported: 2011-04-17 16:34 UTC by Emmanuel Andry
Modified: 2011-04-29 21:43 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
.config file (config,56.55 KB, text/plain)
2011-04-17 16:37 UTC, Emmanuel Andry
Details
pgtable_ppc64_h.patch (pgtable_ppc64_h.patch,1.06 KB, patch)
2011-04-18 16:01 UTC, Stratos Psomadakis (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel Andry 2011-04-17 16:34:36 UTC
# make
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      arch/powerpc/kernel/ptrace.o
In file included from /usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable.h:23:0,
                 from include/linux/mm.h:41,
                 from arch/powerpc/kernel/ptrace.c:20:
/usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable-ppc64.h: In function ‘ptep_set_wrprotect’:
/usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable-ppc64.h:260:16: erreur: variable ‘old’ set but not used [-Werror=unused-but-set-variable]
/usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable-ppc64.h: In function ‘huge_ptep_set_wrprotect’:
/usr/src/linux-2.6.38-gentoo-r2/arch/powerpc/include/asm/pgtable-ppc64.h:270:16: erreur: variable ‘old’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

make[1]: *** [arch/powerpc/kernel/ptrace.o] Erreur 1
make: *** [arch/powerpc/kernel] Erreur 2


Reproducible: Always

Steps to Reproduce:
1. build gentoo-source kernel on ppc64 with gcc 4.6
2.
3.
Actual Results:  
Build fails

Expected Results:  
Kernel builds

Also true for 2.6.38-r1, which did build fine with gcc 4.5.2.
For info, I use gcc 4.6.0 patchset 1.2.
Comment 1 Emmanuel Andry 2011-04-17 16:37:20 UTC
Created attachment 270291 [details]
.config file
Comment 2 Stratos Psomadakis (RETIRED) gentoo-dev 2011-04-18 16:01:48 UTC
Created attachment 270401 [details, diff]
pgtable_ppc64_h.patch

you can try this patch, which probably fixes your build failure...
alternatively, you can disable CONFIG_PPC_WERROR from your config and enable CONFIG_PPC_DISABLE_WERROR(they're obviously mutually exclusive), so that you can build the kernel...
i'll submit the patch upstream too..
Comment 3 Emmanuel Andry 2011-04-23 10:13:14 UTC
Your fix works, but another issue arise :

# make -j2 && make -j2 modules_install
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      arch/powerpc/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CC      init/main.o
  CC      arch/powerpc/kernel/ptrace.o
arch/powerpc/kernel/ptrace.c: In function ‘arch_ptrace’:
arch/powerpc/kernel/ptrace.c:1479:5: erreur: array subscript is above array bounds [-Werror=array-bounds]
arch/powerpc/kernel/ptrace.c:1507:5: erreur: array subscript is above array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors

make[1]: *** [arch/powerpc/kernel/ptrace.o] Erreur 1
make: *** [arch/powerpc/kernel] Erreur 2
make: *** Attente des tâches non terminées....
  CHK     include/generated/compile.h
  CC      init/do_mounts.o
  CC      init/do_mounts_rd.o
  CC      init/noinitramfs.o
  LD      init/mounts.o
  LD      init/built-in.o
Comment 4 Stratos Psomadakis (RETIRED) gentoo-dev 2011-04-23 13:34:05 UTC
(In reply to comment #3)
> Your fix works, but another issue arise :
>   CC      arch/powerpc/kernel/ptrace.o
> arch/powerpc/kernel/ptrace.c: In function ‘arch_ptrace’:
> arch/powerpc/kernel/ptrace.c:1479:5: erreur: array subscript is above array
> bounds [-Werror=array-bounds]
> arch/powerpc/kernel/ptrace.c:1507:5: erreur: array subscript is above array
> bounds [-Werror=array-bounds]
> cc1: all warnings being treated as errors
Does this occur only with gcc-4.6.0?

The warning reported by gcc is not a 'bug', it's a trick the ppc devs used and 'semantically' it's not wrong (although the code could be patched, and maybe made a bit easier to understand).

Anyway, I don't think any of these patches will get added to genpatches, since these build failures can be fixed simply by enabling a CONFIG option, and they're not fixing any actual bugs.

Another possible fix, if you want to keep PPC_WERROR enabled, is to add -Wno-array-bounds to CFLAGS_ptrace.o in arch/powerpc/kernel/Makefile (I tested it only with a dummy userspace program I wrote and seems to work).

However, I'd suggest to disable CONFIG_PPC_WERROR and enable CONFIG_PPC_DISABLE_WERROR(maybe this can be done for genpatches too)...
IMHO, PPC_WERROR should only be enabled if you want to debug the PPC kernel sources, and thus you want abort compiling at each warning.
You'll see the warnings anyway, and if you don't want to actually fix/check any of these warnings, there's no point in having PPC_WERROR enabled.

Btw, the first warning you reported(unused-but-set-variable) will be fixed anyway in next kernel releases, since this new gcc behavior procuces a lot of noisy warnings on any arch, and breaks some archs (like PPC and SPARC which have WERROR enabled by default). [1]

[1] https://lkml.org/lkml/2011/4/21/324
Comment 5 Emmanuel Andry 2011-04-28 09:36:11 UTC
Yes, only with gcc 4.6, it build fine with gcc 4.5.2.

I used CONFIG_PPC_DISABLE_WERROR and it build fine with gcc 4.6.
Strange that default setting set warning as errors...
Maybe you can close this ticket as INVALID ?