Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Premake on macOS universal binary #1629

Merged
merged 4 commits into from
Aug 10, 2021

Conversation

tempura-sukiyaki
Copy link
Contributor

What does this PR do?

This change allows Premake to be built for Arm64/x86_64 universal binaries on macOS.

How does this PR change Premake's behavior?

Premake runs on Arm64 on Macs using the Apple M1 processor.
There are no other changes.

Anything else we should know?

Building universal binaries requires Xcode Command Line Tools version 12.2 or later.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

Copy link
Member

@samsinsane samsinsane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue with supporting a universal binary for macOS is that supporting the M1 requires macOS 11.0 minimum. Should we continue to build an x86_64 only binary with whatever version of macOS we target, but also build a universal binary with an 11.0 requirement?

@tempura-sukiyaki
Copy link
Contributor Author

It may be a matter of opinion whether Premake needs to support universal binaries right now or not.
As long as Rosetta 2 is supported, I don't think there is any need to rush.
However, I think it will have to be done eventually.

@starkos
Copy link
Member

starkos commented May 22, 2021

ARM has definitely got momentum; we're probably going to have support it for all platforms soon. I don't want to require macOS 11.0 yet, so this will need to be a switch of some kind.

What about a new command line flag like --arm or --arch=arm to control the binary type? Something not tied to macOS so we can support ARM Linux & Windows too?

@tempura-sukiyaki
Copy link
Contributor Author

I wrote the source code to try it out.
How does it look like this?

master...tempura-sukiyaki:premake-arch

However, I do not have a Linux environment, so I have not been able to verify that this works correctly on Linux.

In Visual Studio, I think it might be better to ignore this option and always include all platforms.

master...tempura-sukiyaki:premake-arch2

@tempura-sukiyaki
Copy link
Contributor Author

I added the --arch option.

If you want to build ARM64 binaries, you can write the following.

make -f Bootstrap.mak osx PLATFORM=ARM64
nmake -f Bootstrap.mak windows PLATFORM=ARM64

Also, to build the universal binary on macOS, write the following

make -f Bootstrap.mak osx PLATFORM=Universal

On Linux, I didn't know how to specify the architecture, so I didn't do anything.

Adding the following statement to premake5.lua did not seem to work.

		filter { "system:linux", "options:arch=ARM" }
			architecture "ARM"

		filter { "system:linux", "options:arch=ARM64" }
			architecture "ARM64"

		filter { "system:linux", "options:arch=x86 or arch=Win32" }
			architecture "x86"

		filter { "system:linux", "options:arch=x86_64 or arch=x64" }
			architecture "x86_64"

Translated with www.DeepL.com/Translator (free version)

@nickclark2016
Copy link
Member

What's the status on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants