Here are a list of build errors and their solutions that I've encountered since I started building custom ROMs. Execute these commands at the root of ROM folder.
I hope this will help others in fixing their build mistakes.
Use compatible trees. For example, do not use Android 11 trees for building Android 12.
Use proton-clang instead of pre-included clang.