starfive-tech / VisionFive2

445 stars 79 forks source link

error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init] #9

Closed yoyojacky closed 1 day ago

yoyojacky commented 1 year ago

when it compiling to drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.o, it will crash and raise an error message:

  CALL    /home/jacky/VisionFive2/linux/scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
  CC      drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.o
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1846:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1846 |  &PMRLockSysPhysAddressesLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1846:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1846:2: error: invalid initializer
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1846:2: note: (near initialization for ‘_sPMRLMAFuncTab.<anonymous>’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1848:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1848 |  &PMRUnlockSysPhysAddressesLocalMem,
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1848:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1848:2: error: initialization of ‘PVRSRV_ERROR (*)(void *, IMG_DEVMEM_OFFSET_T,  IMG_UINT8 *, size_t,  size_t *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, long long unsigned int,  unsigned char *, long unsigned int,  long unsigned int *)’} from incompatible pointer type ‘PVRSRV_ERROR (*)(void *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *)’} [-Werror=incompatible-pointer-types]
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1848:2: note: (near initialization for ‘_sPMRLMAFuncTab.pfnReadBytes’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1850:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1850 |  &PMRSysPhysAddrLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1850:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1850:2: error: initialization of ‘PVRSRV_ERROR (*)(void *, size_t,  size_t,  void **, void **, PMR_FLAGS_T)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, long unsigned int,  long unsigned int,  void **, void **, long long unsigned int)’} from incompatible pointer type ‘PVRSRV_ERROR (*)(void *, IMG_UINT32,  IMG_UINT32,  IMG_DEVMEM_OFFSET_T *, IMG_BOOL *, IMG_DEV_PHYADDR *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, unsigned int,  unsigned int,  long long unsigned int *, enum tag_img_bool *, IMG_DEV_PHYADDR *)’} [-Werror=incompatible-pointer-types]
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1850:2: note: (near initialization for ‘_sPMRLMAFuncTab.pfnAcquireKernelMappingData’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1852:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1852 |  &PMRAcquireKernelMappingDataLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1852:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1852:2: error: initialization of ‘void (*)(void)’ from incompatible pointer type ‘PVRSRV_ERROR (*)(void *, size_t,  size_t,  void **, void **, PMR_FLAGS_T)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, long unsigned int,  long unsigned int,  void **, void **, long long unsigned int)’} [-Werror=incompatible-pointer-types]
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1852:2: note: (near initialization for ‘_sPMRLMAFuncTab.pfnReleasePMRFactoryLock’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1854:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1854 |  &PMRReleaseKernelMappingDataLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1854:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1854:2: error: initialization of ‘PVRSRV_ERROR (*)(void *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *)’} from incompatible pointer type ‘void (*)(void *, void *)’ [-Werror=incompatible-pointer-types]
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1854:2: note: (near initialization for ‘_sPMRLMAFuncTab.pfnUnpinMem’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1856:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1856 |  &PMRReadBytesLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1856:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1858:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1858 |  &PMRWriteBytesLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1858:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1858:2: error: initialization of ‘PVRSRV_ERROR (*)(void *, const PMR *, IMG_UINT64,  IMG_UINT32,  IMG_UINT32 *, IMG_UINT32,  IMG_UINT32 *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, const struct _PMR_ *, long long unsigned int,  unsigned int,  unsigned int *, unsigned int,  unsigned int *)’} from incompatible pointer type ‘PVRSRV_ERROR (*)(void *, IMG_DEVMEM_OFFSET_T,  IMG_UINT8 *, size_t,  size_t *)’ {aka ‘enum PVRSRV_ERROR_TAG (*)(void *, long long unsigned int,  unsigned char *, long unsigned int,  long unsigned int *)’} [-Werror=incompatible-pointer-types]
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1858:2: note: (near initialization for ‘_sPMRLMAFuncTab.pfnChangeSparseMemCPUMap’)
In file included from /home/jacky/VisionFive2/linux/include/uapi/linux/posix_types.h:5,
                 from /home/jacky/VisionFive2/linux/include/uapi/linux/types.h:14,
                 from /home/jacky/VisionFive2/linux/include/linux/types.h:6,
                 from /home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/include/img_types.h:69,
                 from /home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:45:
/home/jacky/VisionFive2/linux/include/linux/stddef.h:8:14: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
    8 | #define NULL ((void *)0)
      |              ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1860:2: note: in expansion of macro ‘NULL’
 1860 |  NULL,
      |  ^~~~
/home/jacky/VisionFive2/linux/include/linux/stddef.h:8:14: note: (near initialization for ‘_sPMRLMAFuncTab’)
    8 | #define NULL ((void *)0)
      |              ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1860:2: note: in expansion of macro ‘NULL’
 1860 |  NULL,
      |  ^~~~
/home/jacky/VisionFive2/linux/include/linux/stddef.h:8:14: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
    8 | #define NULL ((void *)0)
      |              ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1862:2: note: in expansion of macro ‘NULL’
 1862 |  NULL,
      |  ^~~~
/home/jacky/VisionFive2/linux/include/linux/stddef.h:8:14: note: (near initialization for ‘_sPMRLMAFuncTab’)
    8 | #define NULL ((void *)0)
      |              ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1862:2: note: in expansion of macro ‘NULL’
 1862 |  NULL,
      |  ^~~~
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1864:2: error: positional initialization of field in ‘struct’ declared with ‘designated_init’ attribute [-Werror=designated-init]
 1864 |  &PMRChangeSparseMemLocalMem,
      |  ^
/home/jacky/VisionFive2/linux/drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.c:1864:2: note: (near initialization for ‘_sPMRLMAFuncTab’)
‘PVRSRV_ERROR (*)(void *, PMR_MAPPING_TABLE *)
Internal compiler error: Error reporting routines re-entered.
0x7f1c08055082 __libc_start_main
        ../csu/libc-start.c:308
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugs.buildroot.net/> for instructions.
make[7]: *** [/home/jacky/VisionFive2/linux/scripts/Makefile.build:277: drivers/gpu/drm/img/img-rogue/services/server/common/physmem_lma.o] Error 1
make[6]: *** [/home/jacky/VisionFive2/linux/scripts/Makefile.build:540: drivers/gpu/drm/img/img-rogue] Error 2
make[5]: *** [/home/jacky/VisionFive2/linux/scripts/Makefile.build:540: drivers/gpu/drm/img] Error 2
make[4]: *** [/home/jacky/VisionFive2/linux/scripts/Makefile.build:540: drivers/gpu/drm] Error 2
make[3]: *** [/home/jacky/VisionFive2/linux/scripts/Makefile.build:540: drivers/gpu] Error 2
make[2]: *** [/home/jacky/VisionFive2/linux/Makefile:1868: drivers] Error 2
make[2]: Leaving directory '/home/jacky/VisionFive2/work/linux'
make[1]: *** [Makefile:219: __sub-make] Error 2
make[1]: Leaving directory '/home/jacky/VisionFive2/linux'
make: *** [Makefile:218: /home/jacky/VisionFive2/work/linux/vmlinux] Error 2
jacky@Dev1:~/VisionFive2$

How can I solve this problem ? 

andyhu-stf commented 1 year ago

@yoyojacky , did you build the linux with an extern riscv cross toolchain not the buildroot toolchain?

If not, do you have run into the below situation? Especially when you had build the whole sdk, and then you want to rebuild the linux for example:

rm -rf work/linux
make -j8

It will prompt like below:

make[2]: Entering directory '/var/lib/jenkins/workspace/VF2_515_Branch_SDK_Release/visionfive/work/linux'
  SYNC    include/config/auto.conf.cmd
  GEN     Makefile
*
* Restart config...
*
* GCC plugins
*
GCC plugins (GCC_PLUGINS) [Y/n/?] (NEW) 
  Compute the cyclomatic complexity of a function (GCC_PLUGIN_CYC_COMPLEXITY) [N/y/?] (NEW) 
  Generate some entropy during boot and runtime (GCC_PLUGIN_LATENT_ENTROPY) [N/y/?] (NEW) 
  Randomize layout of sensitive kernel structures (GCC_PLUGIN_RANDSTRUCT) [N/y/?] (NEW) 
*
* Memory initialization
*
Initialize kernel stack variables at function entry
> 1. no automatic stack variable initialization (weakest) (INIT_STACK_NONE)
  2. zero-init structs marked for userspace (weak) (GCC_PLUGIN_STRUCTLEAK_USER) (NEW)
  3. zero-init structs passed by reference (strong) (GCC_PLUGIN_STRUCTLEAK_BYREF) (NEW)
  4. zero-init everything passed by reference (very strong) (GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) (NEW)
choice[1-4?]: 
Enable heap memory zeroing on allocation by default (INIT_ON_ALLOC_DEFAULT_ON) [N/y/?] n
Enable heap memory zeroing on free by default (INIT_ON_FREE_DEFAULT_ON) [N/y/?] n

Normally we should select the default config. If you select the CONFIG_GCC_PLUGIN_RANDSTRUCT to Y, then will reproduce your problem

BTW, if you don't want the above prompt when building the linux, then you could run the below

rm -rf work/linux
rm -rf work/u-boot
make -j8
yoyojacky commented 1 day ago

OK, Thanks, I works for me, I have selected the CONFIG_GCC_PLUGIN_RANDSTRUCT by mistake, right now, everything is ok.. thanks for your tips.