From 7e581790bfa16cf58d2bc581adca4429080018de Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Tue, 20 Oct 2020 12:35:51 -0400 Subject: [PATCH] update build for Apple Silicon You can use this to cross complie from an x86_64 mac if you have at least XCode12 beta 2 installed, and you set target_cpu = "arm64" in your gn args. Change-Id: I3fcdcd162155ac0242c15260994de09177ff2f97 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328659 Commit-Queue: Herb Derby Reviewed-by: Mike Klein --- gn/BUILD.gn | 17 +++++++++++++++++ third_party/libjpeg-turbo/BUILD.gn | 2 +- third_party/zlib/BUILD.gn | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gn/BUILD.gn b/gn/BUILD.gn index 5ad8fd975c..a003a2ad37 100644 --- a/gn/BUILD.gn +++ b/gn/BUILD.gn @@ -254,6 +254,23 @@ config("default") { # /System/Library/Frameworks/foo.framework/foo are out of sync. # Falling back to library file for linking. ldflags += [ "-Wl,-w" ] + + # As of 11/2020, gn is an x86 binary and defaults the host_cpu to x86_64. + # This allows you to build arm64 mac binaries by setting target_cpu = "arm64" + if (current_cpu == "arm64") { + asmflags += [ + "-target", + "arm64-apple-macos11", + ] + cflags += [ + "-target", + "arm64-apple-macos11", + ] + ldflags += [ + "-target", + "arm64-apple-macos11", + ] + } } if (sanitize != "" && sanitize != "MSVC") { diff --git a/third_party/libjpeg-turbo/BUILD.gn b/third_party/libjpeg-turbo/BUILD.gn index 4cf94f26c2..052c0f72f6 100644 --- a/third_party/libjpeg-turbo/BUILD.gn +++ b/third_party/libjpeg-turbo/BUILD.gn @@ -95,7 +95,7 @@ if (skia_use_system_libjpeg_turbo) { "../externals/libjpeg-turbo/simd/arm/common/jidctint-neon.c", "../externals/libjpeg-turbo/simd/arm/common/jidctred-neon.c", ] - } else if (current_cpu == "arm64" && !is_ios && !is_win) { + } else if (current_cpu == "arm64" && !is_mac && !is_ios && !is_win) { sources += [ "../externals/libjpeg-turbo/simd/arm/arm64/jsimd.c", "../externals/libjpeg-turbo/simd/arm/arm64/jsimd_neon.S", diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index f3c02d0bc2..7ac10c9c65 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn @@ -40,7 +40,7 @@ if (skia_use_system_zlib) { defines += [ "ARMV8_OS_FUCHSIA" ] } else if (is_win) { defines += [ "ARMV8_OS_WINDOWS" ] - } else if (is_ios) { + } else if (is_ios || is_mac) { # iOS@ARM is a special case where we always have NEON but don't check # for crypto extensions. defines += [ "ARM_OS_IOS" ]