Internal compiler error: Segmentation fault

Hi there,

My board is rock-5a, I’m trying to build kernel image on board.

I download the kernel source code with:
git clone https://github.com/radxa/kernel.git --branch=linux-5.10-gen-rkr3.4

Everything is perfect when I build the source code on the original board environment, and the system can boot normally when I use the new kernel image that I built.

But when I build the kernel source again under new kernel environment, it gives segmentation fault errors like this:

./include/linux/pm_wakeup.h:107:38: internal compiler error: Segmentation fault
  107 | extern int device_init_wakeup(struct device *dev, bool val);
      |                                      ^~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.

I tried to clean the kernel source tree, and make a clean build, but it doesn’t help, if I switch back to the original kernel envionment, it OK again.

I noticed that this error message is mentioned in user guide, but it doesn’t give a solution:
https://wiki.radxa.com/Rock5/guide/build-kernel-on-5b

Does anyone know how to solve it?

Cyrus