Skip to content

Commit a402116

Browse files
allevatoswiple-rules-gardener
authored andcommitted
Add a feature to allow Swift targets to skip embedding the .swiftmodule file in debug info.
* To disable `.swiftmodule` embedding for a single `swift_{binary,library,test}` target, add `features = ["swift.no_embed_debug_module"]` to that target. * To disable `.swiftmodule` embedding for all Swift targets in a build package, add `features = ["swift.no_embed_debug_module"]` to the `package(...)` declaration in that BUILD file. * To disable `.swiftmodule` embedding for an entire build invocation, pass `--features=swift.no_embed_debug_module` on the command line. (The feature only affects the target it is applied to, not its `deps`. To turn it off universally, use the command line option.) This is intended to be a workaround for apps with large Swift dependency graphs until Xcode 12 releases a fixed version of `ld64` that supports param files. Using this feature may cause a regression in the debugging experience (e.g., breakpoints, expression evaluation) for modules where it is enabled. RELNOTES: None. PiperOrigin-RevId: 322195872
1 parent 68e203d commit a402116

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

swift/internal/compiling.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ load(
4545
"SWIFT_FEATURE_INDEX_WHILE_BUILDING",
4646
"SWIFT_FEATURE_MINIMAL_DEPS",
4747
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
48+
"SWIFT_FEATURE_NO_EMBED_DEBUG_MODULE",
4849
"SWIFT_FEATURE_NO_GENERATED_HEADER",
4950
"SWIFT_FEATURE_NO_GENERATED_MODULE_MAP",
5051
"SWIFT_FEATURE_OPT",
@@ -1704,7 +1705,14 @@ def _register_post_compile_actions(
17041705
# binary for debugging purposes.
17051706
linker_flags = []
17061707
linker_inputs = []
1707-
if _is_debugging(feature_configuration = feature_configuration):
1708+
should_embed_swiftmodule_for_debugging = (
1709+
_is_debugging(feature_configuration = feature_configuration) and
1710+
not is_feature_enabled(
1711+
feature_configuration = feature_configuration,
1712+
feature_name = SWIFT_FEATURE_NO_EMBED_DEBUG_MODULE,
1713+
)
1714+
)
1715+
if should_embed_swiftmodule_for_debugging:
17081716
module_embed_results = ensure_swiftmodule_is_embedded(
17091717
actions = actions,
17101718
feature_configuration = feature_configuration,

swift/internal/feature_names.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,12 @@ SWIFT_FEATURE_EMIT_SWIFTINTERFACE = "swift.emit_swiftinterface"
191191
# This allows Bazel to avoid propagating swiftmodules of such dependencies
192192
# higher in the dependency graph than they need to be.
193193
SWIFT_FEATURE_SUPPORTS_PRIVATE_DEPS = "swift.supports_private_deps"
194+
195+
# If enabled, the .swiftmodule file for the affected target will not be
196+
# embedded in debug info and propagated to the linker.
197+
#
198+
# The name of this feature is negative because it is meant to be a temporary
199+
# workaround until ld64 is fixed (in Xcode 12) so that builds that pass large
200+
# numbers of `-Wl,-add_ast_path,<path>` flags to the linker do not overrun the
201+
# system command line limit.
202+
SWIFT_FEATURE_NO_EMBED_DEBUG_MODULE = "swift.no_embed_debug_module"

0 commit comments

Comments
 (0)