[PATCH] build_bug.h: Also define static_assert() when __CHECKER__ is defined

Tom Rini trini at konsulko.com
Thu May 4 21:55:28 CEST 2023


On Thu, May 04, 2023 at 05:32:12PM +0000, Christophe Leroy wrote:
> 
> 
> Le 04/05/2023 à 19:22, Christophe Leroy a écrit :
> > 
> > 
> > Le 04/05/2023 à 15:54, Tom Rini a écrit :
> >> On Thu, May 04, 2023 at 06:15:13AM +0000, Christophe Leroy wrote:
> >>>
> >>>
> >>> Le 03/05/2023 à 22:02, Tom Rini a écrit :
> >>>> On Thu, Jan 26, 2023 at 07:17:48PM +0100, Christophe Leroy wrote:
> >>>>
> >>>>> When doing a build with C=2, the following failure is encountered on
> >>>>> several files:
> >>>>>
> >>>>>       CHECK   arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c: note: in included file 
> >>>>> (through arch/powerpc/include/asm/global_data.h, include/init.h):
> >>>>>     include/asm-generic/global_data.h:494:21: error: Expected ) in 
> >>>>> function declarator
> >>>>>     include/asm-generic/global_data.h:494:21: error: got (
> >>>>>
> >>>>> And because of the error, the interesting part which are the
> >>>>> warnings don't appear. This is because static_assert() is defined
> >>>>> only when __CHECKER__ is not defined.
> >>>>>
> >>>>> Add a stub when __CHECKER__ is defined. With that fix, the expected
> >>>>> warnings are now seen:
> >>>>>
> >>>>>       CHECK   arch/powerpc/cpu/mpc8xxx/fsl_lbc.c
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:27:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:32:45:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:24:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:35:40:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:67:17:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:68:17:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:72:17:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:73:17:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:78:9:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:79:9:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:131:22:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:132:49:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:26:    got unsigned int 
> >>>>> [usertype] *mxmr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:144:41:    got unsigned int 
> >>>>> [usertype] *mxmr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:145:27:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:146:32:    got unsigned int *
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:149:39:    got unsigned int 
> >>>>> [usertype] *mxmr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18:    expected unsigned 
> >>>>> int volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:18:    got unsigned int 
> >>>>> [usertype] *mxmr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33: warning: incorrect 
> >>>>> type in argument 1 (different address spaces)
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33:    expected unsigned 
> >>>>> int const volatile [noderef] <asn:2> *addr
> >>>>>     arch/powerpc/cpu/mpc8xxx/fsl_lbc.c:155:33:    got unsigned int 
> >>>>> [usertype] *mxmr
> >>>>>
> >>>>> Signed-off-by: Christophe Leroy <christophe.leroy at csgroup.eu>
> >>>>
> >>>> Based on my re-read of the thread in patchwork, it seems like the best
> >>>> answer would be to re-sync this include, along with a few others, from
> >>>> the latest kernel release, yes?
> >>>>
> >>>
> >>> Yes that's right, a re-sync should work, together with a revert of
> >>> aa9e891c633 ("include/linux/stddef.h: avoid 'warning: preprocessor token
> >>> offsetof redefined'") IIRC
> >>
> >> Will you be sending a patch, or should I put it on my TODO list (and how
> >> exactly do I trigger the above problem?).  Thanks.
> >>
> > 
> > Well, I was hoping to find some time during winter but I never 
> > succeeded. So if you can put it on your TODO list that's fine. Maybe you 
> > have some automated way to backport stuff from Linux to U-boot ?
> > 
> > Reproduction is done easily with:
> > 
> > make CROSS_COMPILE=powerpc-linux- CMPC885_defconfig
> > 
> > followed by
> > 
> > make CROSS_COMPILE=powerpc-linux- C=2
> > 
> > 
> > Then everytime you get a repetitive syntax-based error, it's something 
> > that shouldn't happen. Examples:
> > 
> >    CHECK   arch/powerpc/cpu/mpc8xx/cpu.c
> > 
> > arch/powerpc/cpu/mpc8xx/cpu.c: note: in included file (through 
> > arch/powerpc/include/asm/global_data.h):
> > include/asm-generic/global_data.h:494:21: error: Expected ) in function 
> > declarator
> > include/asm-generic/global_data.h:494:21: error: got (
> > 
> > 
> > 
> > arch/powerpc/cpu/mpc8xx/cpu.c: note: in included file (through 
> > include/compiler.h, include/env.h, include/net.h):
> > /opt/gcc-12.2.0-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/12.2.0/include/stddef.h:433:14: error: expected ; at end of declaration
> > /opt/gcc-12.2.0-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/12.2.0/include/stddef.h:433:14: error: Expected } at end of specifier
> > /opt/gcc-12.2.0-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/12.2.0/include/stddef.h:433:14: error: got __max_align_f128
> > /opt/gcc-12.2.0-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/12.2.0/include/stddef.h:435:1: error: Expected ; at the end of type declaration
> > /opt/gcc-12.2.0-nolibc/powerpc-linux/bin/../lib/gcc/powerpc-linux/12.2.0/include/stddef.h:435:1: error: got }
> > 
> 
> There is the same kind of issue with qemu-x86_64_defconfig :
> 
> make qemu-x86_64_defconfig
> 
> make C=2
> 
> ...
>    CHECK   arch/x86/lib/bdinfo.c
> arch/x86/lib/bdinfo.c: note: in included file (through 
> include/compiler.h, arch/x86/include/asm/mrccache.h, 
> arch/x86/include/asm/global_data.h, include/init.h):
> /usr/lib/gcc/x86_64-redhat-linux/12/include/stddef.h:415:9: warning: 
> preprocessor token offsetof redefined
> arch/x86/lib/bdinfo.c: note: in included file (through 
> include/linux/posix_types.h, include/linux/types.h, include/time.h, 
> include/common.h):
> include/linux/stddef.h:19:9: this was the original definition
> arch/x86/lib/bdinfo.c: note: in included file (through 
> arch/x86/include/asm/global_data.h, include/init.h):
> include/asm-generic/global_data.h:494:21: error: Expected ) in function 
> declarator
> include/asm-generic/global_data.h:494:21: error: got (

Thanks, I _think_ we could add a CI test then, once this is resolved, so
long as C=2 issues still give a zero exit status, or at least a specific
one we can catch and say OK to that's not the same as a fail to build.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230504/6fd07005/attachment.sig>


More information about the U-Boot mailing list