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

Commit

Permalink
Get rid of the non-strict use of -fmodules-decluse.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
allevato authored and swiple-rules-gardener committed May 25, 2021
1 parent 9afbc30 commit 214f725
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,6 @@ def compile_action_configs(

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

def c_layering_check_configurator(prerequisites, args, *, strict):
# We do not enforce layering checks for the Objective-C header generated
# by Swift, because we don't have predictable control over the imports
# that it generates. Due to modular re-exports (which are especially
# common among system frameworks), it may generate an import declaration
# for a particular symbol from a different module than the Swift code
# imported it from.
if not prerequisites.is_swift_generated_header:
args.add(
"-Xcc",
"-fmodules-strict-decluse" if strict else "-fmodules-decluse",
)
return None

action_configs += [
# Treat paths in .modulemap files as workspace-relative, not modulemap-
# relative.
Expand Down Expand Up @@ -459,27 +445,7 @@ def compile_action_configs(
),
swift_toolchain_config.action_config(
actions = [swift_action_names.PRECOMPILE_C_MODULE],
configurators = [
lambda prerequisites, args: c_layering_check_configurator(
prerequisites,
args,
strict = False,
),
],
not_features = [
[SWIFT_FEATURE_LAYERING_CHECK],
[SWIFT_FEATURE_SYSTEM_MODULE],
],
),
swift_toolchain_config.action_config(
actions = [swift_action_names.PRECOMPILE_C_MODULE],
configurators = [
lambda prerequisites, args: c_layering_check_configurator(
prerequisites,
args,
strict = True,
),
],
configurators = [_c_layering_check_configurator],
features = [SWIFT_FEATURE_LAYERING_CHECK],
not_features = [SWIFT_FEATURE_SYSTEM_MODULE],
),
Expand Down Expand Up @@ -789,6 +755,16 @@ def _batch_mode_configurator(prerequisites, args):
if not _is_wmo_manually_requested(prerequisites.user_compile_flags):
args.add("-enable-batch-mode")

def _c_layering_check_configurator(prerequisites, args):
# We do not enforce layering checks for the Objective-C header generated by
# Swift, because we don't have predictable control over the imports that it
# generates. Due to modular re-exports (which are especially common among
# system frameworks), it may generate an import declaration for a particular
# symbol from a different module than the Swift code imported it from.
if not prerequisites.is_swift_generated_header:
args.add("-Xcc", "-fmodules-strict-decluse")
return None

def _clang_search_paths_configurator(prerequisites, args):
"""Adds Clang search paths to the command line."""
args.add_all(
Expand Down

0 comments on commit 214f725

Please sign in to comment.