Skip to content

Commit 3148da2

Browse files
committed
Chore: rebase and fix conflicts with latest main
1 parent 22aff3e commit 3148da2

11 files changed

Lines changed: 59 additions & 70 deletions

File tree

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ bazel_dep(name = "apple_support", version = "1.24.2", repo_name = "build_bazel_a
1414
bazel_dep(name = "rules_cc", version = "0.2.14")
1515
bazel_dep(name = "rules_shell", version = "0.3.0")
1616
bazel_dep(name = "platforms", version = "0.0.11")
17-
bazel_dep(name = "protobuf", version = "29.0", repo_name = "com_google_protobuf")
17+
bazel_dep(name = "protobuf", version = "30.0", repo_name = "com_google_protobuf")
1818
bazel_dep(name = "nlohmann_json", version = "3.12.0.bcr.1", repo_name = "com_github_nlohmann_json")
1919
bazel_dep(name = "abseil-cpp", version = "20250127.0")
20-
bazel_dep(name = "re2", version = "2024-07-02")
20+
bazel_dep(name = "re2", version = "2025-11-05")
2121
bazel_dep(
2222
name = "swift_argument_parser",
2323
version = "1.3.1.2",

doc/providers.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ Propagates Swift-specific information about a `proto_library`.
110110

111111
<pre>
112112
SwiftToolchainInfo(<a href="#SwiftToolchainInfo-action_configs">action_configs</a>, <a href="#SwiftToolchainInfo-cc_language">cc_language</a>, <a href="#SwiftToolchainInfo-cc_toolchain_info">cc_toolchain_info</a>, <a href="#SwiftToolchainInfo-clang_implicit_deps_providers">clang_implicit_deps_providers</a>,
113-
<a href="#SwiftToolchainInfo-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#SwiftToolchainInfo-cross_import_overlays">cross_import_overlays</a>, <a href="#SwiftToolchainInfo-debug_outputs_provider">debug_outputs_provider</a>,
114-
<a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>, <a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>,
115-
<a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>,
116-
<a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>, <a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>,
117-
<a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>, <a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
113+
<a href="#SwiftToolchainInfo-codegen_batch_size">codegen_batch_size</a>, <a href="#SwiftToolchainInfo-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#SwiftToolchainInfo-cross_import_overlays">cross_import_overlays</a>,
114+
<a href="#SwiftToolchainInfo-debug_outputs_provider">debug_outputs_provider</a>, <a href="#SwiftToolchainInfo-developer_dirs">developer_dirs</a>, <a href="#SwiftToolchainInfo-entry_point_linkopts_provider">entry_point_linkopts_provider</a>,
115+
<a href="#SwiftToolchainInfo-feature_allowlists">feature_allowlists</a>, <a href="#SwiftToolchainInfo-generated_header_module_implicit_deps_providers">generated_header_module_implicit_deps_providers</a>,
116+
<a href="#SwiftToolchainInfo-implicit_deps_providers">implicit_deps_providers</a>, <a href="#SwiftToolchainInfo-module_aliases">module_aliases</a>, <a href="#SwiftToolchainInfo-package_configurations">package_configurations</a>,
117+
<a href="#SwiftToolchainInfo-requested_features">requested_features</a>, <a href="#SwiftToolchainInfo-root_dir">root_dir</a>, <a href="#SwiftToolchainInfo-swift_worker">swift_worker</a>, <a href="#SwiftToolchainInfo-test_configuration">test_configuration</a>, <a href="#SwiftToolchainInfo-tool_configs">tool_configs</a>,
118+
<a href="#SwiftToolchainInfo-unsupported_features">unsupported_features</a>)
118119
</pre>
119120

120121
Propagates information about a Swift toolchain to compilation and linking rules
@@ -128,6 +129,7 @@ that use the toolchain.
128129
| <a id="SwiftToolchainInfo-cc_language"></a>cc_language | The `language` that should be passed to `cc_common` APIs that take it as an argument. |
129130
| <a id="SwiftToolchainInfo-cc_toolchain_info"></a>cc_toolchain_info | The `cc_common.CcToolchainInfo` provider from the Bazel C++ toolchain that this Swift toolchain depends on. |
130131
| <a id="SwiftToolchainInfo-clang_implicit_deps_providers"></a>clang_implicit_deps_providers | A `struct` with the following fields, which represent providers from targets that should be added as implicit dependencies of any precompiled explicit C/Objective-C modules:<br><br>* `cc_infos`: A list of `CcInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>* `swift_infos`: A list of `SwiftInfo` providers from targets specified as the toolchain's implicit dependencies.<br><br>For ease of use, this field is never `None`; it will always be a valid `struct` containing the fields described above, even if those lists are empty. |
132+
| <a id="SwiftToolchainInfo-codegen_batch_size"></a>codegen_batch_size | The number of files to pass to the compiler in a single code generation action (one that compiles object files from Swift source files). |
131133
| <a id="SwiftToolchainInfo-const_protocols_to_gather"></a>const_protocols_to_gather | `File`. A JSON file specifying a list of protocols for extraction of conformances' const values. |
132134
| <a id="SwiftToolchainInfo-cross_import_overlays"></a>cross_import_overlays | A list of `SwiftCrossImportOverlayInfo` providers whose `SwiftInfo` providers will be automatically injected into the dependencies of Swift compilations if their declaring module and bystanding module are both already declared as dependencies. |
133135
| <a id="SwiftToolchainInfo-debug_outputs_provider"></a>debug_outputs_provider | An optional function that provides toolchain-specific logic around the handling of additional debug outputs for `swift_binary` and `swift_test` targets.<br><br>If specified, this function must take the following keyword arguments:<br><br>* `ctx`: The rule context of the calling binary or test rule.<br><br>It must return a `struct` with the following fields:<br><br>* `additional_outputs`: Additional outputs expected from the linking action.<br><br>* `variables_extension`: A dictionary of additional crosstool variables to pass to the linking action. |

swift/internal/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ bzl_library(
316316
bzl_library(
317317
name = "optimization",
318318
srcs = ["optimization.bzl"],
319+
visibility = ["//swift:__subpackages__"],
319320
deps = [
320321
":feature_names",
321322
],

swift/internal/compiling.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ load(":actions.bzl", "is_action_enabled", "run_toolchain_action")
3838
load(":explicit_module_map_file.bzl", "write_explicit_swift_module_map_file")
3939
load(
4040
":feature_names.bzl",
41-
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
42-
"SWIFT_FEATURE__OPT_IN_SWIFTCOPTS",
43-
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
4441
"SWIFT_FEATURE_ADD_TARGET_NAME_TO_OUTPUT",
4542
"SWIFT_FEATURE_COMPILE_IN_PARALLEL",
4643
"SWIFT_FEATURE_DECLARE_SWIFTSOURCEINFO",
@@ -57,14 +54,17 @@ load(
5754
"SWIFT_FEATURE_MODULAR_INDEXING",
5855
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
5956
"SWIFT_FEATURE_NO_GENERATED_MODULE_MAP",
57+
"SWIFT_FEATURE_OPT",
6058
"SWIFT_FEATURE_OPT_USES_CMO",
6159
"SWIFT_FEATURE_OPT_USES_WMO",
62-
"SWIFT_FEATURE_OPT",
6360
"SWIFT_FEATURE_PROPAGATE_GENERATED_MODULE_MAP",
6461
"SWIFT_FEATURE_SYSTEM_MODULE",
6562
"SWIFT_FEATURE_THIN_LTO",
6663
"SWIFT_FEATURE_USE_EXPLICIT_SWIFT_MODULE_MAP",
6764
"SWIFT_FEATURE_VFSOVERLAY",
65+
"SWIFT_FEATURE__NUM_THREADS_0_IN_SWIFTCOPTS",
66+
"SWIFT_FEATURE__OPT_IN_SWIFTCOPTS",
67+
"SWIFT_FEATURE__WMO_IN_SWIFTCOPTS",
6868
)
6969
load(
7070
":features.bzl",

swift/internal/features.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ load(
2222
"SWIFT_FEATURE_CHECKED_EXCLUSIVITY",
2323
"SWIFT_FEATURE_COVERAGE",
2424
"SWIFT_FEATURE_COVERAGE_PREFIX_MAP",
25+
"SWIFT_FEATURE_DEBUG_PREFIX_MAP",
2526
"SWIFT_FEATURE_DISABLE_CLANG_SPI",
2627
"SWIFT_FEATURE_DISABLE_SYSTEM_INDEX",
2728
"SWIFT_FEATURE_EMIT_SWIFTDOC",
@@ -273,6 +274,7 @@ def default_features_for_toolchain(target_triple):
273274
SWIFT_FEATURE_CACHEABLE_SWIFTMODULES,
274275
SWIFT_FEATURE_CHECKED_EXCLUSIVITY,
275276
SWIFT_FEATURE_COVERAGE_PREFIX_MAP,
277+
SWIFT_FEATURE_DEBUG_PREFIX_MAP,
276278
SWIFT_FEATURE_DISABLE_CLANG_SPI,
277279
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX,
278280
SWIFT_FEATURE_EMIT_SWIFTDOC,

swift/toolchains/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ bzl_library(
1414
"//swift/internal:debugging",
1515
"//swift/internal:feature_names",
1616
"//swift/internal:features",
17+
"//swift/internal:optimization",
1718
"//swift/internal:providers",
1819
"//swift/internal:target_triples",
1920
"//swift/internal:utils",
20-
"//swift/internal:wmo",
2121
"//swift/toolchains/config:action_config",
2222
"//swift/toolchains/config:all_actions_config",
2323
"//swift/toolchains/config:compile_config",
@@ -42,10 +42,10 @@ bzl_library(
4242
"//swift/internal:attrs",
4343
"//swift/internal:feature_names",
4444
"//swift/internal:features",
45+
"//swift/internal:optimization",
4546
"//swift/internal:providers",
4647
"//swift/internal:target_triples",
4748
"//swift/internal:utils",
48-
"//swift/internal:wmo",
4949
"//swift/toolchains/config:action_config",
5050
"//swift/toolchains/config:all_actions_config",
5151
"//swift/toolchains/config:compile_config",

swift/toolchains/config/compile_config.bzl

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,7 @@ def compile_action_configs(
592592
action_configs.append(
593593
# Support for order-file instrumentation.
594594
ActionConfigInfo(
595-
actions = [
596-
SWIFT_ACTION_COMPILE,
597-
],
595+
actions = all_compile_action_names(),
598596
configurators = [
599597
add_arg("-sanitize=undefined"),
600598
add_arg("-sanitize-coverage=func"),
@@ -851,9 +849,7 @@ def compile_action_configs(
851849
features = [SWIFT_FEATURE_VFSOVERLAY],
852850
),
853851
ActionConfigInfo(
854-
actions = [
855-
SWIFT_ACTION_COMPILE,
856-
],
852+
actions = all_compile_action_names(),
857853
configurators = [_module_aliases_configurator],
858854
),
859855
ActionConfigInfo(
@@ -1065,15 +1061,6 @@ def compile_action_configs(
10651061
],
10661062
configurators = [_module_name_configurator],
10671063
),
1068-
ActionConfigInfo(
1069-
actions = all_compile_action_names() + [
1070-
SWIFT_ACTION_PRECOMPILE_C_MODULE,
1071-
],
1072-
configurators = [
1073-
add_arg("-file-prefix-map", "__BAZEL_XCODE_DEVELOPER_DIR__=DEVELOPER_DIR"),
1074-
],
1075-
features = [SWIFT_FEATURE_FILE_PREFIX_MAP],
1076-
),
10771064

10781065
# Set the package name.
10791066
ActionConfigInfo(
@@ -1193,9 +1180,7 @@ def compile_action_configs(
11931180
],
11941181
),
11951182
ActionConfigInfo(
1196-
actions = [
1197-
SWIFT_ACTION_COMPILE,
1198-
],
1183+
actions = all_compile_action_names(),
11991184
configurators = [
12001185
add_arg("-cxx-interoperability-mode=default"),
12011186
add_arg("-Xcc", "-std=c++17"),
@@ -1205,9 +1190,7 @@ def compile_action_configs(
12051190
],
12061191
),
12071192
ActionConfigInfo(
1208-
actions = [
1209-
SWIFT_ACTION_COMPILE,
1210-
],
1193+
actions = all_compile_action_names(),
12111194
configurators = [
12121195
add_arg("-cxx-interoperability-mode=default"),
12131196
add_arg("-Xcc", "-std=c++20"),
@@ -1217,9 +1200,7 @@ def compile_action_configs(
12171200
],
12181201
),
12191202
ActionConfigInfo(
1220-
actions = [
1221-
SWIFT_ACTION_COMPILE,
1222-
],
1203+
actions = all_compile_action_names(),
12231204
configurators = [
12241205
add_arg("-cxx-interoperability-mode=default"),
12251206
add_arg("-Xcc", "-std=c++23"),
@@ -1229,9 +1210,7 @@ def compile_action_configs(
12291210
],
12301211
),
12311212
ActionConfigInfo(
1232-
actions = [
1233-
SWIFT_ACTION_COMPILE,
1234-
],
1213+
actions = all_compile_action_names(),
12351214
configurators = [
12361215
add_arg("-enable-experimental-feature", "Embedded"),
12371216
],
@@ -1261,7 +1240,7 @@ def compile_action_configs(
12611240
ActionConfigInfo(
12621241
actions = all_compile_action_names() + [
12631242
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1264-
SWIFT_ACTION_DUMP_AST,
1243+
SWIFT_ACTION_DUMP_AST,
12651244
SWIFT_ACTION_PRECOMPILE_C_MODULE,
12661245
SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT,
12671246
SWIFT_ACTION_SYNTHESIZE_INTERFACE,
@@ -1282,7 +1261,7 @@ def compile_action_configs(
12821261
# actions, or if we should advise against/forbid that.
12831262
actions = all_compile_action_names() + [
12841263
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1285-
SWIFT_ACTION_DUMP_AST,
1264+
SWIFT_ACTION_DUMP_AST,
12861265
],
12871266
configurators = [
12881267
lambda _, args: args.add_all(
@@ -1312,17 +1291,15 @@ def compile_action_configs(
13121291
),
13131292
)
13141293

1315-
action_configs.extend(
1316-
[
1317-
ActionConfigInfo(
1318-
actions = all_compile_action_names() + [
1319-
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1320-
SWIFT_ACTION_DUMP_AST,
1321-
SWIFT_ACTION_PRECOMPILE_C_MODULE,
1322-
],
1323-
configurators = [_source_files_configurator],
1324-
),
1325-
],
1294+
action_configs.append(
1295+
ActionConfigInfo(
1296+
actions = all_compile_action_names() + [
1297+
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1298+
SWIFT_ACTION_DUMP_AST,
1299+
SWIFT_ACTION_PRECOMPILE_C_MODULE,
1300+
],
1301+
configurators = [_source_files_configurator],
1302+
),
13261303
)
13271304

13281305
# Add additional input files to the sandbox (does not modify flags).

swift/toolchains/swift_toolchain.bzl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ load(
3939
"//swift/internal:action_names.bzl",
4040
"SWIFT_ACTION_AUTOLINK_EXTRACT",
4141
"SWIFT_ACTION_COMPILE",
42+
"SWIFT_ACTION_COMPILE_CODEGEN",
43+
"SWIFT_ACTION_COMPILE_MODULE",
4244
"SWIFT_ACTION_COMPILE_MODULE_INTERFACE",
4345
"SWIFT_ACTION_DUMP_AST",
4446
"SWIFT_ACTION_MODULEWRAP",
@@ -147,6 +149,8 @@ def _all_tool_configs(
147149

148150
tool_configs = {
149151
SWIFT_ACTION_COMPILE: compile_tool_config,
152+
SWIFT_ACTION_COMPILE_CODEGEN: compile_tool_config,
153+
SWIFT_ACTION_COMPILE_MODULE: compile_tool_config,
150154
SWIFT_ACTION_DUMP_AST: compile_tool_config,
151155
SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT: ToolConfigInfo(
152156
additional_tools = additional_tools,
@@ -459,9 +463,13 @@ def _swift_toolchain_impl(ctx):
459463

460464
# Combine build mode features, autoconfigured features, and required
461465
# features.
462-
features_from_swiftcopts, _ = optimization_features_from_swiftcopts(swiftcopts = swiftcopts)
466+
requested_build_mode_features, _ = features_for_build_modes(ctx)
467+
requested_optimization_features, _ = optimization_features_from_swiftcopts(
468+
swiftcopts = swiftcopts,
469+
)
463470
requested_features = (
464-
features_for_build_modes(ctx) + features_from_swiftcopts
471+
requested_build_mode_features +
472+
requested_optimization_features
465473
)
466474
requested_features.extend(default_features_for_toolchain(
467475
target_triple = target_triple,
@@ -669,7 +677,8 @@ to the compiler for exec transition builds.
669677
allow_files = True,
670678
default = Label("//tools/worker"),
671679
doc = """\
672-
An executable that wraps Swift compiler invocations.
680+
An executable that wraps Swift compiler invocations and also provides support
681+
for incremental compilation using a persistent mode.
673682
""",
674683
executable = True,
675684
),

test/fixtures/debug_settings/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,3 @@ swift_library(
2323
],
2424
tags = FIXTURE_TAGS,
2525
)
26-
27-
swift_library(
28-
name = "simple_batch_mode",
29-
srcs = ["Empty.swift"],
30-
tags = FIXTURE_TAGS,
31-
)

tools/common/bazel_substitutions.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ namespace {
2929

3030
// Returns the value of the given environment variable, or the empty string if
3131
// it wasn't set.
32-
std::string GetEnvironmentVariable(absl::string_view name) {
32+
std::string GetAppleEnvironmentVariable(absl::string_view name) {
33+
#if !defined(__APPLE__)
34+
return "";
35+
#endif
36+
3337
std::string null_terminated_name(name.data(), name.length());
3438
char *env_value = getenv(null_terminated_name.c_str());
3539
if (env_value == nullptr) {
@@ -39,7 +43,7 @@ std::string GetEnvironmentVariable(absl::string_view name) {
3943
return env_value;
4044
}
4145

42-
std::string GetToolchainPath() {
46+
std::string GetAppleToolchainPath() {
4347
#if !defined(__APPLE__)
4448
return "";
4549
#endif
@@ -86,15 +90,15 @@ BazelPlaceholderSubstitutions::BazelPlaceholderSubstitutions() {
8690
// the build rules. If the variable isn't set, we don't store a substitution;
8791
// if it was needed then the eventual replacement will be a no-op and the
8892
// command will presumably fail later.
89-
if (std::string developer_dir = GetEnvironmentVariable("DEVELOPER_DIR");
93+
if (std::string developer_dir = GetAppleEnvironmentVariable("DEVELOPER_DIR");
9094
!developer_dir.empty()) {
9195
substitutions_[kBazelXcodeDeveloperDir] = developer_dir;
9296
}
93-
if (std::string sdk_root = GetEnvironmentVariable("SDKROOT");
97+
if (std::string sdk_root = GetAppleEnvironmentVariable("SDKROOT");
9498
!sdk_root.empty()) {
9599
substitutions_[kBazelXcodeSdkRoot] = sdk_root;
96100
}
97-
if (std::string toolchain_path = GetToolchainPath();
101+
if (std::string toolchain_path = GetAppleToolchainPath();
98102
!toolchain_path.empty()) {
99103
substitutions_[kBazelSwiftToolchainPath] = toolchain_path;
100104
}

0 commit comments

Comments
 (0)