Compilation error with Clang 13 in Windows

I am trying to use Clang 13 in Windows with Visual studio 2019 tool kit to build the Unreal Engine. However I am getting the following linker error

Module.OpenCVLensDistortion.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: void __cdecl FRHICommandSetShaderParameter::Execute(class FRHICommandListBase &)” (_imp?Execute@?$FRHICommandSetShaderParameter@VFRHIGraphicsShader@@@@QEAAXAEAVFRHICommandListBase@@@Z) referenced in function “public: virtual void __cdecl FRHICommand<struct FRHICommandSetShaderParameter,struct FRHICommandSetShaderParameterString>::ExecuteAndDestruct(class FRHICommandListBase &,struct FRHICommandListDebugContext &)” (?ExecuteAndDestruct@?$FRHICommand@U?

I get the same error when I tried to use VS 17 and VS 22 tool kit as well.
I am trying to force the project to use clang with the following change
diff --git a/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/UEBuildWindows.cs b/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/UEBuildWindows.cs
index 620a4e6d8b8…bca6259749f 100644
— a/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/UEBuildWindows.cs
+++ b/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/UEBuildWindows.cs
@@ -783,6 +783,8 @@ namespace UnrealBuildTool
///
public override void ValidateTarget(TargetRules Target)
{
+

  •                   Target.WindowsPlatform.Compiler = WindowsCompiler.Clang;
    

Do you have any suggestions to mitigate the error. I am interested in building UE4 with Clang

You should modify the engine codes.
Refer to this commit: https://github.com/EpicGames/UnrealEngine/commit/1b30b0693242e0c38ab51391a4f9e1f04628b34b

VCToolChain.cs (if you are using VS2022)
RHICommandList.h (add RHI_API)
RHICommandListCommandExecutes.inl (add RHI_API)

I’ve successfully built the engine 4.27.2 with Clang-13.0.1 on VS2022
Good luck :smiley:

Has anyone figured out how to get it to work with Clang on Windows consistently? In theory this should improve performance by quite a lot with no change to your game’s code. I don’t know why there isn’t more effort in this direction as it seems like a pretty awesome thing