Skip to content

Commit

Permalink
mac: Switch all architectures to the macOS 11.0 SDK and Xcode 12
Browse files Browse the repository at this point in the history
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 <mark@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826252}
  • Loading branch information
markmentovai authored and Commit Bot committed Nov 11, 2020
1 parent 7230773 commit bc15834
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 97 deletions.
9 changes: 1 addition & 8 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ gclient_gn_args = [
'checkout_openxr',
'cros_boards',
'cros_boards_with_qemu_images',
'mac_xcode_version',
]


Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 0 additions & 13 deletions base/system/sys_info_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") ||
Expand Down
10 changes: 2 additions & 8 deletions build/config/mac/mac_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions build/mac/should_use_hermetic_xcode.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -43,18 +44,14 @@ 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')
if force_toolchain and args.platform == 'ios':
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:
Expand Down
88 changes: 46 additions & 42 deletions build/mac_toolchain.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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')
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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']

Expand All @@ -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)
Expand All @@ -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__':
Expand Down
5 changes: 1 addition & 4 deletions build_overrides/build.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions chrome/app/app-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@
<dict>
<key>MallocNanoZone</key>
<string>0</string>
<key>SYSTEM_VERSION_COMPAT</key>
<string>0</string>
</dict>
<key>LSFileQuarantineEnabled</key>
<true/>
Expand Down
16 changes: 5 additions & 11 deletions docs/mac_arm64.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/dom/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
#include <utility>
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit bc15834

Please sign in to comment.