MacOS Apple Silicon MDSplus Build
Affiliation DIII-D
Description Many of our users prototype their systems on their personal devices. Many scientific users (including myself) make usage of Apple's new M1 and M2 chips. Attempting to use MDSplus on these devices requires the usage of virtual machines, which creates a significant barrier to entry (in addition to being glitchy). It would be worth shipping a build of MDSplus for Apple Silicon. Happy to provide further information if that would be helpful.
Apple Silicon (the M1 and M2 CPUs) are based on the ARM architecture (with customizations made by Apple).
We presently have an experimental build of MDSplus for aarch64 (aka arm64). And that build does work when run in ARM-based Linux VMs (created with VMware Fusion) that are hosted on a Mac with an M2 CPU.
And we have done exploratory work to create a MDSplus build for MacOS running on M1 and M2 CPUs.
However, the initial release probably won't include the interface to LabView because MathWorks has not yet ported their software to Apple Silicon. (Presently, MathWorks uses Apple's Rosetta emulator to run x86 versions of LabView on Apple Silicon.)
Creating a MDSplus build for MacOS on Apple Silicon will be done in phases:
- finish testing MDSplus on
aarch64 - manually build MDSplus on MacOS for M2 and release that build
- upgrade the build system to use the new Mac M2, so that builds are done automatically
An experimental (and incomplete) port to Apple Silicon has bumped into the file locking problem with MacOS Ventura (issue #2599). That is a blocking issue. So now shifting focus to fixing that bug.
Using the LLDB debugger, have confirmed that segfaults in Apple Silicon MacOS Ventura were caused by va_arg arguments being passed incorrectly. Instead of the variable list of arguments being passed on the stack, they were instead being passed in the registers. (The ABI for Apple Silicon MacOS is a bit different than that for Intel MacOS.) Fix involves changing some extern declarations of various variadic functions.
For example, in TclDecompile.c, the following change eliminated the segfault on mdstcl decompile <node_path>
// extern int TdiCompile(); -- original line commented out
extern int TdiCompile(struct descriptor *, ...); // corrected line
Based on the number of failing C and Python test cases, there are probably another ~20 extern function declarations that need to be fixed. However, now that the root cause is known, these edits should go quickly.
The port to Apple Silicon MacOS will touch many files. (Presently at ~100 changes, with many more still to do.) Although the vast majority of changes are trivial (just editing externs as shown in the previous post), nonetheless touching so many files could affect all platforms. Thus, thorough testing will be needed when the Apple Silicon MacOS changes are eventually merged into the alpha branch.
The Apple Silicon MacOS port is now passing ~80% of the test suite. And presently involves ~125 changes spread across ~110 source files. (However, most of the changes are simple edits to extern statements.). Current plan is to achieve ~95% pass rate on the tests, and then submit several PRs to merge the changes into the alpha branch. And of course before submitting the PRs, will also be confirming that the changes don't cause bugs in MDSplus on Windows and Linux.
@mwinkel-dev This seems pretty awesome... can I now use macports to try downloading the new build?
Accidentally closed this issue on 5-Sep-2023. Still working on the port to Apple Silicon.
Hi @ModestMC -- The Apple Silicon MacOS Ventura port is still in flux. Likely will be a few more weeks before I am ready to publish a "preview" branch.
Presently, the Apple Silicon port fails 14 tests. After I investigate those issues, I will review the details with Stephen so that we can assess the impact those failures will have on users. After the Apple Silicon port passes muster with the MDSplus team, then I'll make the preview branch so that you (and others) can experiment with the Apple Silicon prototype.
Currently am wrapping up the changes for Intel macOS Ventura so that they get folded into the forthcoming CMake build system. It is important for the Intel macOS Ventura code to be solid, because in some aspects it is a foundation for the Apple Silicon port.
The Apple Silicon port is complicated because macOS uses a different ABI on M1 / M2 CPUs than on Intel CPUs. The new ABI might impose some limitations on a few MDSplus features. (Will know more after I investigate the 14 failing tests.)
@mwinkel-dev, any further progress on this issue? Thanks for all your hard work on this! Looking forward to MDSplus deployment on Apple Silicon.
Hi @mrclary -- Unfortunately, the Apple Silicon port has languished for months. It was eclipsed by other "US Priority" bugs that were more urgent (i.e., needed for the upcoming campaign at the DIII-D tokamak). However, now that the urgent bug backlog has been dealt with, I will be resuming work on the Apple Silicon port soon.
Whenever you want to know about the progress, it is A-OK to post here and request a status update.