arduino-ide icon indicating copy to clipboard operation
arduino-ide copied to clipboard

Allow builds on M1 Macs

Open me-no-dev opened this issue 2 years ago • 12 comments

Motivation

The only thing preventing builds on M1 macs is failure in downloading arduino-language-server. While other downloads do not check the arch, it is checked here. Adding case for darwin-arm64 fixes the issue.

Change description

Adds case for darwin-arm64

Other information

None

Reviewer checklist

  • [x] PR addresses a single concern.
  • [x] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [x] PR title and description are properly filled.
  • [ ] Docs have been added / updated (for bug fixes / features)

me-no-dev avatar Mar 31 '22 15:03 me-no-dev

Related: https://github.com/arduino/arduino-ide/issues/666

kittaakos avatar Apr 01 '22 09:04 kittaakos

@me-no-dev, thanks for the contribution. We're also working on it. With your patch, the build might correctly download the LS, but it does not fix the M1 build issue in the long run. If we want to build a native M1 app on M1, the universal target is required for the electron-builder. However, if all is configured correctly, the packaging will fail with such an error:

fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: /private/var/folders/zw/1kzgfzm90gd5brlbb91y217m0000gn/T/electron-universal-dpvxj4/Tmp.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli and /Users/tooling/Desktop/a.kitta/arduino-ide/electron/build/dist/mac-universal--arm64/Arduino IDE.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli have the same architectures (x86_64) and can't be in the same fat output file
    at ChildProcess.<anonymous> (/Users/tooling/Desktop/a.kitta/arduino-ide/electron/build/node_modules/@malept/cross-spawn-promise/src/index.ts:172:16)

arduino-cli have the same architectures (x86_64) and can't be in the same fat output file

This 👆 shows that the M1 (arm64) IDE2 app strickly requires an arm64 CLI. It does not exist yet.

kittaakos avatar May 31 '22 14:05 kittaakos

@kittaakos agreed that this is not a long term solution, but was here to help ones that want to build on M1 currently :) Feel free to close

me-no-dev avatar May 31 '22 16:05 me-no-dev

was here to help ones that want to build on M1 currently :)

Thank you so much ❤️

Feel free to close

Let's leave it open. There is progress. We have some blockers, but we are working on the M1 support.

Related: https://github.com/arduino/arduino-ide/compare/main...kittaakos:m1

kittaakos avatar May 31 '22 16:05 kittaakos

Doesn't the CLI already use a recent version of GO that supports Apple Silicon?

Edivad99 avatar Jun 01 '22 07:06 Edivad99

@umbynos, could you please chime in and summarize what is missing on the CLI/LS part? We do not yet have a container for darwin/arm64 if I remember correctly.

Also, even if we can build the CLI on an M1 chip, it does not fit into the current GitHub Actions-based pipeline: https://github.com/actions/virtual-environments/issues/2187.

kittaakos avatar Jun 01 '22 07:06 kittaakos

At the current time, we do not have a way of building the arduino-cli using golang crosscompile because we need the support for CGO on macOS to be able to reset a board when flashing it

umbynos avatar Jun 07 '22 14:06 umbynos

Now that this PR has been closed is it possible to develop a dedicated version for Apple Silicon?

Edivad99 avatar Jun 28 '22 07:06 Edivad99

Hi @Edivad99, having a native Arduino CLI arm64 darwin build unfortunately was only a starting point. Some more action items are required. There are other binaries required by the ide to be able to run natively on M1:

  • Arduino Language server (should be pretty easy since we use the same containers as the CLI)
  • Arduino FW Uploader (we use go native build, should need a go version bump)
  • Clangd + Clang Format (these ones should be the difficult ones: as of now for macos we use the vms offered by github, so it's a native build. Maybe we could try to use our shiny crossbuild container to crosscompile, but this won't be easy)

umbynos avatar Jun 28 '22 10:06 umbynos

  • Clangd + Clang Format (these ones should be the difficult ones: as of now for macos we use the vms offered by github, so it's a native build. Maybe we could try to use our shiny crossbuild container to crosscompile, but this won't be easy)

For the time being, we could build it on M1 manually and upload the artifacts. I know this is suboptimal, but it could speed up things until we have all the workflows and pipelines running on an M1 container.

kittaakos avatar Aug 18 '22 09:08 kittaakos

any update on this?

lbibass avatar Sep 14 '22 18:09 lbibass

There are other binaries required by the ide to be able to run natively on M1:

  • Arduino Language server (should be pretty easy since we use the same containers as the CLI)
  • Arduino FW Uploader (we use go native build, should need a go version bump)
  • Clangd + Clang Format (these ones should be the difficult ones: as of now for macos we use the vms offered by github, so it's a native build. Maybe we could try to use our shiny crossbuild container to crosscompile, but this won't be easy)

Status update:

  • Arduino Language Server: implemented in https://github.com/arduino/arduino-language-server/pull/136 ✔️ (only misses a release)
  • Arduino FW Uploader: implemented in https://github.com/arduino/arduino-fwuploader/pull/144 :heavy_check_mark: (only misses a release)
  • Clangd + Clang Format :red_circle: (still to do)

umbynos avatar Sep 15 '22 14:09 umbynos

everything done, releases here:

umbynos avatar Oct 20 '22 14:10 umbynos

Upstream issues:

  • https://github.com/eclipse-theia/theia-blueprint/issues/204
  • https://github.com/eclipse-theia/theia/issues/10728

kittaakos avatar Oct 21 '22 12:10 kittaakos

Thank you for initiating the support of the M1 build. It was implemented in #1577.

Closing this PR as a duplicate.

kittaakos avatar Nov 02 '22 14:11 kittaakos