Will R Work on Apple Silicon? R needs a Fortran 90 compiler

Discussed at Hacker News. It would be nice if Apple provided some funding for the gfortran port.

Will R Work on Apple Silicon?
by Tomas Kalibera and Simon Urbanek
First published: 2020/11/02

At WWDC 2020 earlier this year, Apple announced a transition from Intel to ARM-based processors in their laptops. This blog is about the prospects of when R will work on that platform, based on experimentation on a developer machine running A12Z, one of the “Apple silicon” processors.

The new platform will include Rosetta 2, a dynamic translation framework which runs binaries built for 64-bit Intel Macs using just-in-time, dynamic translation of binary code. The good news is that R seems to be working fine with the dynamic translation, so R users don’t need to worry even if they use current releases. However, the interesting question is whether R will also work natively. Native execution is expected to be faster, and the transition probably has to be done eventually, anyway.

The executive summary is: while there is currently no released Fortran compiler for the platform, a development version of GNU Fortran already seems to be working fine. There are some surprising results with NaN payload propagation leading to unexpected results when computing with numeric NAs, but these can be overcome by changing the mode of the floating-point unit, which has already been done in R-devel. More details follow in this post.

The NAG Fortran compiler also works there.

Concerning Intel macOS, gfortran can be installed via homebrew:

About homebrew transition to Apple Silicon:

1 Like

Apple went through this “translation” phase when they switched from PowerPC (or was it Motorola?) chips to Intel. The ARM chips are not scheduled for the normal-size laptops or the tower for some time. Still, the vendor of a particular Chip is on the hook to help GCC with the code-gen interface to their hardware, and Apple should definitely do this. I doubt they want performance numbers published based on the translated code. Besides, they have plenty of cash.

I’ve always wanted GCC to provide a .dmg file for gfortran that included the compiler and all the required libraries (including the OpenCoarrays stuff). Things like HomeBrew are fine for the home hobbist, but the corp security would likely not allow software like that to be installed on company laptops. As it stands now, installing gfortran from the GCC distribution is absolute torture. I spent the multiple days to install 6.3 and have never upgraded because of the pain. Apple software is supposed to be installed from a .dmg file. Apple needs to fund this if GCC won’t.

2 Likes

Well, GCC does not come with the Mac software - they supply CLANG for C and no Fortran. Likewise, there is no gmake, just the standard make. Nor configure, which is a profoundly defective piece of software anyway.

1 Like

See here for the ‘private development branch’ mentioned in the article linked in the original post:

Also, as Ondrej pointed out, see NAG’s announcement from a couple of days ago:

There appears to be a fair amount of interest in supporting Fortran on Apple silicon due to a number of Python libraries that require it. However there is unlikely to be any support from Apple towards this IMO.