From a3417bea6de74d15966cedd30c3e497558fc77f2 Mon Sep 17 00:00:00 2001 From: George Wright Date: Tue, 29 Dec 2020 18:21:05 -0800 Subject: [PATCH 1/4] Support ARM64 iOS simulator builds --- build/config/BUILDCONFIG.gn | 6 +++++- build/toolchain/mac/BUILD.gn | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 44c276c80d..b43a3afb67 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -543,7 +543,11 @@ if (custom_toolchain != "") { import("//build/config/ios/ios_sdk.gni") # For use_ios_simulator host_toolchain = "//build/toolchain/mac:clang_$host_cpu" if (use_ios_simulator) { - set_default_toolchain("//build/toolchain/mac:ios_clang_x64") + if (target_cpu == "arm" || target_cpu == "arm64") { + set_default_toolchain("//build/toolchain/mac:ios_clang_arm_sim") + } else { + set_default_toolchain("//build/toolchain/mac:ios_clang_x64_sim") + } } else { set_default_toolchain("//build/toolchain/mac:ios_clang_arm") } diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index 6b898234aa..b87e3ba0e7 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -250,8 +250,22 @@ mac_toolchain("ios_clang_arm") { sysroot_flags = "-isysroot $ios_device_sdk_path -miphoneos-version-min=$ios_deployment_target" } -# Toolchain used for iOS simulator targets. -mac_toolchain("ios_clang_x64") { +# Toolchain used for iOS simulator targets (arm64). +mac_toolchain("ios_clang_arm_sim") { + toolchain_cpu = "arm" + toolchain_os = "mac" + # TODO(gw280): We have to use llvm from xcode until we upgrade our copy of llvm + ar = "ar" + cc = "clang" + cxx = "clang++" + ld = "clang++" + is_clang = true + # We have to ignore unknown options and range loop analysis as this isn't our expected toolchain + sysroot_flags = "-isysroot $ios_simulator_sdk_path -mios-simulator-version-min=$ios_deployment_target -Wno-unknown-warning-option -Wno-range-loop-analysis" +} + +# Toolchain used for iOS simulator targets (x64). +mac_toolchain("ios_clang_x64_sim") { toolchain_cpu = "x64" toolchain_os = "mac" prefix = rebase_path(llvm_bin_path, root_build_dir) From 8f51a47242ab2e5430f43f3f9f2147b02d313f21 Mon Sep 17 00:00:00 2001 From: George Wright Date: Fri, 22 Jan 2021 15:42:56 -0800 Subject: [PATCH 2/4] extra flags aren't necessary if `use_xcode` is set --- build/toolchain/mac/BUILD.gn | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index b87e3ba0e7..fe3a87fa4c 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -254,14 +254,19 @@ mac_toolchain("ios_clang_arm") { mac_toolchain("ios_clang_arm_sim") { toolchain_cpu = "arm" toolchain_os = "mac" - # TODO(gw280): We have to use llvm from xcode until we upgrade our copy of llvm - ar = "ar" - cc = "clang" - cxx = "clang++" - ld = "clang++" + if (!use_xcode) { + prefix = rebase_path(llvm_bin_path, root_build_dir) + ar = "$prefix/llvm-ar" + cc = "$prefix/clang" + cxx = "$prefix/clang++" + } else { + ar = "ar" + cc = "clang" + cxx = "clang++" + } + ld = cxx is_clang = true - # We have to ignore unknown options and range loop analysis as this isn't our expected toolchain - sysroot_flags = "-isysroot $ios_simulator_sdk_path -mios-simulator-version-min=$ios_deployment_target -Wno-unknown-warning-option -Wno-range-loop-analysis" + sysroot_flags = "-isysroot $ios_simulator_sdk_path -mios-simulator-version-min=$ios_deployment_target" } # Toolchain used for iOS simulator targets (x64). From 356dce2285e6b20e71487a5e45de9c5e52527fa7 Mon Sep 17 00:00:00 2001 From: George Wright Date: Fri, 22 Jan 2021 15:47:42 -0800 Subject: [PATCH 3/4] Set `use_xcode` if building for ARM64 simulator --- build/toolchain/clang.gni | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/toolchain/clang.gni b/build/toolchain/clang.gni index 021b141698..097b4ff384 100644 --- a/build/toolchain/clang.gni +++ b/build/toolchain/clang.gni @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/ios/ios_sdk.gni") # For use_ios_simulator + declare_args() { # Enable the optional type profiler in Clang, which will tag heap allocations # with the allocation type. @@ -26,5 +28,7 @@ declare_args() { # TODO(dnfield): We shouldn't need Xcode for bitcode_marker builds, but we do # until libpng and dart have explicitly added LLVM asm sections to their # assembly sources. https://github.com/flutter/flutter/issues/39281 - use_xcode = enable_bitcode + # TODO(gw280): Once our own copy of clang 12 is capable of building for arm64 simulator, + # we can safely remove the requirement that we use xcode for arm64 simulator builds. + use_xcode = enable_bitcode || (use_ios_simulator && (target_cpu == "arm" || target_cpu == "arm64")) } From 68607df1e1d7db211b378610b80b93d1bbffe00b Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 28 Jan 2021 15:13:07 -0800 Subject: [PATCH 4/4] Add issue link --- build/toolchain/mac/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn index fe3a87fa4c..742adcb71f 100644 --- a/build/toolchain/mac/BUILD.gn +++ b/build/toolchain/mac/BUILD.gn @@ -260,6 +260,8 @@ mac_toolchain("ios_clang_arm_sim") { cc = "$prefix/clang" cxx = "$prefix/clang++" } else { + # TODO: https://github.com/harfbuzz/harfbuzz/issues/2834 + # harfbuzz has a non-fatal warning right now with Xcode 12 ar = "ar" cc = "clang" cxx = "clang++"