Cannot build UE 5.1.1 from source on macOS Ventura 13.3.1, Xcode 14.3

I updated my macOS and Xcode yesterday, and I now cannot build UE from source (whereas I could last week). My repo fork is up to date with the latest release branch.

The error I’m seeing is macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma]. I used git clean to reset the repo and followed the instructions in the README, and got stuck at the Mac step 5 – building the ShaderCompileWorker. This is the same bug I was seeing with building UE5 before resetting my repo.

The error seems to be occurring in Runtime/Core/Private/Thirdparty/MiMalloc.c:25:.

Is anyone else experience this?

1 Like

Oh I would like to check if Xcode 14.3 works too.

As an overall advice though, it is wise to wait around a month or two on Xcode updates, frameworks and dev tools tend to catch up late with it.

Did you try adding flags to your build specifications ?
First make sure that you’re not the one using deprecated code, if not you can try disabling the flag :

On YourGame.Target.cs

using UnrealBuildTool;
using System.Collections.Generic;

public class YourGameTarget : TargetRules
{
	public YourGameTarget(TargetInfo Target) : base(Target)
	{
        if(Target.Platform == UnrealTargetPlatform.Mac)
        {
            bOverrideBuildEnvironment = true;
            AdditionalCompilerArguments = "-Wno-deprecated-pragma";  // you can add more separated with spaces here
        }

      ...
	}
}
3 Likes

Thank you for your reply and advice, @Murazaki.

I hadn’t tried adding flags to my _.Target.cs yet (I didn’t know how to do that :sweat_smile:; thank you for showing me), but I wasn’t at a point yet to build my own code. I was still at step 5 of the Mac setup instruction in the README: building the ShaderCompileWorker.

That being said, I did add your code snippet to the ShaderCompileWorker.Target.cs and was able to successfully build the target!

I am building the UE5 target now – I’ll post here once I have the results of that.

Thanks!

After adding the additional compiler flag to UnrealEditor.Target.cs, the UE5 build was successful.

I then tried building my project, and had to add the same code snippet to my _Editor.Target.cs constructor in order for the build to complete.

So it seems the error is related to the deprecation of ATOMIC_VAR_INIT since C++20. I gather from this table that Xcode 14.3 includes a clang patch version bump from 14.0.0 to 14.0.3, and a llvm major version bump from 14.0.0 to 15.0.0. With my limited understanding of clang and llvm, I would guess that llvm 15 compiles at C++20, and therefore throws the build error, whereas the build is successful with Xcode 14.2.

Is there somewhere in the source where I can add the clang flag -Wno-deprecated-pragma based on which version of clang is being used? That seems like it would be a suitable solution for addressing this issue globally.

This could be my issue, since last week after updating to xCode 14.3 I could no longer package my iOS builds where I could very easily before. Time to re-install 14.2 it looks like.

@tbelgrave Did you try the code snippet that @Murazaki posted above in your .Target.cs?

I tried adding the following code to my Engine/Source/Runtime/Core/Public/Apple/ApplePlatformCompilerPreSetup.h instead of adding the compiler argument in my .Target.cs:

// Apple LLVM 14.0.3 (Xcode 14.3)
#if (__clang_major__ == 14 && __clang_patchlevel__ == 3)
#pragma clang diagnostic ignored "-Wdeprecated-pragma"
#endif

This did not work, so I started seeing the macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma] error message again.

2 Likes

Got the same problem. Have tried many possible ways but not work. Still waiting for a decent solution.

1 Like

Thanks to the pointers by @Murazaki, I made some modifications to Engine/Source/Programs/UnrealBuildTool/Platform/Mac/MacToolChain.cs file and the error is gone.

I’m using UE source code version with tag 5.1.1-release on MacOS Ventura 13.2.1, with Xcode 14.3 and M2 Max.

Added code:

			if (CompilerVersionGreaterOrEqual(14, 0, 0))
			{
				Arguments.Add("-Wno-deprecated-pragma");
			}

Full function:

protected override void GetCompileArguments_Global(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
		{
			base.GetCompileArguments_Global(CompileEnvironment, Arguments);

			Arguments.Add("-fasm-blocks");

			if (CompileEnvironment.bEnableOSX109Support)
			{
				Arguments.Add("-faligned-new"); // aligned operator new is supported only on macOS 10.14 and above
			}

			// Pass through architecture and OS info
			Arguments.Add("" + FormatArchitectureArg(CompileEnvironment.Architecture));
			Arguments.Add($"-isysroot \"{SDKPath}\"");
			Arguments.Add("-mmacosx-version-min=" + (CompileEnvironment.bEnableOSX109Support ? "10.9" : Settings.MacOSVersion));

			List<string> FrameworksSearchPaths = new List<string>();
			foreach (UEBuildFramework Framework in CompileEnvironment.AdditionalFrameworks)
			{
				FileReference FrameworkPath = new FileReference(Path.GetFullPath(Framework.Name));
				if (!FrameworksSearchPaths.Contains(FrameworkPath.Directory.FullName))
				{
					Arguments.Add($"-F \"{NormalizeCommandLinePath(FrameworkPath.Directory)}\"");
					FrameworksSearchPaths.Add(FrameworkPath.Directory.FullName);
				}
			}

			
			if (CompilerVersionGreaterOrEqual(14, 0, 0))
			{
				Arguments.Add("-Wno-deprecated-pragma");
			}
		}
9 Likes

thanks!its useful

Did you add the code above to YourGame.Target.cs ? Can you tell me by any chance?

I didn’t add the code above to YourGame.Target.cs. I only modified Engine/Source/Programs/UnrealBuildTool/Platform/Mac/MacToolChain.cs