Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 214f725

Browse files
allevatoswiple-rules-gardener
authored andcommitted
Get rid of the non-strict use of -fmodules-decluse.
For layering checks with explicit modules, we only want `-fmodules-strict-decluse`; it's not useful to let headers without a known module map sneak through. PiperOrigin-RevId: 375825780
1 parent 9afbc30 commit 214f725

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

swift/internal/compiling.bzl

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ def compile_action_configs(
365365

366366
#### Flags controlling how Swift/Clang modular inputs are processed
367367

368-
def c_layering_check_configurator(prerequisites, args, *, strict):
369-
# We do not enforce layering checks for the Objective-C header generated
370-
# by Swift, because we don't have predictable control over the imports
371-
# that it generates. Due to modular re-exports (which are especially
372-
# common among system frameworks), it may generate an import declaration
373-
# for a particular symbol from a different module than the Swift code
374-
# imported it from.
375-
if not prerequisites.is_swift_generated_header:
376-
args.add(
377-
"-Xcc",
378-
"-fmodules-strict-decluse" if strict else "-fmodules-decluse",
379-
)
380-
return None
381-
382368
action_configs += [
383369
# Treat paths in .modulemap files as workspace-relative, not modulemap-
384370
# relative.
@@ -459,27 +445,7 @@ def compile_action_configs(
459445
),
460446
swift_toolchain_config.action_config(
461447
actions = [swift_action_names.PRECOMPILE_C_MODULE],
462-
configurators = [
463-
lambda prerequisites, args: c_layering_check_configurator(
464-
prerequisites,
465-
args,
466-
strict = False,
467-
),
468-
],
469-
not_features = [
470-
[SWIFT_FEATURE_LAYERING_CHECK],
471-
[SWIFT_FEATURE_SYSTEM_MODULE],
472-
],
473-
),
474-
swift_toolchain_config.action_config(
475-
actions = [swift_action_names.PRECOMPILE_C_MODULE],
476-
configurators = [
477-
lambda prerequisites, args: c_layering_check_configurator(
478-
prerequisites,
479-
args,
480-
strict = True,
481-
),
482-
],
448+
configurators = [_c_layering_check_configurator],
483449
features = [SWIFT_FEATURE_LAYERING_CHECK],
484450
not_features = [SWIFT_FEATURE_SYSTEM_MODULE],
485451
),
@@ -789,6 +755,16 @@ def _batch_mode_configurator(prerequisites, args):
789755
if not _is_wmo_manually_requested(prerequisites.user_compile_flags):
790756
args.add("-enable-batch-mode")
791757

758+
def _c_layering_check_configurator(prerequisites, args):
759+
# We do not enforce layering checks for the Objective-C header generated by
760+
# Swift, because we don't have predictable control over the imports that it
761+
# generates. Due to modular re-exports (which are especially common among
762+
# system frameworks), it may generate an import declaration for a particular
763+
# symbol from a different module than the Swift code imported it from.
764+
if not prerequisites.is_swift_generated_header:
765+
args.add("-Xcc", "-fmodules-strict-decluse")
766+
return None
767+
792768
def _clang_search_paths_configurator(prerequisites, args):
793769
"""Adds Clang search paths to the command line."""
794770
args.add_all(

0 commit comments

Comments
 (0)