[build] Re-add linker flags to create empty section in AOT runtime.

To avoid these flags being applied to unexpected build rules, we
separate them out into a separate config that is then pulled in
explicitly in the `dart_precompiled_runtime{,_product}` executable
rules. Only those two executables need the additional empty section:
the product version because it becomes `dartaotruntime` in the SDK
bundle, and the non-product version because some of our tests build
standalone executables using it.

The linker flags were originally removed due to
https://github.com/flutter/flutter/issues/112687.
With the recent removal of bitcode support from Flutter (see
https://github.com/flutter/flutter/issues/107883), I can build
the `ios_release` target locally without any issue.

This also reverts the clang DEPS changes from CL 256208 (again).

TEST=pkg/dartdev/test/commands/compile_test

Bug: https://github.com/dart-lang/sdk/issues/49783
Cq-Include-Trybots: luci.dart.try:analyzer-mac-release-try,dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try
Change-Id: Ie46402ec2eeda23109247eb9d7a64935ec2052cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262429
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland 2022-10-07 09:26:18 +00:00 committed by Commit Queue
parent 97cdb043da
commit 9df6656aa9
7 changed files with 62 additions and 31 deletions

17
DEPS
View file

@ -74,8 +74,8 @@ vars = {
# The list of revisions for these tools comes from Fuchsia, here:
# https://fuchsia.googlesource.com/integration/+/HEAD/toolchain
# If there are problems with the toolchain, contact fuchsia-toolchain@.
"clang_revision": "c2592c374e469f343ecea82d6728609650924259",
"gn_revision": "d7c2209cebcfe37f46dba7be4e1a7000ffc342fb",
"clang_revision": "60d276923902051192eba692e5312e605c9d9f65",
"gn_revision": "0bcd37bd2b83f1a9ee17088037ebdfe6eab6d31a",
# Ninja, runs the build based on files generated by GN.
"ninja_tag": "version:2@1.11.1.chromium.4",
@ -474,8 +474,7 @@ deps = {
"version": "git_revision:" + Var("clang_revision"),
},
],
# TODO(https://fxbug.dev/73385): Use arm64 toolchain on arm64 when it exists.
"condition": "host_cpu == x64 and host_os == mac or host_cpu == arm64 and host_os == mac",
"condition": "host_os == mac", # On ARM64 Macs too because Goma doesn't support the host-arm64 toolchain.
"dep_type": "cipd",
},
Var("dart_root") + "/buildtools/win-x64/clang": {
@ -498,6 +497,16 @@ deps = {
"condition": "host_os == 'linux' and host_cpu == 'arm64'",
"dep_type": "cipd",
},
Var("dart_root") + "/buildtools/mac-arm64/clang": {
"packages": [
{
"package": "fuchsia/third_party/clang/mac-arm64",
"version": "git_revision:" + Var("clang_revision"),
},
],
"condition": "host_os == 'mac' and host_cpu == 'arm64'",
"dep_type": "cipd",
},
Var("dart_root") + "/third_party/webdriver/chrome": {
"packages": [

View file

@ -2,9 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../../toolchain/goma.gni")
_toolchain_cpu = host_cpu
if (host_os == "mac") {
# TODO(https://fxbug.dev/73385): Use arm64 toolchain on arm64 when it exists.
if (host_os == "mac" && use_goma) {
# Goma does not support ARM64.
_toolchain_cpu = "x64"
}

View file

@ -377,7 +377,10 @@ config("compiler") {
} else if (is_linux) {
toolchain_stamp_file =
"//buildtools/linux-x64/clang/.versions/clang.cipd_version"
} else {
} else if (is_mac && host_cpu == "arm64") {
toolchain_stamp_file =
"//buildtools/mac-arm64/clang/.versions/clang.cipd_version"
} else if (is_mac) {
toolchain_stamp_file =
"//buildtools/mac-x64/clang/.versions/clang.cipd_version"
}
@ -548,6 +551,7 @@ if (is_win) {
"-Wno-microsoft-unqualified-friend",
"-Wno-unknown-argument", # icu
"-Wno-unused-value", # crashpad
"-Wno-deprecated-non-prototype", # zlib
]
} else {
default_warning_flags += [
@ -579,6 +583,7 @@ if (is_win) {
default_warning_flags += [
"-Wno-tautological-constant-compare",
"-Wno-unused-but-set-variable", # icu
"-Wno-deprecated-non-prototype", # zlib
]
} else {
default_warning_flags +=

View file

@ -20,6 +20,15 @@ if (use_goma) {
goma_prefix = ""
}
# Goma doesn't support the host-arm64 toolchain, so continue using Rosetta.
if (host_cpu == "arm64" && !use_goma) {
rebased_clang_dir =
rebase_path("//buildtools/mac-arm64/clang/bin", root_build_dir)
} else {
rebased_clang_dir =
rebase_path("//buildtools/mac-x64/clang/bin", root_build_dir)
}
# Shared toolchain definition. Invocations should set toolchain_os to set the
# build args in this definition.
template("mac_toolchain") {
@ -211,28 +220,10 @@ template("mac_toolchain") {
}
}
# Toolchain used for Mac host targets.
mac_toolchain("clang_x64") {
toolchain_cpu = "x64"
toolchain_os = "mac"
prefix = rebase_path("//buildtools/mac-x64/clang/bin", root_build_dir)
cc = "${goma_prefix}$prefix/clang"
cxx = "${goma_prefix}$prefix/clang++"
ar = "${prefix}/llvm-ar"
ld = cxx
strip = "strip"
is_clang = true
if (mac_enable_relative_sdk_path) {
mac_sdk_path = rebase_path(mac_sdk_path, root_build_dir)
}
sysroot_flags = "-isysroot $mac_sdk_path -mmacosx-version-min=$mac_sdk_min"
}
# Toolchain used for Mac host (i386) targets.
mac_toolchain("clang_x86") {
toolchain_cpu = "i386"
toolchain_os = "mac"
prefix = rebase_path("//buildtools/mac-x64/clang/bin", root_build_dir)
prefix = rebased_clang_dir
cc = "${goma_prefix}$prefix/clang"
cxx = "${goma_prefix}$prefix/clang++"
ar = "${prefix}/llvm-ar"
@ -248,7 +239,7 @@ mac_toolchain("clang_x86") {
mac_toolchain("clang_arm64") {
toolchain_cpu = "arm64"
toolchain_os = "mac"
prefix = rebase_path("//buildtools/mac-x64/clang/bin", root_build_dir)
prefix = rebased_clang_dir
cc = "${goma_prefix}$prefix/clang"
cxx = "${goma_prefix}$prefix/clang++"
ar = "${prefix}/llvm-ar"

View file

@ -61,6 +61,24 @@ config("dart_precompiled_runtime_config") {
]
}
config("add_empty_macho_section_config") {
if (is_mac) {
# We create an empty __space_for_note section in a __CUSTOM segment to
# reserve the header space needed for inserting a snapshot into the
# executable when creating standalone executables. This segment and section
# is removed in standalone executables, replaced with a note that points to
# the snapshot in the file.
#
# (A segment load command with a single section is 132 bytes in 32-bit
# executables and 152 bytes in 64-bit ones, and a note load command is
# always 40 bytes.)
#
# Keep this in sync with the constants reservedSegmentName and
# reservedSectionName in pkg/dart2native/lib/macho_utils.dart.
ldflags = [ "-Wl,-add_empty_section,__CUSTOM,__space_for_note" ]
}
}
# Controls DART_PRECOMPILER #define.
config("dart_precompiler_config") {
defines = []

View file

@ -831,7 +831,10 @@ dart_executable("dart") {
}
dart_executable("dart_precompiled_runtime") {
extra_configs = [ "..:dart_precompiled_runtime_config" ]
extra_configs = [
"..:dart_precompiled_runtime_config",
"..:add_empty_macho_section_config",
]
extra_deps = [
"..:libdart_precompiled_runtime",
"../platform:libdart_platform_precompiled_runtime",
@ -862,7 +865,10 @@ dart_executable("dart_precompiled_runtime") {
dart_executable("dart_precompiled_runtime_product") {
use_product_mode = true
extra_configs = [ "..:dart_precompiled_runtime_config" ]
extra_configs = [
"..:dart_precompiled_runtime_config",
"..:add_empty_macho_section_config",
]
extra_deps = [
"..:libdart_precompiled_runtime_product",
"../platform:libdart_platform_precompiled_runtime_product",

View file

@ -11,9 +11,9 @@
namespace dart {
#if defined(DEBUG)
const intptr_t kSkipCount = 6;
const intptr_t kSkipCount = 7;
#elif !(defined(PRODUCT) || defined(DEBUG))
const intptr_t kSkipCount = 5;
const intptr_t kSkipCount = 6;
#endif
} // namespace dart