Projucer macOS Architecture option "Native architecture of build machine" is broken on M1 Macs

When the Projucer “Xcode (macOS)” exporter option “macOS Architecture” is set to “Native architecture of build machine” (osxArchitecture="Native" in .jucer file),
Xcode 12.2 on an M1 Mac builds an arm64e executable rather than arm64, and macOS then refuses to run such executable.

The proper architecture to use should be arm64 architecture as seen on non-preinstalled .apps such as Logic, Final Cut, Google Chrome etc.

(tested on macOS 11.0.1 on MacBook Pro 13-inch, M1, 2020)

1 Like

FYI:

This session https://developer.apple.com/wwdc20/10686 mentions arm64e. I believe it requires special special boot arguments to work for non-Apple processes. They say that they’re not ready for non-Apple developers to adopt it yet.

1 Like

The architectures which get built are determined by the intersection of the ARCHS_STANDARD and VALID_ARCHS settings. The Projucer sets VALID_ARCHS to i386 x86_64 arm64 arm64e by default and, on our DTK at least, this results in a fat binary with x86_64 and arm64 architectures (output by running lipo -info on the binary). If I set VALID_ARCHS to just arm64e then Xcode refuses to build with the error “No architectures to compile for (ARCHS=arm64 x86_64, VALID_ARCHS=arm64e).”

Perhaps the actual M1 machines have ARCHS which includes arm64e? Can you try building a JUCE project with the “Valid Architectures” setting in the macOS exporter set to just arm64e and see if that builds on your machine without error?

In latest develop (b828830af8cb) if I open Projucer.jucer in the Projucer and change the macOS Architecture to “Native architecture of build machine” then I get this when trying to run via Xcode:

If I just tell it to build and not run via Xcode, then it builds an arm64e build that refuses to run when double clicking in Finder.

(for those it doesn’t seem to matter whether there are additional valid architectures)

If I keep architecture as “Default” change the valid architectures to include only arm64e I get the error:

No architectures to compile for (ARCHS=arm64 x86_64, VALID_ARCHS=arm64e)

What about if you change the “Valid Architectures” setting in the Projucer to exclude arm64e (so i386, x86_64 and arm64 are ticked)? If arm64e binaries can’t be run then perhaps we shouldn’t be adding them to the default valid architectures.

When set along with “macOS Architecture” is set to “Native architecture of build machine” you get this:

It seems that this is a problem with the “Legacy Build System” which we enable by default for Xcode projects to fix some issues that were present in Xcode 10. If you disable this via “File->Project Settings…” then it should build an arm64 binary as expected.

I think it’s been long enough that we can use the modern build system as the default with an option to re-enable the legacy system for users who are stuck on a broken version of Xcode (Xcode 10.2 fixed a lot of these issues but requires a major OS version update from High Sierra to Mojave).

7 Likes

This is now on develop:

2 Likes

I understand the need to move forward - can you confirm that this plays well with your corporate overlord’s copy protection system so long as the project is built with XCode 10.2 or higher?

For searchable posterity, I’ll note here: if people run into "Expected unqualified-id” error while compiling a certain type of copy protected build on XCode 10 or 10.1 the problem is likely this setting: make sure it is set to Legacy Build System in that case.

4 Likes

I believe you’ll still need to use the legacy build system which you can enable with the xcode exporter option in the Projucer.

1 Like