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

Mac: Automatically build Universal x86_64 / arm64 binaries #3956

Merged
merged 8 commits into from
Aug 16, 2020

Conversation

CharlieFenton
Copy link
Contributor

Mac: Automatically build:

  • Universal x86_64 / arm64 binaries on Xcode versions that support building both architectures
  • x86_64-only binaries on Xcode versions that support only x86_64
  • arm64-only binaries on Xcode versions that support only arm64.

CAUTION # 1: I don't have arm64 macintosh hardware so this has been tested only on an x86_64 system.
CAUTION # 2: This was developed on MacOS 11.0 beta 3 and Xcode 12.0 beta 2, not final release builds
CAUTION # 3: At this time OpenSSL does not yet provide a way to build for MacOS with arm64 architecture, so I implemented a temporary workaround, which may or may not work properly on arm64 Macs.

Fixes #3827

Apple has announced that they will be transitioning to all arm64 ("Apple Silicon") Macs over the next two years, with the first ones to be released at the end of 2020. Apple Silicon Macs will initially include an emulator or virtual machine capable of running x86_64 code, but these will run less efficiently than native arm64 binaries and this capability will be phased out over time.

At this time, some (but not all) builds of Xcode 12 support building binaries for both Intel x86_64 Macintoshes and Apple Silicon (arm64) Macs. While these will automatically build Xcode based projects as Universal Binaries containing both architectures, BOINC's third party dependent libraries use configure and make and so require additional effort to produce Universal Binaries. And BOINC code itself required a few modifications to be compatible with arm64 Macs.

This PR does the following:

  • Updates the build scripts for the dependent libraries c-ares, curl, freestyle, ftgl, openssl and wxWidgets to automatically build for x86-64 architecture, arm64 architecture, or both, depending on the capabilities of the Xcode version being used.

  • Eliminates obsolete build settings in the Xcode project which were incompatible with building for arm64.

  • Adds arm64-apple-darwin as a valid BOINC platform in addition to i686-apple-darwin and x86_64-apple-darwin. (Note that the 32-bit i686-apple-darwin platform is only available on versions of MacOS prior to OS 10.15.)

  • Updates the release script release_boinc.sh to name the directories containing the installer and associated files boinc_x.y.z_macOSX_x86_64boinc_x.y.z_macOSX_arm64 or boinc_x.y.z_macOSX_universal as appropriate. It similarly updates the release_brand.sh script to label its products with the appropriate architecture.

  • Updates other Macintosh-specific BOINC files for arm64 compatibility.

Charlie Fenton added 2 commits August 1, 2020 23:41
…ersions that support building both architectures, x86_64-only binaries on Xcode versions that support only x86_64 and arm64-only binaries on Xcode versions that support only arm64.

CAUTION #1: I don't have arm64 macintosh hardware so this has been tested only on an x86_64 system.
CAUTION #2: This was developed on MacOS 11.0 beta 3 and Xcode 12.0 beta 2, not final release builds
CAUTION #3: At this time OpenSSL does not yet provide a way to build for MacOS with arm64 architecture, so I implemented a temporary workaround, which may or may not work properly on arm64 Macs.
@CharlieFenton
Copy link
Contributor Author

Xcode 12 beta 3 warns that the deployment target is OS 10.7 but the minimum supported by this version of Xcode is OS 10.11, though it builds successfully. This makes me think that BOINC may not work properly under MacOS versions earlier than OS 10.11 7when we build with Xcode 12.

@codecov
Copy link

codecov bot commented Aug 2, 2020

Codecov Report

Merging #3956 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master    #3956   +/-   ##
=========================================
  Coverage     16.56%   16.56%           
  Complexity      752      752           
=========================================
  Files           134      134           
  Lines         13115    13115           
  Branches       1631     1631           
=========================================
  Hits           2172     2172           
  Misses        10811    10811           
  Partials        132      132           

Charlie Fenton added 3 commits August 4, 2020 05:17
…te PowerPC support.

Caution: we need to add code for arm64 CPU to get_cpu_info_mac() in hostinfo_unix.cpp
I have not removed is_native_i386_app() in app_start.cpp so it can be modified to identify arm64 apps
@CharlieFenton
Copy link
Contributor Author

This is as complete as possible without having an arm64 Mac to test with.

A couple more considerations:

  • We will need to add code for arm64 CPUs to the method get_cpu_info_mac(HOST_INFO& host) in hostinfo_unix.cpp. That file already has arm64 code for linux. I suspect we may be able to copy that code as a starting point for supporting arm64 Macs.

  • The method int is_native_i386_app(char*) in app_start.cpp and app.h was originally needed in the early years of Intel Macs, which had Apple's Rosetta emulator to run PowerPC code. It was needed because PowerPC apps emulated on i386 Macs crashed if running graphics. Apple's Rosetta PowerPC emulator was discontinued a long time ago, but the new arm64 Macs will have a new Rosetta emulator to run x86_64 apps.

If needed, I expect that the is_native_i386_app(char*) method will require little or no modification to test for x86_64 apps on arm64 Macs. We don't know whether or not this capability will be needed, so I have not removed it.

@CharlieFenton
Copy link
Contributor Author

Since @AenBleidd feels this PR needs review, and since Macs with arm CPUs will not be released for a few months, there may be a delay in merging this PR. But I expect that MacOS 11, which is well into beta testing, will be released soon.

So I have included two of the same files that are in this PR in a new PR #3963 because they are necessary for the BOINC screensaver coordinator to work properly under MacOS 11 and so should be included in the next release of BOINC for the Mac. The two files are clientscr/gfx_switcher.cpp and clientscr/screensaver.cpp.

@CharlieFenton CharlieFenton changed the title [WIP] Mac: Automatically build Universal x86_64 / arm64 binaries Mac: Automatically build Universal x86_64 / arm64 binaries Aug 14, 2020
@CharlieFenton
Copy link
Contributor Author

I feel it is important to merge this as soon as possible, and certainly within a very few days. Although more work may be needed for running on Apple Silicon (arm64) Macs, it is safe to release this code now, because none of the changes affecting arm64 will be included in a build with Xcode 11 or earlier. Only Xcode 12 will include the arm64 code in a build. I have tested this code on my Intel Mac under multiple versions of MacOS and found no problems.

I have removed the WIP from this PR because have done as much as possible without access to an arm64 Mac, but merging this code into master now will make it much easier to finalize arm64 support quickly when Apple starts selling arm64 Macs before the end of this year.

@AenBleidd has marked this as requiring review, but I don't know of anyone qualified to do that. Please do not let this PR sit in limbo if there is no one who can quickly perform a review.

@CharlieFenton
Copy link
Contributor Author

Closing and reopening to trigger CI Travis build

@AenBleidd
Copy link
Member

@davidpanderson, could you please review and merge this if you're ok with these changes?

@davidpanderson davidpanderson merged commit b2ca098 into master Aug 16, 2020
@AenBleidd AenBleidd added this to the Client Release 7.18 milestone Aug 17, 2020
@AenBleidd AenBleidd modified the milestones: Client Release 7.18, Client Release 7.18.0 Aug 31, 2020
@CharlieFenton CharlieFenton deleted the mac_build_arm64_x86_64_Universal branch September 1, 2020 00:27
@AenBleidd AenBleidd modified the milestones: Client Release 7.18.0, Client Release 7.16.11 Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Apple's transitioning of Macs to new ARM CPU & GPU
3 participants