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

Building for apple silicon #92

Open
wilsonowilson opened this issue Sep 18, 2021 · 2 comments
Open

Building for apple silicon #92

wilsonowilson opened this issue Sep 18, 2021 · 2 comments

Comments

@wilsonowilson
Copy link

MacOS apps created by Nativeshell are optimized for Intel macs by default. Is there any way to create a universal binary for release and/or debug?

Screenshot 2021-09-18 at 17 30 22

@knopp
Copy link
Contributor

knopp commented Sep 18, 2021

The biggest issue with this right now is that Flutter engine does not have official arm64 build for macOS. I opened issue for this here but there haven't been much progress. Technically you could build engine yourself from scratch, in which case you can build for arm64 and cross compile for intel (or vice versa) and build the nativeshell app with custom engine (arm64 for arm64 build, intel for intel build) and then lipo the resulting binaries together. I've done it locally, it's doable, but it's quite a lot of work to do.

@eEQK
Copy link

eEQK commented Apr 6, 2022

Building the engine locally is actually easier now compared to last year since Flutter team is actively working on publishing apple silicon engine and also because flutter beta channel already ships arm64 dart.

Just follow these steps: https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-macos-or-linux

Remember to match kernel binary format version between the engine and flutter, for example for me master channel works with engine's branch flutter-2.12-candidate.11 (you will have to run gclient sync after changing the branch)

  1. Disable unit tests and some skia stuff

root: src/flutter

diff --git a/testing/testing.gni b/testing/testing.gni
index 4fd02403aa..40ca7afb39 100644
--- a/testing/testing.gni
+++ b/testing/testing.gni
@@ -12,7 +12,7 @@ is_aot_test =

 # Unit tests targets are only enabled for host machines and Fuchsia right now
 declare_args() {
-  enable_unittests = current_toolchain == host_toolchain || is_fuchsia
+  enable_unittests = false #current_toolchain == host_toolchain || is_fuchsia
 }

root: src/third_party/skia

diff --git a/BUILD.gn b/BUILD.gn
index d086f04a07..2ab968a942 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1136,9 +1136,9 @@ optional("raw") {
  public_defines = [ "SK_CODEC_DECODES_RAW" ]

  deps = [
-    "//third_party/dng_sdk",
+#    "//third_party/dng_sdk",
    "//third_party/libjpeg-turbo:libjpeg",
-    "//third_party/piex",
+#    "//third_party/piex",
  ]

  # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
  1. There will be an error saying that gen_snapshot is missing, just copy it to the clang directory:
$ cp out/mac_debug_arm64/gen_snapshot out/mac_debug_arm64/clang_x64/gen_snapshot
  1. Run ninja again and it should finish this time.

  2. Then create the link:

$ cd ~/dev/flutter/bin/cache/artifacts/engine
$ ln -s ~/dev/Projects/engine/src/out/mac_debug_arm64 darwin-arm64
  1. Run the app:
$ cargo run

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants