Elm works perfectly fine via Rosetta on Apple Silicon

As I’ve seen nothing being discussed about this on the forum so I’d just like to post a small report (I hope it’s not out-of-topic, sorry and feel free to close if it is)

First of all: elm binary from official distribution works PERFECTLY FINE. If any of you are on a new Apple M1 machine and having trouble getting it to work, here’s what I did:

  1. Download the official build from GitHub https://github.com/elm/compiler/releases (uses the binary-for-mac-64-bit.gz option)
  2. Extracted the archive, cd to the folder and chmod +x elm
  3. Move the elm binary to node_modules/.bin folder in my project.
  4. Adds node_modules/.bin as first entry in my PATH environment variable to make sure this is the first binary anything will pick up.
  5. Runs parcel or webpack or whatever tool as usual.
  6. Things compile juuuusssst fineee :slight_smile: :slight_smile: :slight_smile:

It, of course, is running via the Rosetta 2 translator. If you run file elm on it this is returned (obviously):

» uname -m
arm64
» file ./node_modules/.bin/elm
./node_modules/.bin/elm: Mach-O 64-bit executable x86_64

So I wonder if it’s possible to get a native aarch64 build so the first thing I want to check is wether Haskell runs and unfortunately, seems it does not.

The information is here: https://doesitarm.com/app/haskell/ , that page links to this tracking issue on Haskell gitlab:

So I assumed Elm would also fail. Trying to install it via Homebrew (configured in arm64 mode, installing in /opt/homebrew) fails with an error while trying to ./configure GHC:

==> ./configure --prefix=/opt/homebrew/Cellar/ghc@8.8/8.8.4_1/libexec/integer-gmp --with-pic --d
Last 15 lines from /Users/chakrit/Library/Logs/Homebrew/ghc@8.8/01.configure:
2020-12-17 22:53:17 +0700

./configure
--prefix=/opt/homebrew/Cellar/ghc@8.8/8.8.4_1/libexec/integer-gmp
--with-pic
--disable-shared
--build=arm_vortex_tempest-apple-darwin20

checking build system type... Invalid configuration `arm_vortex_tempest-apple-darwin20': machine `arm_vortex_tempest-apple' not recognized
configure: error: /bin/sh ./config.sub arm_vortex_tempest-apple-darwin20 failed

Trying to install via yarn global add elm (which is actually just a downloader, which should work theoretically as the manual binary download does work)

It however fails with:

--------------------------------------------------------------------------------

Downloading Elm 0.19.1 from GitHub.

NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-undefined.gz
All this package does is download that file and put it somewhere.

--------------------------------------------------------------------------------

-- ERROR -----------------------------------------------------------------------

I ran into trouble decompressing the downloaded binary. It is saying:

Error: incorrect header check

NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-undefined.gz
All this package does is download that file and put it somewhere.

--------------------------------------------------------------------------------

Which, noting from the -undefined part in the library, someone (or me, if I have energy left for the day) should go and update the elm npm package to uses the x86_64 option for now if it detects darwin-arm64 or aarch64 somewhere.

So it looks like if you have CI/CD setup or a build script shared by multiple devs, you might want to update it to download the x86_64 build directly from GitHub instead to make sure there is minimal disruption.

If anyone was experimenting with Elm on arm64 machines, I’d love to hear/learn more about it.

If you’re looking to buy new Apple Macs to hack on node/elm, I’m happy to report that I’ve been working on it for a week (parcel+elm setup) and have yet to encounter any arm-specific issues : )

7 Likes

Yep that all seems right! I have a PR up on the compiler doing exactly what you described (: (there isn’t much activity, so I actually forked the npm module with the patch @ https://www.npmjs.com/package/elm-npm-m1 if others don’t want to change their npm workflow between now and an official arm Mac binary build)

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.