Mac: Add ARM64 configuration support (see issue #2981)

Requires Xcode 12.2 and the MacOS 11.0 SDK. To generate ARM64 builds set
the CEF_ENABLE_ARM64=1 environment variable and replace all usage of
--x64-build with --arm64-build in script command-line arguments.
This commit is contained in:
Marshall Greenblatt 2020-11-20 16:00:56 -05:00
parent a584bd187b
commit 71179da2f6
8 changed files with 42 additions and 25 deletions

View File

@ -1272,7 +1272,10 @@ if (is_mac) {
sources = [ "libcef_dll/sandbox/sandbox_mac.mm" ]
# CEF sources use include paths relative to the CEF root directory.
include_dirs = [ "." ]
deps = [ "//sandbox/mac:seatbelt" ]
deps = [
"//build/config:executable_deps",
"//sandbox/mac:seatbelt"
]
}
}

View File

@ -12,7 +12,7 @@
# distribution include:
#
# Linux: Ninja, Unix Makefiles
# MacOS: Ninja, Xcode 8+
# MacOS: Ninja, Xcode 8+ (x86_64) or Xcode 12.2+ (ARM64)
# Windows: Ninja, Visual Studio 2015+
#
# Ninja is a cross-platform open-source tool for running fast builds using
@ -48,9 +48,10 @@
# libgtkglext1-dev (required by the cefclient target only)
#
# - MacOS requirements:
# Xcode 8 or newer building on MacOS 10.11 (El Capitan) or newer. Xcode 11.2
# and MacOS 10.14 are recommended. The Xcode command-line tools must also be
# installed. Only 64-bit builds are supported.
# Xcode 8 or newer building on MacOS 10.11 (El Capitan) or newer for x86_64.
# Xcode 12.2 or newer building on MacOS 10.15.4 (Catalina) or newer for ARM64.
# Only 64-bit builds are supported. The Xcode command-line tools must also be
# installed.
#
# - Windows requirements:
# Visual Studio 2015 Update 2 or newer building on Windows 7 or newer. Visual
@ -84,6 +85,15 @@
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a MacOS build using an ARM64 CEF binary distribution:
# Using the Xcode IDE:
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
# Open build\cef.xcodeproj in Xcode and select Product > Build.
#
# Using Ninja:
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
# > ninja cefclient cefsimple
#
# To perform a Windows build using a 32-bit CEF binary distribution:
# Using the Visual Studio 2019 IDE:
# > cmake -G "Visual Studio 16" -A Win32 ..

View File

@ -328,6 +328,8 @@ if(OS_MAC)
# Target architecture.
if(PROJECT_ARCH STREQUAL "x86_64")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
elseif(PROJECT_ARCH STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64")
else()
set(CMAKE_OSX_ARCHITECTURES "i386")
endif()

View File

@ -921,7 +921,8 @@ parser.add_option(
'--distrib-subdir-suffix',
dest='distribsubdirsuffix',
default='',
help='CEF distrib dir name suffix, child of chromium/src/cef/binary_distrib')
help='CEF distrib dir name suffix, child of chromium/src/cef/binary_distrib'
)
(options, args) = parser.parse_args()
@ -1032,16 +1033,11 @@ if options.armbuild:
print('The ARM build option is only supported on Linux.')
sys.exit()
if options.arm64build:
if platform != 'linux' and platform != 'windows':
print('The ARM64 build option is only supported on Linux and Windows.')
sys.exit()
deps_file = 'DEPS'
if platform == 'mac' and not options.x64build:
if platform == 'mac' and not (options.x64build or options.arm64build):
print('32-bit MacOS builds are not supported. ' +
'Add --x64-build flag to generate a 64-bit build.')
'Add --x64-build or --arm64-build flag to generate a 64-bit build.')
sys.exit()
# Platforms that build a cef_sandbox library.

View File

@ -99,7 +99,7 @@ class cef_json_builder:
@staticmethod
def get_platforms():
""" Returns the list of supported platforms. """
return ('linux32', 'linux64', 'linuxarm', 'linuxarm64', 'macosx64',
return ('linux32', 'linux64', 'linuxarm', 'linuxarm64', 'macosarm64', 'macosx64',
'windows32', 'windows64')
@staticmethod

View File

@ -26,7 +26,7 @@ cefclient.app/
cef_extensions.pak <=====^
devtools_resources.pak <=^
icudtl.dat <= unicode support
snapshot_blob.bin, v8_context_snapshot.bin <= V8 initial snapshot
snapshot_blob.bin, v8_context_snapshot.[x86_64|arm64].bin <= V8 initial snapshot
en.lproj/, ... <= locale-specific resources and strings
Info.plist
cefclient Helper.app/

View File

@ -327,11 +327,11 @@ def ValidateArgs(args):
windows_sdk_path = GetArgValue(args, 'windows_sdk_path')
# Target CPU architecture.
# - Windows supports "x86" and "x64".
# - Mac supports only "x64".
# - Windows supports "x86", "x64" and "arm64".
# - Mac supports "x64" and "arm64".
# - Linux supports only "x64" unless using a sysroot environment.
if platform == 'mac':
assert target_cpu == 'x64', 'target_cpu must be "x64"'
assert target_cpu in ('x64', 'arm64'), 'target_cpu must be "x64" or "arm64"'
elif platform == 'windows':
assert target_cpu in ('x86', 'x64',
'arm64'), 'target_cpu must be "x86", "x64" or "arm64"'
@ -548,6 +548,8 @@ def GetAllPlatformConfigs(build_args):
supported_cpus.append('arm64')
elif platform == 'mac':
supported_cpus = ['x64']
if os.environ.get('CEF_ENABLE_ARM64', '') == '1':
supported_cpus.append('arm64')
else:
raise Exception('Unsupported platform')

View File

@ -381,7 +381,8 @@ def combine_libs(platform, build_dir, libs, dest_lib):
# Create an intermediate object file that combines all other object files.
# Symbols not identified above will be made private (local).
intermediate_obj = os.path.splitext(dest_lib)[0] + '.o'
cmdline = 'ld -arch x86_64 -r -o "%s"' % intermediate_obj
arch = 'arm64' if options.arm64build else 'x86_64'
cmdline = 'ld -arch %s -r -o "%s"' % (arch, intermediate_obj)
for symbol in symbols:
cmdline += ' -exported_symbol %s' % symbol
@ -410,6 +411,10 @@ def combine_libs(platform, build_dir, libs, dest_lib):
# Verify that no C++ symbols are imported by the archive file. If the
# archive imports C++ symbols and the client app links an incompatible C++
# library, the result will be undefined behavior.
# For example, to avoid importing libc++ symbols the cef_sandbox target
# should have a dependency on libc++abi. This dependency can be verified
# with the following command:
# gn path out/[config] //cef:cef_sandbox //buildtools/third_party/libc++abi
print('Verifying imported (undefined) symbols...')
undefined_symbols = get_undefined_symbols(dest_lib)
cpp_symbols = list(
@ -565,10 +570,6 @@ if options.armbuild and platform != 'linux':
print_error('--arm-build is only supported on Linux.')
sys.exit()
if options.arm64build and not platform in ('linux', 'windows'):
print_error('--arm64-build is only supported on Linux and Windows.')
sys.exit()
if options.sandbox and not platform in ('mac', 'windows'):
print_error('--sandbox is only supported on macOS and Windows.')
sys.exit()
@ -632,8 +633,11 @@ else:
output_dir_base = 'cef_binary_' + cef_ver
if options.distribsubdir == '':
# For backwards compatibility keep the old default directory name on mac.
platform_name = 'macosx' if platform == 'mac' else platform
if platform == 'mac':
# For backwards compatibility keep the old default directory name on mac.
platform_name = 'macos' + ('x' if platform_arch == '64' else '')
else:
platform_name = platform
output_dir_name = output_dir_base + '_' + platform_name + platform_arch
if options.distribsubdirsuffix != '':