Le 27/01/2023 à 08:43, Rasmus Villemoes a écrit : > [Vous ne recevez pas souvent de courriers de rasmus.villem...@prevas.dk. > Découvrez pourquoi ceci est important à > https://aka.ms/LearnAboutSenderIdentification ] > > On 26/01/2023 19.17, 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: >> > > So sparse has supported _Static_assert since basically forever, and in > the linux version of build_bug.h, the static_assert definition is not > inside #ifndef __CHECKER__. So I think a better fix is to synchronize > build_bug.h with linux again, so that we actually also do those > static_asserts with sparse (if nothing else then as a sanity check of > sparse itself, it really should grok ICEs and barf at > 'static_assert(sizeof(int) == 3)'). > > The __CHECKER__ guard around most of the file vanished from upstream in > 527edbc18a70, just before the static_assert define was added in > 6bab69c65013, and I didn't notice that discrepancy when porting that to > U-Boot in ef0f4e834c66. >
Ah right, I didn't see that difference with Linux. By the way, there are other changes in Linux that we are missing in Uboot and create problems for me when using sparse: 80591e61a0f7 ("kbuild: tell sparse about the $ARCH") 6c49f359ca14 ("kbuild: disable sparse warnings about unknown attributes") Also I have a problem with the following u-boot commit : aa9e891c633 ("include/linux/stddef.h: avoid 'warning: preprocessor token offsetof redefined'") On uboot mainline I get: CHECK drivers/pci/pci-uclass.c drivers/pci/pci-uclass.c:88:9: error: typename in expression drivers/pci/pci-uclass.c:88:9: error: typename in expression drivers/pci/pci-uclass.c:88:9: error: undefined identifier 'offsetof' drivers/pci/pci-uclass.c:88:9: error: cast from unknown type drivers/pci/pci-uclass.c:88:9: error: undefined identifier 'offsetof' drivers/pci/pci-uclass.c:88:9: error: cast from unknown type If I revert that patch I get CHECK drivers/pci/pci-uclass.c drivers/pci/pci-uclass.c:852:20: warning: function 'board_pci_fixup_dev' with external linkage has definition drivers/pci/pci-uclass.c:594:17: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:594:17: expected unsigned char volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:594:17: got unsigned char volatile [usertype] * drivers/pci/pci-uclass.c:597:17: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:597:17: expected unsigned short volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:597:17: got unsigned short volatile [usertype] * drivers/pci/pci-uclass.c:600:17: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:600:17: expected unsigned int volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:600:17: got unsigned int volatile [usertype] * drivers/pci/pci-uclass.c:625:27: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:625:27: expected unsigned char const volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:625:27: got unsigned char volatile [usertype] * drivers/pci/pci-uclass.c:628:27: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:628:27: expected unsigned short const volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:628:27: got unsigned short volatile [usertype] * drivers/pci/pci-uclass.c:631:27: warning: incorrect type in argument 1 (different address spaces) drivers/pci/pci-uclass.c:631:27: expected unsigned int const volatile [noderef] <asn:2> *addr drivers/pci/pci-uclass.c:631:27: got unsigned int volatile [usertype] * drivers/pci/pci-uclass.c:1563:16: warning: Using plain integer as NULL pointer drivers/pci/pci-uclass.c:1841:1: warning: symbol '_u_boot_list_2_uclass_driver_2_pci' was not declared. Should it be static? drivers/pci/pci-uclass.c:1863:1: warning: symbol '_u_boot_list_2_driver_2_pci_bridge_drv' was not declared. Should it be static? drivers/pci/pci-uclass.c:1870:1: warning: symbol '_u_boot_list_2_uclass_driver_2_pci_generic' was not declared. Should it be static? drivers/pci/pci-uclass.c:1880:1: warning: symbol '_u_boot_list_2_driver_2_pci_generic_drv' was not declared. Should it be static? But there are other files that then exhibit the original problem: On mainline: CHECK drivers/rtc/ds1374.c drivers/rtc/ds1374.c:68:12: warning: symbol 'RtcTodAddr' was not declared. Should it be static? With above commit reverted; CHECK drivers/rtc/ds1374.c drivers/rtc/ds1374.c: note: in included file (through include/compiler.h, include/env.h, include/command.h): /opt/cldk-1.4.11/lib/gcc/ppc-linux/5.5.0/include/stddef.h:417:9: warning: preprocessor token offsetof redefined drivers/rtc/ds1374.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 drivers/rtc/ds1374.c:68:12: warning: symbol 'RtcTodAddr' was not declared. Should it be static? What can we do about it ? At least reverting it replaces an error with a warning, I think that's better isn't it ? Thanks Christophe