How to enable AVX2 on AST files

I am trying to cross compile Unreal Engine 5.5.4 dedicated server to linux from Windows. I have code that relies on AVX2 so I figured it would just work, but I am unable to get it to compile, I get these errors:

UATHelper: Packaging (Linux): error: current translation unit is compiled with the target feature '+avx' but the AST file was not
UATHelper: Packaging (Linux): error: current translation unit is compiled with the target feature '+avx2' but the AST file was not
UATHelper: Packaging (Linux): error: current translation unit is compiled with the target feature '+bmi' but the AST file was not

I am at a loss as to how to fix this, I have tried going into Game.Build.cs and adding MinCpuArchX64 = MinimumCpuArchitectureX64.AVX2; but that didn’t change anything

I went into VCToolChain.cs and at the top of the function protected virtual void AppendCLArguments_Global(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
I added

Arguments.Add("/arch:AVX2");
Arguments.Add("-mavx2");

Afterwards, recompiled the engine, also regenerated my project files. Deleted the intermediate and binaries folder for my project, recompiled. Then when going to package the server for linux, I get those errors, what else can I do to force the compilation of the AST files to be compiled with AVX2

I have no idea. Are you using wsl ?
Or just crosscompile?

This may be a silly question, but have you checked to be sure the AST files are actually being recompiled?

1 Like

This won’t directly answer your question, but I did find mention of a property “bUseAVX” that exists (but is obsolete, according to the documentation) in the Build.cs file.

Here’s the link: Module Properties (official docs)

Hopefully this gives you another avenue to investigate.

1 Like