0

[ios] Use symbolic links when using Goma and system Xcode

Goma RBE only supports paths that are relative to the source dir
while build not using Goma or using old Goma backend supports both
so always use symbolic link to system Xcode on iOS when using Goma.

This fix the compilation for people using Goma as Goma RBE is now
the default backend and without this change, the build would fall
back to local compilation, drastically slowing the build.

Stop using the ios_enable_relative_sdk_path and ios_use_goma_rbe
gn variables as they are now always expected to be `true`. Keep
the variable ios_use_goma_rbe to avoid breaking the bots that do
override the value but ignore it (bot set it to true anyway).

Bug: 1015730, 1154201
Change-Id: I728ebd960e73d5c4a021817a8acdde5e51f30181
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561844
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832765}
This commit is contained in:
Sylvain Defresne
2020-12-02 11:18:30 +00:00
committed by Chromium LUCI CQ
parent 580fdf2bd5
commit 01e2deded7
7 changed files with 47 additions and 26 deletions

@ -19,7 +19,7 @@ if (current_cpu == "arm" || current_cpu == "arm64") {
import("//build/config/arm.gni")
}
if (is_mac) {
if (is_apple) {
import("//build/config/mac/symbols.gni")
}
@ -216,7 +216,7 @@ declare_args() {
# official builders.
strip_absolute_paths_from_debug_symbols_default =
is_android || is_fuchsia || is_nacl || (is_win && use_lld) || is_linux ||
is_chromeos || (is_mac && !enable_dsyms) || ios_use_goma_rbe
is_chromeos || (is_apple && !enable_dsyms)
# If the platform uses stripped absolute paths by default, then we don't expose
# it as a configuration option. If this is causing problems, please file a bug.

@ -3,7 +3,9 @@
# found in the LICENSE file.
import("//build/config/ios/ios_sdk.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
import("//build_overrides/build.gni")
declare_args() {
# Enabling this option makes clang compile to an intermediate
@ -87,12 +89,12 @@ config("compiler") {
# that is iOS-only. Please see that target for advice on what should go in
# :runtime_library vs. :compiler.
config("runtime_library") {
# The variable ios_sdk_path may be relative to root_out_dir on the bots. As
# it is passed to the compiler via cflags, ldflags which do not rebase the
# values (since they are compiler flags, not paths), it may be required to
# rebase it. Use a local variable to avoid repeating the rebase invocation.
# The variable ios_sdk_path is relative to root_build_dir when using Goma RBE
# and system Xcode (since Goma RBE only supports paths relative to source).
# Rebase the value in that case since gn does not convert paths in compiler
# flags (since it is not aware they are paths).
_sdk_root = ios_sdk_path
if (ios_enable_relative_sdk_path) {
if (use_system_xcode && use_goma) {
_sdk_root = rebase_path(ios_sdk_path, root_build_dir)
}
@ -222,7 +224,7 @@ _xctrunner_path =
#
# To workaround this, add a target that pretends to create those files
# (but does nothing). See https://crbug.com/1061487 for why this is needed.
if (ios_use_goma_rbe) {
if (use_system_xcode && use_goma) {
action("copy_xctrunner_app") {
testonly = true
script = "//build/noop.py"
@ -251,7 +253,7 @@ action("xctest_runner_without_arm64e") {
xcode_version,
]
if (ios_use_goma_rbe) {
if (use_system_xcode && use_goma) {
deps = [ ":copy_xctrunner_app" ]
}
}

@ -5,7 +5,9 @@
import("//build/config/ios/config.gni")
import("//build/config/ios/ios_sdk_overrides.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
import("//build_overrides/build.gni")
assert(use_system_xcode, "Hermetic xcode doesn't work for ios.")
@ -58,9 +60,6 @@ declare_args() {
# You can also pass the value via "--args" parameter for "gn gen" command by
# using the syntax --args='additional_target_cpus=["arm"] target_cpu="arm64"'.
additional_target_cpus = []
# TODO(crbug.com/1015730): remove this flag because ios_use_goma_rbe covers.
ios_enable_relative_sdk_path = ios_use_goma_rbe
}
declare_args() {
@ -138,7 +137,7 @@ if (ios_sdk_path == "") {
ios_sdk_developer_dir,
]
}
if (ios_use_goma_rbe) {
if (use_system_xcode && use_goma) {
ios_sdk_info_args += [
"--create_symlink_at",
"sdk/xcode_links",

@ -5,7 +5,9 @@
import("//build/config/ios/ios_sdk.gni")
import("//build/config/mac/base_rules.gni")
import("//build/config/mac/symbols.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
import("//build_overrides/build.gni")
# Constants corresponding to the bundle type identifiers use application,
# application extension, XCTest and XCUITest targets respectively.
@ -435,9 +437,10 @@ template("create_signed_bundle") {
if (defined(invoker.extra_system_frameworks)) {
# All framework in extra_system_frameworks are expected to be system
# framework and the path to be already system absolute so do not use
# rebase_path here unless ios_enable_relative_sdk_path is trued.
# rebase_path here unless using Goma RBE and system Xcode (as in that
# case the system framework are found via a symlink in root_build_dir).
foreach(_framework, invoker.extra_system_frameworks) {
if (ios_enable_relative_sdk_path) {
if (use_system_xcode && use_goma) {
_framework_path = rebase_path(_framework, root_build_dir)
} else {
_framework_path = _framework
@ -1974,7 +1977,7 @@ template("ios_xcuitest_test_runner_bundle") {
"-o=" + rebase_path(_output_name, root_build_dir),
] + rebase_path(sources, root_build_dir)
if (ios_use_goma_rbe) {
if (use_system_xcode && use_goma) {
deps = [ "//build/config/ios:copy_xctrunner_app" ]
}
}
@ -2006,7 +2009,7 @@ template("ios_xcuitest_test_runner_bundle") {
outputs = [ "{{bundle_contents_dir}}/PkgInfo" ]
if (ios_use_goma_rbe) {
if (use_system_xcode && use_goma) {
public_deps = [ "//build/config/ios:copy_xctrunner_app" ]
}
}

@ -76,8 +76,11 @@ if (!use_system_xcode) {
]
}
# put system xcode under src to avoid absolute path.
if (use_system_xcode && ios_use_goma_rbe) {
# Goma RBE requires paths relative to source directory. When using system
# Xcode, this is done by creating symbolic links in root_build_dir. It is
# only supported when targetting iOS. The check uses `target_os` as this
# file is parsed for the host toolchain and `is_ios` checks `current_os`.
if (use_system_xcode && use_goma && target_os == "ios") {
sdk_info_args += [
"--get_sdk_info",
"--create_symlink_at",
@ -89,7 +92,7 @@ sdk_info_args += [ mac_sdk_name ]
_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
xcode_version = _mac_sdk_result.xcode_version
xcode_build = _mac_sdk_result.xcode_build
if (mac_sdk_path == "" && use_system_xcode && ios_use_goma_rbe) {
if (mac_sdk_path == "" && use_system_xcode && use_goma && target_os == "ios") {
mac_sdk_path = _mac_sdk_result.sdk_path
}

@ -25,14 +25,11 @@ declare_args() {
# TODO(crbug.com/726475): true if use_goma = true in the future.
use_java_goma = false
# Auto-configure for Goma RBE backend.
# TODO(crbug.com/1015730): true if use_goma = true in the future.
# Deprecated and ignored as Goma RBE is now the default. Still exists
# to avoid breaking the build on the bots. Will be removed when all
# bots have been configured to not set this variable.
ios_use_goma_rbe = -1
}
if (ios_use_goma_rbe == -1) {
ios_use_goma_rbe = is_ios && use_goma
}
assert(!is_win || !use_goma || is_clang,
"cl.exe does not work on goma, use clang")

@ -328,6 +328,23 @@ ask there. As mentioned above, be sure that the
[waterfall](https://build.chromium.org/buildbot/waterfall/) is green and the tree
is open before checking out. This will increase your chances of success.
### Debugging
To help with deterministic builds, and to work with Goma, the path to source
files in debugging symbols are relative to source directory. To allow Xcode
to find the source files, you need to ensure to have an `~/.lldbinit-Xcode`
file with the following lines into it (substitute {SRC} for your actual path
to the root of Chromium's sources):
```
script sys.path[:0] = ['{SRC}/tools/lldb']
script import lldbinit
```
This will also allow you to see the content of some of Chromium types in the
debugger like `base::string16`, ... If you want to use `lldb` directly, name
the file `~/.lldbinit` instead of `~/.lldbinit-Xcode`.
### Changing the version of Xcode
To change the version of Xcode used to build Chromium on iOS, please follow