Skip to content

Commit 230b2dc

Browse files
committed
Rebase, fix conflicts and issues with latest main from Dec. 17
1 parent 1b6728c commit 230b2dc

11 files changed

Lines changed: 55 additions & 61 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 & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,7 @@ def compile_action_configs(
593593
action_configs.append(
594594
# Support for order-file instrumentation.
595595
ActionConfigInfo(
596-
actions = [
597-
SWIFT_ACTION_COMPILE,
598-
],
596+
actions = all_compile_action_names(),
599597
configurators = [
600598
add_arg("-sanitize=undefined"),
601599
add_arg("-sanitize-coverage=func"),
@@ -852,9 +850,7 @@ def compile_action_configs(
852850
features = [SWIFT_FEATURE_VFSOVERLAY],
853851
),
854852
ActionConfigInfo(
855-
actions = [
856-
SWIFT_ACTION_COMPILE,
857-
],
853+
actions = all_compile_action_names(),
858854
configurators = [_module_aliases_configurator],
859855
),
860856
ActionConfigInfo(
@@ -1194,9 +1190,7 @@ def compile_action_configs(
11941190
],
11951191
),
11961192
ActionConfigInfo(
1197-
actions = [
1198-
SWIFT_ACTION_COMPILE,
1199-
],
1193+
actions = all_compile_action_names(),
12001194
configurators = [
12011195
add_arg("-cxx-interoperability-mode=default"),
12021196
add_arg("-Xcc", "-std=c++17"),
@@ -1206,9 +1200,7 @@ def compile_action_configs(
12061200
],
12071201
),
12081202
ActionConfigInfo(
1209-
actions = [
1210-
SWIFT_ACTION_COMPILE,
1211-
],
1203+
actions = all_compile_action_names(),
12121204
configurators = [
12131205
add_arg("-cxx-interoperability-mode=default"),
12141206
add_arg("-Xcc", "-std=c++20"),
@@ -1218,9 +1210,7 @@ def compile_action_configs(
12181210
],
12191211
),
12201212
ActionConfigInfo(
1221-
actions = [
1222-
SWIFT_ACTION_COMPILE,
1223-
],
1213+
actions = all_compile_action_names(),
12241214
configurators = [
12251215
add_arg("-cxx-interoperability-mode=default"),
12261216
add_arg("-Xcc", "-std=c++23"),
@@ -1230,9 +1220,7 @@ def compile_action_configs(
12301220
],
12311221
),
12321222
ActionConfigInfo(
1233-
actions = [
1234-
SWIFT_ACTION_COMPILE,
1235-
],
1223+
actions = all_compile_action_names(),
12361224
configurators = [
12371225
add_arg("-enable-experimental-feature", "Embedded"),
12381226
],
@@ -1262,7 +1250,7 @@ def compile_action_configs(
12621250
ActionConfigInfo(
12631251
actions = all_compile_action_names() + [
12641252
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1265-
SWIFT_ACTION_DUMP_AST,
1253+
SWIFT_ACTION_DUMP_AST,
12661254
SWIFT_ACTION_PRECOMPILE_C_MODULE,
12671255
SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT,
12681256
SWIFT_ACTION_SYNTHESIZE_INTERFACE,
@@ -1283,7 +1271,7 @@ def compile_action_configs(
12831271
# actions, or if we should advise against/forbid that.
12841272
actions = all_compile_action_names() + [
12851273
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1286-
SWIFT_ACTION_DUMP_AST,
1274+
SWIFT_ACTION_DUMP_AST,
12871275
],
12881276
configurators = [
12891277
lambda _, args: args.add_all(
@@ -1313,17 +1301,15 @@ def compile_action_configs(
13131301
),
13141302
)
13151303

1316-
action_configs.extend(
1317-
[
1318-
ActionConfigInfo(
1319-
actions = all_compile_action_names() + [
1320-
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1321-
SWIFT_ACTION_DUMP_AST,
1322-
SWIFT_ACTION_PRECOMPILE_C_MODULE,
1323-
],
1324-
configurators = [_source_files_configurator],
1325-
),
1326-
],
1304+
action_configs.append(
1305+
ActionConfigInfo(
1306+
actions = all_compile_action_names() + [
1307+
SWIFT_ACTION_COMPILE_MODULE_INTERFACE,
1308+
SWIFT_ACTION_DUMP_AST,
1309+
SWIFT_ACTION_PRECOMPILE_C_MODULE,
1310+
],
1311+
configurators = [_source_files_configurator],
1312+
),
13271313
)
13281314

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

swift/toolchains/swift_toolchain.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,13 @@ def _swift_toolchain_impl(ctx):
459459

460460
# Combine build mode features, autoconfigured features, and required
461461
# features.
462-
features_from_swiftcopts, _ = optimization_features_from_swiftcopts(swiftcopts = swiftcopts)
462+
requested_build_mode_features, _ = features_for_build_modes(ctx)
463+
requested_optimization_features, _ = optimization_features_from_swiftcopts(
464+
swiftcopts = swiftcopts,
465+
)
463466
requested_features = (
464-
features_for_build_modes(ctx) + features_from_swiftcopts
467+
requested_build_mode_features +
468+
requested_optimization_features
465469
)
466470
requested_features.extend(default_features_for_toolchain(
467471
target_triple = target_triple,
@@ -668,7 +672,8 @@ to the compiler for exec transition builds.
668672
allow_files = True,
669673
default = Label("//tools/worker"),
670674
doc = """\
671-
An executable that wraps Swift compiler invocations.
675+
An executable that wraps Swift compiler invocations and also provides support
676+
for incremental compilation using a persistent mode.
672677
""",
673678
executable = True,
674679
),

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)