From bc158344215ad8bc2592f76b52a26738e2ae6ada Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 11 Nov 2020 13:24:40 +0000 Subject: [PATCH] mac: Switch all architectures to the macOS 11.0 SDK and Xcode 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This deprecates the xcode_12_beta mac_xcode_version .gclient custom_vars setting. “xcode_12_beta” now points to the same hermetic toolchain package as “default”. “xcode_12_beta” is also deprecated in favor of “default”. A few easy users of xcode_12_beta have been transitioned to default, but most (including arm64 bot recipes) remain. A future follow-up will switch them back to default. Developers targeting arm64 will also need to remove this setting. In switching to the 11.0 SDK, it’s possible to remove a few hacks, mostly related to the operating system version number lies that the system would tell when built against the 10.15 SDK (and earlier). These hacks are removed. Bug: 1108831, 1108832, 1115294, 1146078 CQ-Include-Trybots: luci.chromium.try:mac-arm64-rel Change-Id: I86c7a698c7d68f3d42f93cf2410a7c540a66a82b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530914 Commit-Queue: Mark Mentovai Reviewed-by: Nico Weber Cr-Commit-Position: refs/heads/master@{#826252} --- DEPS | 9 +- base/system/sys_info_mac.mm | 13 --- build/config/compiler/BUILD.gn | 3 +- build/config/mac/mac_sdk.gni | 10 +-- build/mac/should_use_hermetic_xcode.py | 7 +- build/mac_toolchain.py | 88 ++++++++++--------- build_overrides/build.gni | 5 +- chrome/app/app-Info.plist | 2 - docs/mac_arm64.md | 16 ++-- .../blink/renderer/core/dom/document.cc | 2 +- tools/clang/scripts/build.py | 2 +- 11 files changed, 60 insertions(+), 97 deletions(-) diff --git a/DEPS b/DEPS index 64c8799eac3800..bc778a87ed6e72 100644 --- a/DEPS +++ b/DEPS @@ -45,7 +45,6 @@ gclient_gn_args = [ 'checkout_openxr', 'cros_boards', 'cros_boards_with_qemu_images', - 'mac_xcode_version', ] @@ -185,11 +184,6 @@ vars = { # instead of downloading the prebuilt pinned revision. 'llvm_force_head_revision': False, - # This can be overridden, e.g. with custom_vars, to download a nonstandard - # Xcode version in build/mac_toolchain.py - # instead of downloading the prebuilt pinned revision. - 'mac_xcode_version': 'default', - 'android_git': 'https://android.googlesource.com', 'aomedia_git': 'https://aomedia.googlesource.com', 'boringssl_git': 'https://boringssl.googlesource.com', @@ -4247,8 +4241,7 @@ hooks = [ 'name': 'mac_toolchain', 'pattern': '.', 'condition': 'checkout_mac', - 'action': ['python', 'src/build/mac_toolchain.py', - '--xcode-version', Var('mac_xcode_version')], + 'action': ['python', 'src/build/mac_toolchain.py'], }, { # Update the prebuilt clang toolchain. diff --git a/base/system/sys_info_mac.mm b/base/system/sys_info_mac.mm index 2efd4a395dd987..8ad6259924bcd0 100644 --- a/base/system/sys_info_mac.mm +++ b/base/system/sys_info_mac.mm @@ -61,19 +61,6 @@ *major_version = version.majorVersion; *minor_version = version.minorVersion; *bugfix_version = version.patchVersion; - - // TODO(https://crbug.com/1108832): If an app is built against a pre-macOS - // 11.0 SDK, macOS will lie as to what version it is, saying that it is macOS - // "10.16" rather than "11.0". The problem is that the "IsOS/IsAtLeastOS/ - // IsAtMostOS" functions are driven from the Darwin version number, which - // isn't lied about, and therefore the values returned by this function and - // those functions are inconsistent. Therefore, unlie about these values. - - if (*major_version == 10 && *minor_version >= 16) { - *major_version = *minor_version - 5; - *minor_version = *bugfix_version; - *bugfix_version = 0; - } } // static diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 9bc7dda39027fe..9d66490cdb555a 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -144,8 +144,7 @@ declare_args() { # so only enable them by default for mainstream build configs. enable_wmax_tokens = !is_official_build && - ((is_mac && target_cpu == "x64" && !use_system_xcode && - mac_xcode_version == "default") || + ((is_mac && target_cpu == "x64" && !use_system_xcode) || (is_linux && !is_chromeos && target_cpu == "x64") || (is_win && target_cpu == "x86") || (is_win && target_cpu == "x64") || (is_android && target_cpu == "arm") || diff --git a/build/config/mac/mac_sdk.gni b/build/config/mac/mac_sdk.gni index 09183cb65d03da..32596461e3206b 100644 --- a/build/config/mac/mac_sdk.gni +++ b/build/config/mac/mac_sdk.gni @@ -37,7 +37,7 @@ declare_args() { # The SDK version used when making official builds. This is a single exact # version, not a minimum. If this version isn't available official builds # will fail. - mac_sdk_official_version = "10.15" + mac_sdk_official_version = "11.0" # Production builds should use hermetic Xcode. If you want to do production # builds with system Xcode to test new SDKs, set this. @@ -113,13 +113,7 @@ if (use_system_xcode) { mac_bin_path = find_sdk_lines[1] } } else { - if (mac_xcode_version == "default") { - mac_sdk_version = mac_sdk_official_version - } else if (mac_xcode_version == "xcode_12_beta") { - mac_sdk_version = "11.0" - } else { - assert(false, "unknown mac_xcode_version $mac_xcode_version") - } + mac_sdk_version = mac_sdk_official_version _dev = _hermetic_xcode_path + "/Contents/Developer" _sdk = "MacOSX${mac_sdk_version}.sdk" mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk" diff --git a/build/mac/should_use_hermetic_xcode.py b/build/mac/should_use_hermetic_xcode.py index e7578fe8a521f0..77b0e803b642ee 100755 --- a/build/mac/should_use_hermetic_xcode.py +++ b/build/mac/should_use_hermetic_xcode.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + # Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -43,9 +44,6 @@ def _IsCorpMachine(): def main(): parser = argparse.ArgumentParser(description='Download hermetic Xcode.') parser.add_argument('platform') - parser.add_argument('--xcode-version', - choices=('default', 'xcode_12_beta'), - default='default') args = parser.parse_args() force_toolchain = os.environ.get('FORCE_MAC_TOOLCHAIN') @@ -53,8 +51,7 @@ def main(): return "3" allow_corp = args.platform == 'mac' and _IsCorpMachine() if force_toolchain or allow_corp: - if not mac_toolchain.PlatformMeetsHermeticXcodeRequirements( - args.xcode_version): + if not mac_toolchain.PlatformMeetsHermeticXcodeRequirements(): return "2" return "1" else: diff --git a/build/mac_toolchain.py b/build/mac_toolchain.py index 931f4fc20b8002..e263d63d7d28e9 100755 --- a/build/mac_toolchain.py +++ b/build/mac_toolchain.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + # Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -28,24 +29,16 @@ import subprocess import sys -# To build these packages, see comments in build/xcode_binaries.yaml +# This contains binaries from the Xcode 12.2 release candidate, along with the +# macOS 11 SDK (aka 12B5044c). To build these packages, see comments in +# build/xcode_binaries.yaml MAC_BINARIES_LABEL = 'infra_internal/ios/xcode/xcode_binaries/mac-amd64' -MAC_BINARIES_TAG = { - # This contains binaries from Xcode 12.1, along with the 10.15 SDK (aka - # 12A7403). - 'default': '77fpfpUrA6kBF3yEaMBEvWHOomBWqoiRT3bEJ4bXxvUC', - # This contains binaries from the Xcode 12.2 release candidate, along with - # the macOS 11 SDK (aka 12B5044c). - 'xcode_12_beta': 'UwKVijd1FvMzmCAjyoYq_sw6xXJZpw_mGBH420gwlrwC', -} - -# The toolchain will not be downloaded if the minimum OS version is not met. -# 17 is the major version number for macOS 10.13. -# 9E145 (Xcode 9.3) only runs on 10.13.2 and newer. -MAC_MINIMUM_OS_VERSION = { - 'default': [17], # macOS 10.13+ - 'xcode_12_beta': [19, 4], # macOS 10.15.4+ -} +MAC_BINARIES_TAG = 'UwKVijd1FvMzmCAjyoYq_sw6xXJZpw_mGBH420gwlrwC' + +# The toolchain will not be downloaded if the minimum OS version is not met. 19 +# is the major version number for macOS 10.15. 12B5044c (Xcode 12.2rc) only runs +# on 10.15.4 and newer. +MAC_MINIMUM_OS_VERSION = [19, 4] BASE_DIR = os.path.abspath(os.path.dirname(__file__)) TOOLCHAIN_ROOT = os.path.join(BASE_DIR, 'mac_files') @@ -59,10 +52,10 @@ PARANOID_MODE = '$ParanoidMode CheckIntegrity\n' -def PlatformMeetsHermeticXcodeRequirements(version): +def PlatformMeetsHermeticXcodeRequirements(): if sys.platform != 'darwin': return True - needed = MAC_MINIMUM_OS_VERSION[version] + needed = MAC_MINIMUM_OS_VERSION major_version = [int(v) for v in platform.release().split('.')[:len(needed)]] return major_version >= needed @@ -103,7 +96,7 @@ def PrintError(message): sys.stderr.flush() -def InstallXcodeBinaries(version, binaries_root=None): +def InstallXcodeBinaries(binaries_root=None): """Installs the Xcode binaries needed to build Chrome and accepts the license. This is the replacement for InstallXcode that installs a trimmed down version @@ -117,15 +110,14 @@ def InstallXcodeBinaries(version, binaries_root=None): os.makedirs(binaries_root) # 'cipd ensure' is idempotent. - args = [ - 'cipd', 'ensure', '-root', binaries_root, '-ensure-file', '-' - ] + args = ['cipd', 'ensure', '-root', binaries_root, '-ensure-file', '-'] - p = subprocess.Popen( - args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + p = subprocess.Popen(args, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) stdout, stderr = p.communicate(input=PARANOID_MODE + MAC_BINARIES_LABEL + - ' ' + MAC_BINARIES_TAG[version]) + ' ' + MAC_BINARIES_TAG) if p.returncode != 0: print(stdout) print(stderr) @@ -137,13 +129,13 @@ def InstallXcodeBinaries(version, binaries_root=None): # Accept the license for this version of Xcode if it's newer than the # currently accepted version. - cipd_xcode_version_plist_path = os.path.join( - binaries_root, 'Contents/version.plist') + cipd_xcode_version_plist_path = os.path.join(binaries_root, + 'Contents/version.plist') cipd_xcode_version_plist = plistlib.readPlist(cipd_xcode_version_plist_path) cipd_xcode_version = cipd_xcode_version_plist['CFBundleShortVersionString'] - cipd_license_path = os.path.join( - binaries_root, 'Contents/Resources/LicenseInfo.plist') + cipd_license_path = os.path.join(binaries_root, + 'Contents/Resources/LicenseInfo.plist') cipd_license_plist = plistlib.readPlist(cipd_license_path) cipd_license_version = cipd_license_plist['licenseID'] @@ -163,19 +155,25 @@ def InstallXcodeBinaries(version, binaries_root=None): # Use puppet's sudoers script to accept the license if its available. license_accept_script = '/usr/local/bin/xcode_accept_license.py' if os.path.exists(license_accept_script): - args = ['sudo', license_accept_script, '--xcode-version', - cipd_xcode_version, '--license-version', cipd_license_version] + args = [ + 'sudo', license_accept_script, '--xcode-version', cipd_xcode_version, + '--license-version', cipd_license_version + ] subprocess.check_call(args) return 0 # Otherwise manually accept the license. This will prompt for sudo. print('Accepting new Xcode license. Requires sudo.') sys.stdout.flush() - args = ['sudo', 'defaults', 'write', current_license_path, - 'IDEXcodeVersionForAgreedToGMLicense', cipd_xcode_version] + args = [ + 'sudo', 'defaults', 'write', current_license_path, + 'IDEXcodeVersionForAgreedToGMLicense', cipd_xcode_version + ] subprocess.check_call(args) - args = ['sudo', 'defaults', 'write', current_license_path, - 'IDELastGMLicenseAgreedTo', cipd_license_version] + args = [ + 'sudo', 'defaults', 'write', current_license_path, + 'IDELastGMLicenseAgreedTo', cipd_license_version + ] subprocess.check_call(args) args = ['sudo', 'plutil', '-convert', 'xml1', current_license_path] subprocess.check_call(args) @@ -189,16 +187,22 @@ def main(): return 0 parser = argparse.ArgumentParser(description='Download hermetic Xcode.') - parser.add_argument('--xcode-version', - choices=('default', 'xcode_12_beta'), - default='default') + parser.add_argument('--xcode-version', help='deprecated, do not use') args = parser.parse_args() - if not PlatformMeetsHermeticXcodeRequirements(args.xcode_version): + # Users in other repositories (v8, pdfium, webrtc) borrow Chromium's toolchain + # and depend on this script. Tolerate --xcode-version until all dependents are + # weaned. + if args.xcode_version is not None: + PrintError( + '%s: warning: --xcode-version is deprecated and will be removed' % + os.path.basename(__file__)) + + if not PlatformMeetsHermeticXcodeRequirements(): print('OS version does not support toolchain.') return 0 - return InstallXcodeBinaries(args.xcode_version) + return InstallXcodeBinaries() if __name__ == '__main__': diff --git a/build_overrides/build.gni b/build_overrides/build.gni index ae855e84055bfa..09bab2563bf2d0 100644 --- a/build_overrides/build.gni +++ b/build_overrides/build.gni @@ -62,10 +62,7 @@ declare_args() { if (is_apple && use_system_xcode == "") { _result = exec_script("//build/mac/should_use_hermetic_xcode.py", - [ - "--xcode-version=$mac_xcode_version", - target_os, - ], + [ target_os ], "value") assert(_result != 2, diff --git a/chrome/app/app-Info.plist b/chrome/app/app-Info.plist index 965c0e81f2fbb1..b52af9833fdafc 100644 --- a/chrome/app/app-Info.plist +++ b/chrome/app/app-Info.plist @@ -235,8 +235,6 @@ MallocNanoZone 0 - SYSTEM_VERSION_COMPAT - 0 LSFileQuarantineEnabled diff --git a/docs/mac_arm64.md b/docs/mac_arm64.md index 8c37b0e3886485..ee98a030ac7749 100644 --- a/docs/mac_arm64.md +++ b/docs/mac_arm64.md @@ -17,17 +17,11 @@ Building _for_ arm Macs You can build Chrome for arm macs on an Intel Mac. To build for arm64, you have to do 2 things: -1. use the `MacOSX11.0.sdk` that comes with - Xcode 12 beta. If you're on Google's corporate network, edit your `.gclient` - file and add this `custom_vars`: - - "custom_vars": { "mac_xcode_version": "xcode_12_beta" }, - - Then just run `gclient sync` and you'll automatically get that SDK and will - build with it. - - Otherwise, manually download and install the current Xcode 12 beta and make - it the active Xcode with `xcode-select`. +1. use the `MacOSX11.0.sdk` that comes with the + Xcode 12.2 release candidate. If you're on Google's corporate network, this + SDK is part of the hermetic toolchain and will be used automatically. + Otherwise, manually download and install this version of Xcode and make it + the active Xcode with `xcode-select`. 2. Add `target_cpu = "arm64"` to your `args.gn`. diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index 8623ed02df5bd7..999dcea3eb09c5 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc @@ -33,7 +33,7 @@ // instead of including more headers. If that is infeasible, adjust the limit. // For more info, see // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md -#pragma clang max_tokens_here 980000 +#pragma clang max_tokens_here 1000000 #include #include diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py index 22a73faaeb29e6..d4793c26811cd8 100755 --- a/tools/clang/scripts/build.py +++ b/tools/clang/scripts/build.py @@ -815,7 +815,7 @@ def main(): sys.path.insert(1, os.path.join(CHROMIUM_DIR, 'build')) import mac_toolchain LLVM_XCODE = os.path.join(THIRD_PARTY_DIR, 'llvm-xcode') - mac_toolchain.InstallXcodeBinaries('xcode_12_beta', LLVM_XCODE) + mac_toolchain.InstallXcodeBinaries(LLVM_XCODE) isysroot_11 = os.path.join(LLVM_XCODE, 'Contents', 'Developer', 'Platforms', 'MacOSX.platform', 'Developer', 'SDKs', 'MacOSX11.0.sdk')