[MONGOCRYPT-372] Package Apple M1 support as Universal Binary Created: 24/Jan/22  Updated: 28/Oct/23  Resolved: 03/Feb/22

Status: Closed
Project: Libmongocrypt
Component/s: C library
Affects Version/s: None
Fix Version/s: 1.3.1

Type: Improvement Priority: Major - P3
Reporter: James Kovacs Assignee: Kevin Albertson
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by JAVA-4517 Unable to use client side field level... Closed
Gantt Dependency
has to be done before CSHARP-4016 Update libmongocrypt C# bindings for ... Closed
Related
related to MONGOCRYPT-340 Add support for darwin-arm64 compilation Closed
is related to NODE-3631 Install of mongocrypt fails on M1 Closed

 Description   

MONGOCRYPT-340 added support for Apple's M1 processor. Currently we ship two dylibs for MacOS - one for x64 (aka Intel) and one for ARM64 (aka M1). It would be preferable to ship a single Universal Binary, which contains both the x64 and ARM64 code in a single dylib. Darwin's loader will then choose the appropriate CPU architecture when loading the dylib.

What is the advantage of shipping CSFLE as a universal binary compared to shipping two CPU-specific dylibs? The work required to consume CSFLE on MacOS is significantly reduced. Our drivers (or shims) currently detect whether they are running on MacOS and load the dylib already. Now all drivers/shims must be updated to not only detect MacOS, but also x64 or ARM64, and then load the correct dylib. With a universal binary, drivers/shims load the dylib as they always have and Darwin's loader sorts out whether to run the x64 or ARM64 code. In theory, each driver will only need to be tested with the CSFLE universal binary, but won't need additional code changes.

Universal Binaries can be created for apps, extensions, dylibs, etc. To build a Universal Binary, additional compiler options can be provided to compile for multiple architectures or separate architecture-specific builds can be combined using the lipo tool. Universal Binaries supporting both x64 and ARM64 can be created on both Intel and M1 Macs, but the ARM64 slice can only be debugged on a M1 Mac. For more information, see Building a Universal macOS Binary in Apple's documentation.

NOTE: Drivers may have other unmanaged dependencies that will have to be recompiled as universal binaries to enable full M1 support. For example, the .NET/C# driver uses unmanaged libraries for Snappy and zstd, which would need to be updated. Supporting CSFLE as a Universal Binary is only one step.



 Comments   
Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: MONGOCRYPT-372 make macos M1 builds universal builds (#238)
Branch: master
https://github.com/mongodb/libmongocrypt/commit/404f4c43aa09197acb0cbfd95dabfb98a39b9b84

Comment by Kevin Albertson [ 27/Jan/22 ]

PR: https://github.com/mongodb/libmongocrypt/pull/238

Generated at Thu Feb 08 09:08:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.