Thanks for your suggestion.
As your said, it’s native compile. If I try to cross-compile in an external x86 Linux host, can I do it in 5.10 Linux kernel? Because I found the kernel version is 5.4 of my raspberry openWRT.
The compilation host kernel version plays no role. Openwrt toolchain, imagebuilder and SDK all install/include the respectively correct kernel headers for OpenWrt.
But you need to be sure to use the OpenWrt compilation tools matching exactly the OpenWrt version that you are running. Easiest would be if you compile the whole firmware with that new program included.
Thanks. In fact, this is what I want to consider.
Now I directly download the official openWRT image file, but my actual situation is that my Raspberry Pi is connected to other hardware which includes the mentioned software programs that need to be compiled. As you said, what is the way to compile the whole firmware? Is there any reference guide?
See the above link by @RuralRoots - It's how to setup the build environment to compile from source.
You will need to package yourself any software that isn't already available in the OpenWrt package repo. You can find out more about creating packages https://openwrt.org/docs/guide-developer/packages