Build of wireguard module fails on Rocky 8.8 (kernel 4.18.0-477.*)

You may want to use the kmod-wireguard package offered by ELRepo. It is kABI-tracking, meaning it survives kernel updates withing a minor release (8.8 for example).