[CSHARP-4016] Update libmongocrypt C# bindings for macOS m1 Created: 18/Jan/22  Updated: 28/Oct/23  Resolved: 31/Aug/22

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.17.0

Type: Task Priority: Unknown
Reporter: Kevin Albertson Assignee: James Kovacs
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CSHARP-4189 Upgrade Cake to support Apple M1 Closed
Gantt Dependency
has to be done after MONGOCRYPT-372 Package Apple M1 support as Universal... Closed
Issue split
split from MONGOCRYPT-340 Add support for darwin-arm64 compilation Closed
Related
is related to CSHARP-4101 Update Snappy/Zstd to support M1 Closed
Case:
Backwards Compatibility: Fully Compatible

 Description   

Background
See MONGOCRYPT-340. Updating C# bindings to support macOS m1 build.

MONGOCRYPT-340 added the build-and-test-and-upload task. See [this PR](https://github.com/mongodb/libmongocrypt/pull/234#issue-1100755034) for a link to a patch build with the build-and-test-csharp task error logs.

Scope
TODO. This may require updating the build.cake script to add a download for macOS m1 (darwin arm64).



 Comments   
Comment by James Kovacs [ 31/Aug/22 ]

2.17.0 shipped libmongocrypt as a universal binary with both x64 and arm64 code forks. Testing on Apple M1 indicates that this was sufficient and no additional changes are required to make MongoDB.Libmongocrypt work on Apple M1.

Comment by James Kovacs [ 16/Mar/22 ]

Hi, vah@oveo.io,

We were blocked on MONGOCRYPT-372, but that work has been completed. Now it is just a matter of scheduling the work compared to other features. I don't have a release date for this feature, but we will likely do it along with updating our Snappy and Zstd wire protocol compression libraries as they require M1 support as well. (See CSHARP-4101.)

NOTE: .NET only supports M1 natively starting with .NET 6. If you are still building on .NET 5 or earlier, your .NET applications will run through Rosetta 2 and the x64 libmongocrypt.dylib will be cross-compiled automatically. Even if you are using .NET 6, you can target x64 and run through Rosetta 2 until we package libmongocrypt.dylib Universal binary with M1 support.

Sincerely,
James

Comment by Vadim Hatsura [ 16/Mar/22 ]

Hey, @James Jovacs

 

Do you know what is the blocker for this task?

Comment by James Kovacs [ 24/Jan/22 ]

On the M1, Intel applications - including .NET 5 and earlier - are cross-compiled through Rosetta2 which converts Intel machine code to ARM machine code. (The M1 - just like the A-series for iPhones and iPads - is a custom ARM processor.) .NET 6 supports the M1 and will run it natively without cross compilation through Rosetta2.

On OSX, we use dylib for compression and CSFLE. dylib is Apple’s version of DLLs (Windows) or .so (Linux). A dylib can contain machine code for multiple platforms. Right now our dylib packages only contain x86 and/or x64 code. When we recompile them to support M1, they will also contain ARM32 and/or ARM64 code. It will be a matter of ensuring that all our unmanaged dependencies are re-compiled with ARM support and testing them. The loader in the Darwin kernel should handle all the hard magic of ensuring that the right machine code from the binary is executed.

.NET applications will run natively on .NET 6 on the M1, but until we update our compression and CSFLE unmanaged dependencies to support the M1, users will be unable to use those features natively and would have to configure their .NET 6 applications to run through Rosetta2 (but only if they required compression or CSFLE).

Generated at Wed Feb 07 21:46:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.