[Build] Fix compile errors and patch