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

Error compiling fyne on Apple M1 arm64 #1739

Closed
sirkon opened this issue Jan 8, 2021 · 24 comments
Closed

Error compiling fyne on Apple M1 arm64 #1739

sirkon opened this issue Jan 8, 2021 · 24 comments
Labels
OS:macOS Tickets affecting only macOS

Comments

@sirkon
Copy link
Contributor

sirkon commented Jan 8, 2021

Cannot compile fyne_demo on Apple M1 (if it matters).

I am following the procedure described at the tour, got an error message:

GO111MODULE=on go get fyne.io/fyne/cmd/fyne_demo
go: downloading github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200625191551-73d3c3675aa3
# github.com/go-gl/gl/v3.1/gles2
go/pkg/mod/github.com/go-gl/gl@v0.0.0-20190320180904-bf2b1f2f34d7/v3.1/gles2/package.go:38:11: fatal error: 'KHR/khrplatform.h' file not found
 #include <KHR/khrplatform.h>
          ^~~~~~~~~~~~~~~~~~~
1 error generated.

Device (please complete the following information):

  • OS: MacOS
  • Version: Big Sur 11.1
  • Go version: go version go1.16beta1 darwin/arm64
  • Fyne version: v1.4.3
@andydotxyz
Copy link
Member

Do you have Xcode and the command line tools all installed?

We have not yet tested compiling on an M1 so this may be a new issue.
It refers to missing graphics headers, but it is possible that Apple removed them from the toolking in the transition to their new sillicon.

@andydotxyz andydotxyz added the OS:macOS Tickets affecting only macOS label Jan 8, 2021
@Jacalz
Copy link
Member

Jacalz commented Jan 8, 2021

Can you please update the issue with the contents from the issue template? The issue template is there for us to more easily be able to help. More specifically, I am curious about the Go version that you are using. Go 1.16 (which has yet to be released) is the first release with M1 support and the older versions do not support compilation for that target.

@sirkon
Copy link
Contributor Author

sirkon commented Jan 8, 2021

Added system and Golang info.

Do you have Xcode and the command line tools all installed?

Sure, everything is installed.

@andydotxyz
Copy link
Member

Hmm, looking closer it seems we are trying to load a GLES driver because it’s an arm machine. Apple must, if at al, be using core OpenGL for compatibility so we need an M1 specific compile option.
If you could try running any other OpenGL content it might confirm this suspicion.

@sirkon
Copy link
Contributor Author

sirkon commented Jan 9, 2021

Yeah, I can. Could you point an example to check this idea with?

@andydotxyz
Copy link
Member

I don't have a list personally - but I saw a few listed on Reddit: https://www.reddit.com/r/macgaming/comments/jvlpmi/stardew_valley_an_opengl_game_runs_fine_on_apple/

@sirkon
Copy link
Contributor Author

sirkon commented Jan 12, 2021

Used this tutorial: https://kylewbanks.com/blog/tutorial-opengl-with-golang-part-1-hello-opengl

It compiles and works with that triangle.

2021-01-12.10.23.35.mp4

@Jacalz
Copy link
Member

Jacalz commented Jan 14, 2021

It looks like glfw isn't working on M1 just yet. See this PR for more info: glfw/glfw#1833

@ipfans
Copy link

ipfans commented Jan 26, 2021

I think it is a long life time issue go-gl/gl#125

@andydotxyz
Copy link
Member

I think it is a long life time issue go-gl/gl#125

It might be the opposite issue - on that ticket they want to use GLES but it's not included, whereas the issue here we have is that when on arm we auto-detect GLES but we want to use OpenGL proper.

Could you please help us @sirkon, by inverting the "arm" flag in internal/painter/gl/gl_es.go and gl_core.go so just to test whether it works when it's switched to full GL instead of GLES?

@ipfans
Copy link

ipfans commented Jan 27, 2021

@andydotxyz @sirkon Thanks for your suggestion. With inverting the "arm" and "arm64" flag in internal/painter/gl/gl_es.go and gl_core.go, the program can build success, but still not start normally: it does not show main screen with some warnings and errors:

# fyne.io/fyne/v2/app
app_darwin.m:10:33: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here
app_darwin.m:11:32: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
app_darwin.m:17:33: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here
app_darwin.m:18:32: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
app_darwin.m:37:5: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here
app_darwin.m:37:66: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here
app_darwin.m:43:5: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
app_darwin.m:43:61: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
2021/01/27 14:16:00 PlatformError: Cocoa: Failed to find service port for display
2021/01/27 14:16:00 Fyne error:  window creation error
2021/01/27 14:16:00   Cause: APIUnavailable: NSGL: OpenGL ES is not available on macOS
2021/01/27 14:16:00   At: /Users/user/Desktop/fyne_demo/vendor/fyne.io/fyne/v2/internal/driver/glfw/window.go:1306

@sirkon
Copy link
Contributor Author

sirkon commented Jan 27, 2021

@andydotxyz confirm @ipfans report, it compiles but no GUI is shown with the same error message: "OpenGL ES not available on macOS"

@sirkon
Copy link
Contributor Author

sirkon commented Feb 2, 2021

BTW, returned back finally to my intel machine. Really like the overall feel of the library, just what is needed for my tasks, good job, thank you!

PS Hope to see working M1 sooner than later :)
PPS Intel feels slooow

@Virgil-N
Copy link

Virgil-N commented Feb 7, 2021

I have this problem too. I'm using mac M1.

@andydotxyz
Copy link
Member

If anyone is able to share access to an M1 it may get fixed sooner - because none of the developers currently have access.
(Sorry to ask! Otherwise we need to finance a purchase from our sponsorship contributions)

@andydotxyz
Copy link
Member

andydotxyz commented Feb 7, 2021

@ipfans, @sirkon Ah, there were more build tags - can you try toggling the arm value in the flags of ./internal/driver/glfw/glfw_es.go and ./internal/driver/glfw/glfw_core.go as well, that might work...?

@sirkon
Copy link
Contributor Author

sirkon commented Feb 7, 2021

And it works!

2021-02-07.15.36.36.mp4

PS A bit harder than just toggling arm tags. Got an idea though, just managed to enable _core and disable _es and that worked.

@sirkon
Copy link
Contributor Author

sirkon commented Feb 7, 2021

If anyone is able to share access to an M1 it may get fixed sooner - because none of the developers currently have access.
(Sorry to ask! Otherwise we need to finance a purchase from our sponsorship contributions)

Is it possible without a public IP? I guess I could share an access if it is possible somehow without a public address.

@andydotxyz
Copy link
Member

And it works!

This is fantastic news, thanks. Can you please share the diff here so we can work with it?
I would normally ask if you can open a PR but there is probably more work to do as this was mostly just to test what would work rather than the final solution.

Is it possible without a public IP? I

Not really, but don't worry - you have it working, so we can work with your differences and if you're able to test a patch once we have a PR shaped up that's just as good as direct access!

@sirkon
Copy link
Contributor Author

sirkon commented Feb 8, 2021

Made a PR #1922
Check it please

@Jacalz Jacalz changed the title fyne_demo compilation error Error compiling fyne on Apple M1 arm64 Feb 17, 2021
@andydotxyz
Copy link
Member

Fixed on develop

@daiwhea
Copy link

daiwhea commented Jun 24, 2021

For my old MBP, branch develop won't work. I created a vendor directory, and download develop branch in it. Then run commands below.

go mod vendor reports nothing. but when I try to run it, there is an error output below.

daiwhea$ go mod vendor
daiwhea$ go run GoStock.go
#github.com/go-gl/gl/v3.2-core/gl
vendor/github.com/go-gl/gl/v3.2-core/gl/package.go:40:11: fatal error: 'KHR/khrplatform.h' file not found
#include <KHR/khrplatform.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.

image

go version go1.16.5 darwin/amd64

@andydotxyz
Copy link
Member

Go mod vendor overwrites your vendor folder. And it is not needed for go 1.16. You need to update the version in your go.mod to head of develop branch and it should just work

@andydotxyz
Copy link
Member

andydotxyz commented Jun 24, 2021

FYI this may relate to #2282 - by calling go mod vendor locally you will probably find that it is removing the file (try git status). If that is the case then just get checkout (path to missing file) and it will work again. I have filed an issue upstream go-gl/gl#140.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:macOS Tickets affecting only macOS
Projects
None yet
Development

No branches or pull requests

6 participants