Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add darwin arm64 target #33

Closed
squash opened this issue Feb 16, 2021 · 24 comments
Closed

Add darwin arm64 target #33

squash opened this issue Feb 16, 2021 · 24 comments
Assignees
Labels
enhancement New feature or request

Comments

@squash
Copy link

squash commented Feb 16, 2021

Go 1.16 was released today with support for the new MacOS platform, darwin/arm64.

@Jacalz
Copy link
Member

Jacalz commented Feb 17, 2021

I think this might take a little time to get working. Firstly Fyne itself needs to support compiling in the Apple M1, see fyne-io/fyne#1739. There is a PR open that fixes it but it is not done and might require more thought to make sure that compiling for iOS still is compatible with older Go releases.

Then there is the issue with the licensing for the Apple SDK. I think it might require a new version and we cannot quite distribute that.

It will also of course require an update to Go 1.16 which has a couple points to consider before doing so. We are still on Go 1.14 as Go 1.15 drops support for one more MacOS release. The SDK that we are using is for the version that is being dropped and I don’t know if it will compile with newer Go versions. That requires testing, but assuming that it does work, upgrading should only be a matter of the team being okay with a MacOS version being dropped (as Go 1.16 does not drop any more versions).

I have perhaps painted a bit of a dark picture here, but it should all be solvable one way or another. It just requires some clever thinking and agreement with the team 🙂 We might end up having the user download the Apple SDK manually on to their computer (due to distribution issues with licensing).

I am curious as to what @lucor has to say about it. At the end of the day, he is the main developer and professional when it comes to fyne-cross 🙂

@Jacalz Jacalz added the enhancement New feature or request label Feb 17, 2021
@Jacalz
Copy link
Member

Jacalz commented Feb 17, 2021

I might also want to specify that I am personally very interested in this per Jacalz/rymdport#7.

@squash
Copy link
Author

squash commented Feb 20, 2021

Just as a bump, fyne-io/fyne#1739 was closed today with a fix in the develop branch.

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

I'll be spinning up a test image using Go 1.16 later today for some testing (just the Go update, not any arm64 support). Will update here with any developments.

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

Looks like darwin builds indeed can't compile with an updated Go version. I think we need to figure out something better.

cc @lucor

@andydotxyz
Copy link
Member

Did I misunderstand this message, or is it true that Go 1.16 does not work for darwin?

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

Did I misunderstand this message, or is it true that Go 1.16 does not work for darwin?

That's correct. Our macOS SDK is for 10.11 and later but Go 1.15 only support 10.12 and later, thus it cannot compile for Darwin on amd64. We'd need to update the SDK.

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

I can double check Go 1.15 tomorrow to make sure that it wasn't a bug in Go 1.16.

@andydotxyz
Copy link
Member

andydotxyz commented Feb 21, 2021

It works perfectly well with Go 1.15.
The macOS SDK is part of fyne package not part of the go compiler, so upgrading Go should not have changed anything.

My current build platform (compiles and packages correctly):

❯ go version
go version go1.15.7 darwin/amd64

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

I’m not saying that Go 1.15 doesn’t work on MacOS, I am saying that it doesn’t work with the SDK that we have in the fyne-cross docker image. That SDK is for 10.11 and I could not get fyne-cross to build using Go 1.16. As it was an error about linking to C-code I assumed that it was due to 10.11 no longer being supported as of Go 1.15 and later. Will check Go 1.15 in fyne-cross tomorrow and see if I find the same error happening there as well.

@andydotxyz
Copy link
Member

Aaah! That all makes sense :)

@lucor
Copy link
Member

lucor commented Feb 22, 2021

@Jacalz has reported all the issues regarding this activity, so no more to add there. I'd try just to recap the action items in order to figure out a possible way to get this sorted...

As reported above the major issue is with the last point due to the SDK licensing that does not allow to redistribuite the SDK into a docker image.

As discussed previously into the slack channel, one possible to solution is to have the final user to build itself a local copy of the macOS docker image.

First ideal comes in mind is to have a fyne-cross command that given a valid Apple developer account will download the SDK and build the docker image.

Since handling the auth on the Apple dev site could require some effort, probably as first step a command (or a bash script / make task) that builds the image using a local copy of the SDK already download by the user could be good enough :-)

@Jacalz
Copy link
Member

Jacalz commented Feb 22, 2021

@lucor Would it be possible to load the SDK from the computer at runtime without having to recompile the docker images? Compiling the images a takes a lot of time and it would be great if it could be avoided.

@lucor
Copy link
Member

lucor commented Feb 23, 2021

@Jacalz we could try something like that, but the great part of the time is spent to create the osx toolchain starting from the xcode package :(
Further details can be found at the osxcross project (the tool used to create the macOS Cross toolchain for Linux and *BSD) but basically the steps needed and that takes time are:

  • download xcode (~11Gb)
  • extract the macOS SDK
  • install dependencies required by osxcross
  • build OSXCross toolchain

Some time could be saved providing a base image with the desired version of Go and the required dependencies but IMO it will save only a small fraction of the total time...

I do not like the build all locally way too, especially for users that does not have a fast internet connection... but unless it is not possible to host the image or rely on a third-party one no other solutions comes in mind.

@lucor lucor self-assigned this Mar 7, 2021
lucor added a commit to lucor/fyne-io-fyne-cross that referenced this issue Mar 7, 2021
This commit add support for the darwin arm64 target.

Additionally provides:
- Update Go to v1.16.0
- Update fyne cli to v2.0.1
- Add darwin arm64 target
- Remove darwin 386 target

Fixes fyne-io#33
@lucor
Copy link
Member

lucor commented Mar 7, 2021

The PR #34 add support for darwin arm64 along with some other new stuff like Go v1.16.
Help with testing on that architecture is welcome :-)

@shawnbutts
Copy link

ideally, the darwin arm64 support would lead right into darwin universal. "native" apple apps don't require the user to have knowledge of which processor architecture they are on.

@Jacalz
Copy link
Member

Jacalz commented Mar 8, 2021

ideally, the darwin arm64 support would lead right into darwin universal. "native" apple apps don't require the user to have knowledge of which processor architecture they are on.

I’m not so sure about that. We are using a compiled language. If we want universal apps, we should just use interpreted languages like Python. Either way, I don’t think it’s anything that we can do anything about unless Go supports it.

@andydotxyz
Copy link
Member

@shawnbutts Yes, darwin apps (like our iOS apps) should be universal.
I don't know if this needs any additional support from Go to make this work - either way it is a separate issue from this one.

@andydotxyz
Copy link
Member

If we want universal apps, we should just use interpreted languages like Python.

Sorry but I disagree with this @Jacalz we can, and should, continue to make it easy for users to manager their apps without technical knowledge. Universal apps may be part of this. It's just a case of compiling in multiple architectures to a package - a solved problem.

@Jacalz
Copy link
Member

Jacalz commented Mar 9, 2021

I wasn’t talking about iOS apps running on M1, that is something that I think would be the future. I just meant general Go binaries that run on amd64 and arm64 (straight out of go build). That is something that I don’t see happening. Partly due to making binary sizes massive and partly due to Go dropping support for one macOS version each year (thus Go 1.22 being the last to support Darwin amd64, assuming that they don’t want to keep it). Either way, that’s probably a discussion for another time 🙂

@andydotxyz
Copy link
Member

I wasn’t talking about iOS apps running on M1

I understood this (as iOS running on M1 is something Apple supports rather than the compiler). I was merely using iOS as a comparison, as our iOS apps (and Android) (can) support multiple architectures.

@andydotxyz
Copy link
Member

thus Go 1.22 being the last to support Darwin arm64

Do you mean amd64 here? I doubt very much that Apple will remove amd support so fast - it will be many years in the transition, and there will be some years of support after the old machines are no longer built.

@lucor
Copy link
Member

lucor commented Mar 9, 2021

Having the possibility to create also a universal binary would be a nice to have.
We could expose it as an additional target, leaving at the end user the target choice: amd64, arm64 or universal.
Anyway as @andydotxyz said above, this requires further investigation and it is a separate issue from this one.

@lucor
Copy link
Member

lucor commented Apr 28, 2021

cross-compiling for darwin arm64 target is now available for testing in develop (#39)

@lucor lucor closed this as completed Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants