From 0e4c3935c5ab00aeaacdd139421a3161ffa53971 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Sat, 5 Nov 2022 09:44:01 -0700 Subject: [PATCH] Narrow the scope of the Windows Android arm hack (flutter/engine#37125) --- DEPS | 2 +- engine/src/flutter/tools/gn | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index ad1194c877..03feafbca3 100644 --- a/DEPS +++ b/DEPS @@ -118,7 +118,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'ad96f00615dc306c22cc09d433eee50392f8033c', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '4099e11fffa406aaa13be8bd512fe5b0ad6262f6', # Fuchsia compatibility # diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index e231a78191..27f65988f5 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -329,15 +329,18 @@ def to_gn_args(args): gn_args['target_cpu'] = get_target_cpu(args) gn_args['dart_target_arch'] = gn_args['target_cpu'] - # No cross-compilation on Windows (for now). Use host toolchain that - # matches the bit-width of the target architecture. - if sys.platform.startswith(('cygwin', 'win')) and args.target_os != 'win': - cpu = cpu_for_target_arch(gn_args['target_cpu']) - # We explicitly allow arm64 native build. 'host_cpu' key may not exist. - if gn_args.get('host_cpu') == 'arm64' and gn_args['target_cpu'] == 'arm64': - cpu = 'arm64' - gn_args['host_cpu'] = cpu - gn_args['target_cpu'] = cpu + # We cannot cross-compile for 32 bit arm on a Windows host. We work around + # this by leaving 'target_cpu' and 'dart_target_arch' set to 'arm' so that + # Dart tools such as gen_snapshot that are built for the host will correctly + # target arm, but we hardcode the 'current_cpu' to always be the host arch + # so that the GN build doesn't go looking for a Windows arm toolchain, which + # does not exist. Further, we set the 'host_cpu' so that it shares the + # bitwidth of the 32-bit arm target. + if sys.platform.startswith( + ('cygwin', 'win') + ) and args.target_os == 'android' and gn_args['target_cpu'] == 'arm': + gn_args['host_cpu'] = 'x86' + gn_args['current_cpu'] = 'x86' if is_host_build(args) and gn_args['host_os'] == 'mac': # macOS host builds (whether x64 or arm64) must currently be built under