Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Commit

Permalink
Teach our fork of the engine to build on Android arm32 (#5)
Browse files Browse the repository at this point in the history
This required conditionally linking against separate builds of
libupdater.a as well as providing a stub for getauxval.

If we find a way to move off of using ring (via rust-tls, via reqwests)
we could get rid of this.  More likely Flutter will just move to a
newer version of SDK/NDK:
flutter/flutter#82000
  • Loading branch information
eseidel authored and felangel committed Jun 8, 2023
1 parent e9233bc commit aea6b62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shell/platform/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ source_set("flutter_shell_native_src") {
"android",
"EGL",
"GLESv2",
"//flutter/updater/android_aarch64/libupdater.a",
]
if (target_cpu == "arm") {
libs += [ "//flutter/updater/android_arm/libupdater.a" ]
} else if (target_cpu == "arm64") {
libs += [ "//flutter/updater/android_aarch64/libupdater.a" ]
}
}

action("gen_android_build_config_java") {
Expand Down
16 changes: 16 additions & 0 deletions shell/platform/android/flutter_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ const flutter::Settings& FlutterMain::GetSettings() const {
return settings_;
}

// Old Android versions (e.g. the v16 ndk Flutter uses) don't always include a
// getauxval symbol, but the Rust ring crate assumes it exists:
// https://github.com/briansmith/ring/blob/fa25bf3a7403c9fe6458cb87bd8427be41225ca2/src/cpu/arm.rs#L22
// It uses it to determine if the CPU supports AES instructions.
// Making this a weak symbol allows the linker to use a real version instead
// if it can find one.
// BoringSSL just reads from procfs instead, which is what we would do if
// we needed to implement this ourselves. Implementation looks straightforward:
// https://lwn.net/Articles/519085/
// https://github.com/google/boringssl/blob/6ab4f0ae7f2db96d240eb61a5a8b4724e5a09b2f/crypto/cpu_arm_linux.c
#if defined(__ANDROID__) && defined(__arm__)
extern "C" __attribute__((weak)) unsigned long getauxval(unsigned long type) {
return 0;
}
#endif

// TODO: Move this out into a separate file?
void ConfigureShorebird(std::string android_cache_path,
flutter::Settings& settings,
Expand Down

0 comments on commit aea6b62

Please sign in to comment.