Skip to content

Instantly share code, notes, and snippets.

@makotokato
Last active February 22, 2021 19:57
Show Gist options
  • Save makotokato/5fb36750ff8c69bea88cd4fa9ad681a8 to your computer and use it in GitHub Desktop.
Save makotokato/5fb36750ff8c69bea88cd4fa9ad681a8 to your computer and use it in GitHub Desktop.
GeckoView Build On Apple Silicon

TL;DR

  • Actually, we don't support GeckoView build on Apple Sillicon simply yet. Although Rust has native binaries, we have to use some x86_64 tools for clang, OpenJDK and Python 2.7.
  • You can use https://github.com/google/android-emulator-m1-preview on macOS. But ./mach install doesn't detect this emulator now.
  • GV's unit tests doesn't work yet.

Step

  1. Set up development environment via https://bit.ly/36bUmEx
  2. Install OpenJDK (macOS x86_64) since it has no aarch64 packages.
  3. Add your rust target like aarch64-linux-android via rustup target add aarch64-linux-android
  4. Comment out https://searchfox.org/mozilla-central/rev/c8ce16e4299a3afd560320d8d094556f2b5504cd/python/mozboot/mozboot/osx.py#197 like "# sys.exit(1)"
  5. Run ./mach bootstrap --no-system-changes to install GV's build tools.
  6. Add the following lines on your mozconfig
ac_add_options --with-android-toolchain=$HOME/.mozbuild/android-ndk-r21d/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64
ac_add_options --with-android-lldb-server=$HOME/.mozbuild/android-ndk-r21d/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/9.0.8/lib/linux/aarch64/lldb-server
ac_add_options --with-libclang-path=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
  1. Run ./mach build

Install GeckoView example

./mach install doesn't work yet. But you can use adb commaned to install binary like adb install objdir/gradle/build/mobile/android/geckoview_example/outputs/apk/withGeckoBinaries/debug/geckoview_example-withGeckoBinaries-debug.apk.

Actually, Android emulator path isn't <Android SDK>/emulator now, you cannot use any unittests and we don't have aarch64 test image now.

Known issue

If you set HOST_CC and HOST_CXX to Xcode's clang, it requries -m to link additional libm. Don't use xcode's clang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment